使用RMAN在单实例恢复ASM文件系统的两节点RAC时遇到ORA-38856,ORA-01547,ORA-01152错误
Jan082016
前几天朋友在单实例上恢复两节点的RAC时,遇到ORA-01547、ORA-01152错误。
RMAN> run{ 2> sql 'alter session set nls_date_format= "YYYY-MM-DD HH24:MI:SS"'; 3> set until time '2015-12-19 00:10:30'; 4> recover database; 5> } sql statement: alter session set nls_date_format= "YYYY-MM-DD HH24:MI:SS" executing command: SET until clause Starting recover at 25-DEC-15 Starting implicit crosscheck backup at 25-DEC-15 released channel: ORA_DISK_1 released channel: ORA_DISK_2 released channel: ORA_DISK_3 released channel: ORA_DISK_4 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=35 devtype=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=34 devtype=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: sid=33 devtype=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: sid=32 devtype=DISK Crosschecked 54 objects Finished implicit crosscheck backup at 25-DEC-15 Starting implicit crosscheck copy at 25-DEC-15 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 Finished implicit crosscheck copy at 25-DEC-15 searching for all files in the recovery area cataloging files... no files cataloged using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 starting media recovery archive log thread 1 sequence 8958 is already on disk as file /opt/oracle/base/OracleHomes/db10g/dbs/arch1_8958_825071076.dbf archive log thread 2 sequence 7882 is already on disk as file /opt/oracle/base/OracleHomes/db10g/dbs/arch2_7882_825071076.dbf archive log filename=/opt/oracle/base/OracleHomes/db10g/dbs/arch1_8958_825071076.dbf thread=1 sequence=8958 archive log filename=/opt/oracle/base/OracleHomes/db10g/dbs/arch2_7882_825071076.dbf thread=2 sequence=7882 Oracle Error: ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/fshare/nacdb/system.260.825071011' media recovery complete, elapsed time: 00:00:04 Finished recover at 25-DEC-15 RMAN> alter database open resetlogs; RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 12/25/2015 14:20:34 ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/fshare/nacdb/system.260.825071011'
QQ远程协助发现,指定的恢复时间小于RMAN备份完成的时间,也就是说2015-12-19 00:10:30的时候,数据库的数据文件还没备份完成,通过查询备份文件的产生时间,发现最新的数据备份文件是2015-12-19 00:44:13,归档日志全部备份完的时间是2015-12-19 00:59:57,适当的调整恢复时间稍大于备份完成时间,恢复成功。
RMAN> run{ 2> sql 'alter session set nls_date_format= "YYYY-MM-DD HH24:MI:SS"'; 3> set until time '2015-12-19 09:48:05'; 4> recover database; 5> } sql statement: alter session set nls_date_format= "YYYY-MM-DD HH24:MI:SS" executing command: SET until clause Starting recover at 25-DEC-15 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 starting media recovery archive log thread 1 sequence 8958 is already on disk as file /opt/oracle/base/OracleHomes/db10g/dbs/arch1_8958_825071076.dbf archive log thread 2 sequence 7882 is already on disk as file /opt/oracle/base/OracleHomes/db10g/dbs/arch2_7882_825071076.dbf archive log filename=/opt/oracle/base/OracleHomes/db10g/dbs/arch2_7882_825071076.dbf thread=2 sequence=7882 archive log filename=/opt/oracle/base/OracleHomes/db10g/dbs/arch1_8958_825071076.dbf thread=1 sequence=8958 channel ORA_DISK_2: starting archive log restore to default destination channel ORA_DISK_1: starting archive log restore to default destination channel ORA_DISK_2: restoring archive log archive log thread=2 sequence=7883 channel ORA_DISK_2: reading from backup piece /fshare/test1/backup_20151219_6356_1.arc channel ORA_DISK_1: restoring archive log archive log thread=2 sequence=7884 channel ORA_DISK_1: reading from backup piece /fshare/test1/backup_20151219_6359_1.arc channel ORA_DISK_1: restored backup piece 1 piece handle=/fshare/test1/backup_20151219_6359_1.arc tag=TAG20151219T094825 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_2: restored backup piece 1 piece handle=/fshare/test1/backup_20151219_6356_1.arc tag=TAG20151219T094825 channel ORA_DISK_2: restore complete, elapsed time: 00:00:16 archive log filename=/archlog/NACDB/archivelog/2015_12_25/o1_mf_2_7883_c7ss0dtd_.arc thread=2 sequence=7883 channel default: deleting archive log(s) archive log filename=/archlog/NACDB/archivelog/2015_12_25/o1_mf_2_7883_c7ss0dtd_.arc recid=16654 stamp=899390232 archive log filename=/archlog/NACDB/archivelog/2015_12_25/o1_mf_2_7884_c7ss0dyb_.arc thread=2 sequence=7884 channel default: deleting archive log(s) archive log filename=/archlog/NACDB/archivelog/2015_12_25/o1_mf_2_7884_c7ss0dyb_.arc recid=16653 stamp=899390221 media recovery complete, elapsed time: 00:06:09 Finished recover at 25-DEC-15
恢复完成后,通过resetlogs的方式打开数据库,由于源库是ASM文件系统,新恢复的数据库是ext4文件系统,并且源库的redo log有10组,每组两个成员,如果要打开数据库,需要rename一些日志文件,这样很麻烦,所有,采用重建控制文件的方法来直接更改redo log的路径。
SQL> alter database backup controlfile to trace; Database altered. SQL> CREATE CONTROLFILE REUSE DATABASE "NACDB" RESETLOGS NOARCHIVELOG 2 MAXLOGFILES 192 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 1024 5 MAXINSTANCES 32 6 MAXLOGHISTORY 584 7 LOGFILE 8 GROUP 1 ('/fshare/nacdb/redo01.log' 9 ) SIZE 50M, 10 GROUP 2 ('/fshare/nacdb/redo02.log' 11 ) SIZE 50M, 12 GROUP 3 ('/fshare/nacdb/redo03.log' 13 ) SIZE 50M, 14 GROUP 4 ('/fshare/nacdb/redo04.log' 15 ) SIZE 50M 16 -- STANDBY LOGFILE 17 DATAFILE 18 '/fshare/nacdb/system.260.825071011', 19 '/fshare/nacdb/undotbs1.265.825071011', 20 '/fshare/nacdb/sysaux.269.825071011', 21 '/fshare/nacdb/users.264.825071011', 22 '/fshare/nacdb/undotbs2.261.825071097', 23 '/fshare/nacdb/telnumber_bigfile.dbf', 24 '/fshare/nacdb/extel_bigfile.dbf', 25 '/fshare/nacdb/ext_bigfile.dbf', 26 '/fshare/nacdb/tel_ind.dbf', 27 '/fshare/nacdb/ext_ind.dbf', 28 '/fshare/nacdb/extel_ind.dbf', 29 '/fshare/nacdb/users.256.886287171', 30 '/fshare/nacdb/users.408.891252945' 31 CHARACTER SET ZHS16GBK 32 ; Control file created.
重建控制文件后,resetlog打开数据库时遇到ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread 2) as enabled错误。
SQL> alter database open resetlogs; alter database open resetlogs * ERROR at line 1: ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread 2) as enabled
如果不重建控制文件,直接rename redo log的方式,然后resetlogs方式打开数据库,基本不会遇到这个问题,即使遇到这个错误,一般只需要添加一组thread 2的redo log就可以解决,但是上文这种情况,通过添加thread 2 redo的方式基本解决不了。
SQL> alter database add logfile thread 2 group 5 '/fshare/nacdb/redo05.log' size 50M ; Database altered. SQL> alter database open resetlogs; alter database open resetlogs * ERROR at line 1: ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread 2) as enabled
添加thread 2 redo后仍然无法打开数据库,这时就需要通过设置隐含参赛_no_recovery_through_resetlogs来跳过thread 2 redo的校验,即可成功打开数据库。
SQL> alter system set "_no_recovery_through_resetlogs"=TRUE; System altered. SQL> alter database open resetlogs; Database altered.