环境:
OS:Linux
DB:10.2.0.5 (主库RAC+ASM ,备库 单机+文件系统)
错误现象:
启动DG的时候运行
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
这个命令之后,DG没有正常同步,查看alert日志发现了以下错误:
Thu Dec 24 10:18:26 CST 2015
Physical Standby Database mounted.
Completed: ALTER DATABASE MOUNT
Thu Dec 24 10:18:46 CST 2015
ALTER DATABASE RECOVER managed standby database disconnect from session
Thu Dec 24 10:18:46 CST 2015
Attempt to start background Managed Standby Recovery process (sjdb)
MRP0 started with pid=26, OS id=30896
Thu Dec 24 10:18:46 CST 2015
MRP0: Background Managed Standby Recovery process started (sjdb)
Managed Standby Recovery not using Real Time Apply
MRP0: Background Media Recovery terminated with error 19909
Thu Dec 24 10:18:51 CST 2015
Errors in file /oracle/admin/sjdb/bdump/sjdb_mrp0_30896.trc:
ORA-19909: datafile 162 belongs to an orphan incarnation
ORA-01110: data file 162: '/oradata2/sjdb/undotbs2.2070.dbf'
Thu Dec 24 10:18:51 CST 2015
Errors in file /oracle/admin/sjdb/bdump/sjdb_mrp0_30896.trc:
ORA-19909: datafile 162 belongs to an orphan incarnation
ORA-01110: data file 162: '/oradata2/sjdb/undotbs2.2070.dbf'
Thu Dec 24 10:18:51 CST 2015
MRP0: Background Media Recovery process shutdown (sjdb)
查看主备两端的CHECKPOINT_CHANGE#号,发现备库的比较小,主库的较大。
SQL>select file#,to_char(CHECKPOINT_CHANGE#), CHECKPOINT_COUNT from v$datafile_header;
主库结果:
FILE# TO_CHAR(CHECKPOINT_CHANGE#) CHECKPOINT_COUNT
---------- ---------------------------------------- ----------------
162 14704777068330 62
备库结果:
FILE# TO_CHAR(CHECKPOINT_CHANGE#) CHECKPOINT_COUNT
---------- ---------------------------------------- ----------------
162 14704774937353 33
解决方法:
1、根据报错的数据文件号从主库拷贝一个正常的数据文件过来替换备库对应的数据文件
2、备库offline掉这个有问题的文件
SQL> alter database datafile 162 offline drop;
Database altered.
3、备库做全库恢复
SQL> recover standby database;
4、备库online数据文件,再重启动同步
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 2.8991E+10 bytes
Fixed Size 2148960 bytes
Variable Size 3808429472 bytes
Database Buffers 2.5115E+10 bytes
Redo Buffers 64958464 bytes
Database mounted.
SQL> alter database datafile 162 online;
Database altered.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Database altered.
PS:
利用rman 从10G 从ASM里面拷贝数据文件到本地
RMAN> copy datafile 162 to '/backup/undotbs2.2070.dbf';
Starting backup at 24-DEC-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00162 name=+DATA/nwdb/datafile/undotbs2.2070.898805417
output filename=/backup/undotbs2.2070.dbf tag=TAG20151224T130642 recid=3 stamp=899298407
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 24-DEC-15