DG unresolvable gap gap sequence备库恢复
案例
环境:2节点RAC asm + 单实例DG备库 ,备库用的是文件系统来存放数据文件,未用ASM;RAC一节点上部署有ogg。
在主库上通过在线重定义对表做分区,创建分区表空间时备库上创建数据文件失败,
导致日志传到备库无法应用,备库停止日志应用。
rman备份清理归档的脚本无法及时清理归档导到主库、备库归档磁盘空间均出现满的现象,ogg进程不工作,进程正常,只是time since chkpt 持续升高。
清理了归档后,备库可以接收日志但不应用。查看DG switchover_status 为unresolvable gap 。下面进行备库的恢复。
备库中的alert日志信息如下:
Managed Standby Recovery starting Real Time ApplyTue Apr 07 08:39:57 2015Errors in file /u01/app/oracle/diag/rdbms/centerdg/center/trace/center_dbw0_4645.trc:ORA-01186: file 63 failed verification testsORA-01157: cannot identify/lock data file 63 - see DBWR trace fileORA-01111: name for data file 63 is unknown - rename to correct fileORA-01110: data file 63: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00063'File 63 not verified due to error ORA-01157Errors in file /u01/app/oracle/diag/rdbms/centerdg/center/trace/center_dbw0_4645.trc:ORA-01186: file 201 failed verification testsORA-01157: cannot identify/lock data file 201 - see DBWR trace fileORA-01110: data file 201: '+DATA'File 201 not verified due to error ORA-01157MRP0: Background Media Recovery terminated with error 1111Errors in file /u01/app/oracle/diag/rdbms/centerdg/center/trace/center_pr00_5770.trc:ORA-01111: name for data file 63 is unknown - rename to correct fileORA-01110: data file 63: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00063'ORA-01157: cannot identify/lock data file 63 - see DBWR trace fileORA-01111: name for data file 63 is unknown - rename to correct fileORA-01110: data file 63: '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00063'Managed Standby Recovery not using Real Time ApplySlave exiting with ORA-1111 exception
处理思路:
1.停ogg
2.置分区表空间cdtbs_par2-10 ,idxtbs_2-10 readonly [表空间来源于下面的查询create_change#>备库当前SCN号,其中备库的cdtbs_par1也没有,但未查出来].
3.拷贝分区表空间对应的数据文件。
4.增备,做恢复。
具体操作:
1.置表空间为read only:
--在此之前先查出备库scn号。
select current_scn from v$database;10329528031425
--主库上查询
select 'alter tablespace '||b.name||' read only;' from v$datafile a,v$tablespace b where a.CREATION_CHANGE#> =10329528031425and a.TS#=b.TS#;alter tablespace CDTBS_PAR2 read only;alter tablespace CDTBS_PAR3 read only;alter tablespace CDTBS_PAR4 read only;alter tablespace CDTBS_PAR5 read only;alter tablespace CDTBS_PAR6 read only;alter tablespace CDTBS_PAR7 read only;alter tablespace CDTBS_PAR8 read only;alter tablespace CDTBS_PAR9 read only;alter tablespace CDTBS_PAR10 read only;alter tablespace IDXTBS_2 read only;alter tablespace IDXTBS_3 read only;alter tablespace IDXTBS_4 read only;alter tablespace IDXTBS_5 read only;alter tablespace IDXTBS_6 read only;alter tablespace IDXTBS_7 read only;alter tablespace IDXTBS_8 read only;alter tablespace IDXTBS_9 read only;alter tablespace IDXTBS_10 read only;
--因为发现备库上是没有cdtbs_par1表空间对应的数据文件,处理方法如上,先read only后静态拷贝到备库。
alter tablespace CDTBS_PAR1 read only;
2.拷贝文件到备库上。
先从ASM上拷贝到本地文件系统上:
cp CDTBS_PAR1.345.875609233 /home/gridcp CDTBS_PAR2.346.875609279 /home/grid/archcp CDTBS_PAR3.347.875609293 /home/grid/archcp CDTBS_PAR4.348.875609307 /home/grid/archcp CDTBS_PAR5.349.875609319 /home/grid/archcp CDTBS_PAR6.350.875609333 /home/grid/archcp CDTBS_PAR7.351.875609345 /home/grid/archcp CDTBS_PAR8.352.875609359 /home/grid/archcp CDTBS_PAR9.353.875609371 /home/grid/archcp CDTBS_PAR10.354.875609385 /home/grid/archcp IDXTBS_10.363.875609811 /home/grid/archcp IDXTBS_2.355.875609535 /home/grid/archcp IDXTBS_3.356.875609679 /home/grid/archcp IDXTBS_4.357.875609687 /home/grid/archcp IDXTBS_5.358.875609693 /home/grid/archcp IDXTBS_6.359.875609699 /home/grid/archcp IDXTBS_7.360.875609707 /home/grid/archcp IDXTBS_8.361.875609713 /home/grid/archcp IDXTBS_9.362.875609719 /home/grid/arch
grid用户直接scp 拷贝,例句:
scp CDTBS_PAR10.354.875609385 oracle@host:/datadg/center/datafilescp CDTBS_PAR[3,4,5,6]* oracle@host:/datadg/center/datafile
--多个同时拷贝,批考例句:
scp IDXTBS_[2,3,4]* oracle@host:/datadg/center/datafilescp IDXTBS_[5,6,7,8,9]* oracle@host:/datadg/center/datafile
PS:拷贝后发现文件权限是对的,但是在备库上文件名全部转换成了小写,为了避免linux系统文件名大小写敏感,将文件名重命名为小写,但未验证大写的文件名是否有影响。
3.主库基于备库的SCN号做增备备份
--分配多通道加快速度,恢复时未用多通道耗时较长。
主库上做增备:
rman target /run{allocate channel c1 type disk;allocate channel c2 type disk;allocate channel c3 type disk;allocate channel c4 type disk;BACKUP INCREMENTAL FROM SCN 10329528031425 DATABASE FORMAT '/home/oracle/upstd_%U_%p' tag 'upstd';release channel c1;release channel c2;release channel c3;release channel c4;}backup current controlfile for standby format '/home/oracle/upstdctl_%U';
4.备库上操作,清理有问题的数据文件:
alter system set standby_file_management=manual;alter database create datafile '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00063' as '/datadg/center/datafile/cdtbs_par1.345.875609233'; alter database datafile '/datadg/center/datafile/cdtbs_par1.345.875609233' offline drop; --alter database datafile '/u01/app/oracle/product/11.2.0/db_1/dbs/UNNAMED00063' offline drop; 用此句应该等效上面2句,未验证。 --然后静态read only将对应的数据文件拷贝过来 alter system set standby_file_management=auto;
5.备库上恢复
rman target / catalog start with '/home/oracle/dgbak'; recover database noredo; shutdown immediate;STARTUP NOMOUNT;RESTORE STANDBY CONTROLFILE FROM '/home/oracle/dgbak/upstdctl_9uq3rv22_1_1';alter database mount;RMAN> alter database open;RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of alter db command at 04/08/2015 16:32:47ORA-10458: standby database requires recoveryORA-01194: file 1 needs more recovery to be consistentORA-01110: data file 1: '/datadg/center/datafile/system.260.797342827'
继续备库上操作:
SQL> set num 50SQL> select current_scn from v$database;此处先应用 日志 SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION; SQL> select file#,status,name from v$datafile; SQL>select * from v$dataguard_status; ARC4: Beginning to archive thread 1 sequence 171370 (10331448528074-10331448899608) SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel; SQL>alter database open read only; SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE using current logfile DISCONNECT FROM SESSION;
附加后续DG相关信息
备库应用日志及打开到read only状态时alert中的一些信息:
备库上一些操作alert日志中的提示信息,虽然显示的是报错,但其实可以不用管,只是一个信息提示。
mount状态 取消日志应用报错ORA 16037:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCELMRP0: Background Media Recovery cancelled with status 16037Errors in file /u01/app/oracle/diag/rdbms/centerdg/center/trace/center_pr00_6282.trc:ORA-16037: user requested cancel of managed recovery operationThu Apr 09 08:32:09 2015Recovery interrupted!Recovered data files to a consistent state at change 10331906716894Thu Apr 09 08:32:10 2015MRP0: Background Media Recovery process shutdown (center)Thu Apr 09 08:32:10 2015Managed Standby Recovery Canceled (center)Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCELThu Apr 09 08:32:38 2015
将备库打开提示临时表空间数据文件无法锁定,可忽略,临时表空间会自动处理:
Data Guard Broker initializing...Data Guard Broker initialization completeThu Apr 09 08:32:41 2015SMON: enabling cache recoveryDictionary check beginningThu Apr 09 08:32:46 2015RFS[6]: Selected log 26 for thread 2 sequence 189031 dbid -68775212 branch 797342936Thu Apr 09 08:32:53 2015Errors in file /u01/app/oracle/diag/rdbms/centerdg/center/trace/center_dbw0_4855.trc:ORA-01157: cannot identify/lock data file 201 - see DBWR trace fileORA-01110: data file 201: '+DATA/center/tempfile/temp.264.797342939'ORA-17503: ksfdopn:2 Failed to open file +DATA/center/tempfile/temp.264.797342939ORA-15001: diskgroup "DATA" does not exist or is not mountedORA-15077: could not locate ASM instance serving a required diskgroupORA-29701: unable to connect to Cluster Synchronization ServiceErrors in file /u01/app/oracle/diag/rdbms/centerdg/center/trace/center_dbw0_4855.trc:ORA-01186: file 201 failed verification testsORA-01157: cannot identify/lock data file 201 - see DBWR trace fileORA-01110: data file 201: '+DATA/center/tempfile/temp.264.797342939'File 201 not verified due to error ORA-01157Thu Apr 09 08:32:53 2015Dictionary check completeCannot re-create tempfile +DATA/center/tempfile/temp.264.797342939, the same name file existsErrors in file /u01/app/oracle/diag/rdbms/centerdg/center/trace/center_dbw0_4855.trc:ORA-01157: cannot identify/lock data file 201 - see DBWR trace fileORA-01110: data file 201: '+DATA/center/tempfile/temp.264.797342939'ORA-17503: ksfdopn:2 Failed to open file +DATA/center/tempfile/temp.264.797342939ORA-15001: diskgroup "DATA" does not exist or is not mountedORA-15077: could not locate ASM instance serving a required diskgroupORA-29701: unable to connect to Cluster Synchronization ServiceDatabase Characterset is ZHS16GBKNo Resource Manager plan activereplication_dependency_tracking turned off (no async multimaster replication found)Thu Apr 09 08:32:55 2015Archived Log entry 485 added for thread 2 sequence 189030 ID 0xfd3d5b54 dest 1:Physical standby database opened for read only access.Completed: alter database open read only
到此备库已恢复成功。
在此附上惜纷飞的基于Data Guard出现gap sequence修复的案例,只是其中无创建数据文件。
http://www.xifenfei.com/1176.html