Wednesday, July 11, 2007

RMAN - Testing of Recovery through the RESETLOGS point

Oracle 10 g new feature - Backups prior to the use of RESETLOGS can be
used to recover database to the point after the RESETLOGS


Overview of test steps
======================

1. Make a new backup or have a good whole database backup available.
2. Force the redo log activity to archive logs.
3. Validate the log sequence number to perform your incomplete recovery,
for which you use the RESETLOGS clause.
4. Shut down the database and delete the USERS01.DBF file to cause a
recovery situation.
5. Start up the database in MOUNT mode and use RMAN to perform an
incomplete recovery using the SET UNTIL SEQUENCE command.
6. When the incomplete recovery is complete, use the RESETLOGS clause to
open the database.
7. To recover through the RESETLOGS, you need to simulate more database
activity and force this activity to the archive logs. We will be using
the USERS tablespace.
8. Shut down the database and delete the USERS01.DBF to cause another
recovery situation.
9. Start up the database in MOUNT mode and use RMAN to perform a
complete recovery.
10. When the recovery is complete, just use an ALTER DATABASE OPEN
command.
11. Finally, view the V$LOG_HISTORY table and validate that the database
activity is available in the database.


Steps
=====
1. Perform a backup

2. Force all the redo log information to archive logs by executing ALTER
SYSTEM SWITCH LOGFILE:

sys@TOY10G> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G
Oldest online log sequence 36
Next log sequence to archive 38
Current log sequence 38
sys@TOY10G> alter system switch logfile;

System altered.

sys@TOY10G> alter system switch logfile;

System altered.

sys@TOY10G> alter system switch logfile;

System altered.

sys@TOY10G> alter system switch logfile;

System altered.

sys@TOY10G> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G
Oldest online log sequence 40
Next log sequence to archive 42
Current log sequence 42
sys@TOY10G>

3. Verify the redo log sequence and thread number in the V$LOG_HISTORY
table so that we can perform incomplete recovery to a redo log sequence:

sys@TOY10G> select * from v$log_history;

RECID STAMP THREAD# SEQUENCE# FIRST_CHANGE# FIRST_TIME
NEXT_CHANGE#
---------- ---------- ---------- ---------- -------------
-------------------- ------------
RESETLOGS_CHANGE# RESETLOGS_TIME
----------------- --------------------
229 622072816 1 229 1484411 08-MAY-2007
21:00:22 1487280
1 06-APR-2007 12:51:52

230 622072832 1 230 1487280 08-MAY-2007
22:00:16 1488399
1 06-APR-2007 12:51:52

231 622073883 1 231 1488399 08-MAY-2007
22:00:32 1490706
1 06-APR-2007 12:51:52


... .........

516 627639754 1 37 2875462 11-JUL-2007
00:00:58 2887413
2703078 06-JUL-2007 14:45:59

517 627639885 1 38 2887413 11-JUL-2007
08:22:34 2887469
2703078 06-JUL-2007 14:45:59

518 627639889 1 39 2887469 11-JUL-2007
08:24:45 2887471
2703078 06-JUL-2007 14:45:59

519 627639896 1 40 2887471 11-JUL-2007
08:24:49 2887477
2703078 06-JUL-2007 14:45:59

520 627639901 1 41 2887477 11-JUL-2007
08:24:56 2887479
2703078 06-JUL-2007 14:45:59


4. Simulate a failure by shutting down the database and deleting the
USERS01.DBF

sys@TOY10G> select name from v$datafile;

NAME

------------------------------------------------------------------------
----------------------------
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/system01.dbf
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/undotbs01.dbf
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/sysaux01.dbf
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/users01.dbf
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/indx01.dbf

sys@TOY10G> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@TOY10G> ho rm
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/users01.dbf

sys@TOY10G>

5. Begin the recovery process by starting the database in MOUNT mode

6. Perform an incomplete recovery using the SET UNTIL SEQUENCE clause
RMAN> connect target

connected to target database: TOY10G (DBID=3330944552, not open)

RMAN> run
2> {
3> set until sequence 39 thread 1;
4> restore database;
5> recover database;
6> }

executing command: SET until clause
using target database control file instead of recovery catalog

Starting restore at 11-JUL-2007 09:01:52
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=45 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/system01.dbf
restoring datafile 00002 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/undotbs01.dbf
restoring datafile 00003 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/sysaux01.dbf
restoring datafile 00004 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/users01.dbf
restoring datafile 00005 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/indx01.dbf
channel ORA_DISK_1: reading from backup piece
/ora01/orabkup/GENQ/.temp_toy10g/oracle/admin/TOY10G/backup/test_6276397
44_22_1.dbf
channel ORA_DISK_1: restored backup piece 1
piece
handle=/ora01/orabkup/GENQ/.temp_toy10g/oracle/admin/TOY10G/backup/test_
627639744_22_1.dbf tag=TAG20070711T082223
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
Finished restore at 11-JUL-2007 09:02:11

