Saturday, January 19, 2008

"failover to previous backup" during RMAN "restore database"

I issued following commands to restore database files

$ ramn

Recovery Manager: Release 10.2.0.3.0 - Production on Wed Jan 16 19:08:07 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

RMAN> connect catalog rman@cat_db

recovery catalog database Password:
connected to recovery catalog database

RMAN> set dbid=3937750366

executing command: SET DBID
database name is "DB_NAME" and DBID is 3937750366

RMAN> connect target

connected to target database: DB_NAME (not mounted)

RMAN> RUN {
2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
3> ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
4> ALLOCATE CHANNEL ch02 TYPE 'SBT_TAPE';
5> ALLOCATE CHANNEL ch03 TYPE 'SBT_TAPE';
6> restore database;
7> RELEASE CHANNEL ch00;
8> RELEASE CHANNEL ch01;
9> RELEASE CHANNEL ch02;
10> RELEASE CHANNEL ch03;


I did not pay much attention to errors (caused by ASM) in RMAN:

ORA-19870: error reading backup piece bk_9tj5rapj_1_1_643672883
ORA-19504: failed to create file "+DATA/db_name/datafile/DW_table_idx"
ORA-17502: ksfdcre:4 Failed to create file +DATA/db_name/datafile/DW_table_idx
ORA-15055: unable to connect to ASM instance
ORA-00020: maximum number of processes () exceeded
channel ch01: restored backup piece 1
piece handle=bk_9uj5rapk_1_1_643672884 tag=TAG20080110T220118
channel ch01: restore complete, elapsed time: 00:53:26
failover to previous backup

After the restore, I had difficulty in bringing the database up. The below query result made me realize that the restoration totally failed (per Metalink note 465478.1) because the backup was a cold one and the query should return just one row.

SQL> select status, checkpoint_change#,
to_char(checkpoint_time, 'DD-MON-YYYY HH24:MI:SS') as checkpoint_time, count(*)
from v$datafile_header
group by status, checkpoint_change#, checkpoint_time
order by status, checkpoint_change#, checkpoint_time;

STATUS CHECKPOINT_CHANGE# CHECKPOINT_TIME COUNT(*)
------- ------------------ -------------------- ----------
ONLINE 3.1620E+10 08-JAN-2008 22:01:22 20
ONLINE 3.1620E+10 10-JAN-2008 22:00:31 20
ONLINE 3.1620E+10 13-JAN-2008 21:01:39 38

I had to re-run the restoration, and used "restore database from tag=TAG20080113T210228;" to make sure RMAN only restores the data files from the right tag which can be got from "list backup;" in RMAN.

Additional notes:
1. Before re-restoring, I did not manually delete datafiles restored by the 1st time in the ASM. RMAN recoglize and skips the good ones and only overwrites the bad ones.

2. It is necessary to make sure the status in V$DATAFILE_HEADER for all files is ONLINE, and it is normal to see the status in V$DATAFILE is RECOVER before running command "recover database;" or "alter database open resetlogs;".

3. Run below command to restore individual file:
RMAN> restore datafile 7;
or
RMAN> restore datafile 7 from tag=TAG20080113T210228;

4. After the database is recovered, when RMAN catalog connects to the database (target) again, it will resynchronize the recovery catalog automatically:

RMAN> connect target

new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
connected to target database: DB_NAME (DBID=3937750366)

1 comment:

Anonymous said...

ramn works?