Starting recover at 11-JUL-2007 09:02:11
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 37 is already on disk as file
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_37_62723075
9.arc
archive log thread 1 sequence 38 is already on disk as file
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_38_62723075
9.arc
archive log
filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_37
_627230759.arc thread=1 sequence=37
archive log
filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_38
_627230759.arc thread=1 sequence=38
media recovery complete, elapsed time: 00:00:03
Finished recover at 11-JUL-2007 09:02:16

RMAN>
RMAN> alter database open resetlogs;

database opened

RMAN>

7. Simulate database activity by creating a table T1 and forcing this
activity to the
archived redo logs:

scott@TOY10G> create table t5(c char(20));

Table created.

scott@TOY10G> conn / as sysdba
Connected.
sys@TOY10G> alter system switch logfile;

System altered.

sys@TOY10G> ;
1* alter system switch logfile
sys@TOY10G> /

System altered.

sys@TOY10G> /

System altered.

sys@TOY10G> /

System altered.

sys@TOY10G>

8. Shut down the database and simulate a database failure by deleting
the
USERS01.DBF file:

9. Start the database in MOUNT mode and then perform a complete recovery
in
RMAN:

RMAN> connect target

connected to target database: TOY10G (DBID=3330944552, not open)

RMAN> run
2> {
3> restore database;
4> recover database;
5> }

Starting restore at 11-JUL-2007 09:22:37
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=47 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/system01.dbf
restoring datafile 00002 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/undotbs01.dbf
restoring datafile 00003 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/sysaux01.dbf
restoring datafile 00004 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/users01.dbf
restoring datafile 00005 to
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oradata/TOY10G/indx01.dbf
channel ORA_DISK_1: reading from backup piece
/ora01/orabkup/GENQ/.temp_toy10g/oracle/admin/TOY10G/backup/test_6276397
44_22_1.dbf
channel ORA_DISK_1: restored backup piece 1
piece
handle=/ora01/orabkup/GENQ/.temp_toy10g/oracle/admin/TOY10G/backup/test_
627639744_22_1.dbf tag=TAG20070711T082223
channel ORA_DISK_1: restore complete, elapsed time: 00:00:09
Finished restore at 11-JUL-2007 09:22:48

Starting recover at 11-JUL-2007 09:22:48
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 37 is already on disk as file
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_37_62723075
9.arc
archive log thread 1 sequence 38 is already on disk as file
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_38_62723075
9.arc
archive log thread 1 sequence 1 is already on disk as file
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_1_627642245
.arc
archive log thread 1 sequence 2 is already on disk as file
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_2_627642245
.arc
archive log thread 1 sequence 3 is already on disk as file
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_3_627642245
.arc
archive log thread 1 sequence 4 is already on disk as file
/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_4_627642245
.arc
archive log
filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_37
_627230759.arc thread=1 sequence=37
archive log
filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_38
_627230759.arc thread=1 sequence=38
archive log
filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_1_
627642245.arc thread=1 sequence=1
archive log
filename=/ora01/orabkup/GENQ/.temp_toy10g/ora01/oraarch/TOY10G/arch_1_2_
627642245.arc thread=1 sequence=2
media recovery complete, elapsed time: 00:00:03
Finished recover at 11-JUL-2007 09:22:52

RMAN> alter database open;

database opened

RMAN>

10. Validate that you have recovered through the last RESETLOGS by
verifying that the
current V$LOG_HISTORY table
516 627639754 1 37 2875462 11-JUL-2007
00:00:58 2887413
2703078 06-JUL-2007 14:45:59

517 627639885 1 38 2887413 11-JUL-2007
08:22:34 2887469
2703078 06-JUL-2007 14:45:59

518 627639889 1 39 2887469 11-JUL-2007
08:24:45 2887471
2703078 06-JUL-2007 14:45:59

519 627639896 1 40 2887471 11-JUL-2007
08:24:49 2887477
2703078 06-JUL-2007 14:45:59

520 627639901 1 41 2887477 11-JUL-2007
08:24:56 2887479
2703078 06-JUL-2007 14:45:59

521 627642522 1 1 2887470 11-JUL-2007
09:04:05 2887674
2887470 11-JUL-2007 09:04:05

522 627642526 1 2 2887674 11-JUL-2007
09:08:42 2887676
2887470 11-JUL-2007 09:04:05

523 627642530 1 3 2887676 11-JUL-2007
09:08:46 2887679
2887470 11-JUL-2007 09:04:05

524 627642535 1 4 2887679 11-JUL-2007
09:08:50 2887682
2887470 11-JUL-2007 09:04:05

No comments: