DG 主库丢失归档
主要原因就是备库没有APP呢,主库就误把归档删除了。常见的这种情况都是主库RMAN做备份的时候把归档删除了。
丢失归档解决方法:用RMAN 增量备份恢复,还有恢复控制文件。
备库:
SQL> select sequence#,applied from v$archived_log;
SEQUENCE# APP
---------- ---
69 YES
70 YES
71 YES
72 YES
73 YES
74 YES
75 YES
76 YES
77 YES
78 YES
79 YES
SEQUENCE# APP
---------- ---
86 NO
87 NO
从这里我们可以看出2个问题:
1、 从80到85 sequence# 没有记录了,这里就是主库的归档丢失了,都没有传输到备库上。
2、 86,87 sequence# 传输过来了,证明归档过来了,但是没有应用(这里执行命令恢复:alter database recover managed standby database disconnect from session 执行后日志86,87也没有被应用。因为这里出现了GAP)。【GAP解释:missing archived redo log files (referred to as a gap)
官档链接:http://docs.oracle.com/cd/E11882_01/server.112/e25608/concepts.htm#SBYDB00010】
解决方法:
一、备库
查看当前的SCN号:
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
528205
二、主库
进行RMAN增量备库:
Rman>backup as compressed backupset incremental from SCN528205 database format '/u01/standby_%d_%T_%U.bak'include current controlfile for standby filesperset=5tag 'FOR STANDBY';
(一条命令增量备份,同时也备份了控制文件。)
三、备库
进行恢复数据,恢复控制文件:
1、把增量备份SCP到备库上,并且用 CATALOG START WITH ‘/u01/’; 注册。
2、然后进行恢复。
Alter database recover managed standby database disconnect from session;
Alter database recover managed standby database cancel;
RMAN> run {
allocate channel dsk0 type disk;
allocate channel dsk1 type disk;
allocate channel dsk2 type disk;
restore standby controlfile to '/u01/control01.ctl';
recover database noredo; }
如果报下面的错误。(只截取了部分错误),我们可以重启数据库解决。
restore not done; all files readonly, offline, or already restored
Finished restore at 01-APR-12
Starting recover at 01-APR-12
released channel: dsk0
released channel: dsk1
released channel: dsk2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/01/2012 23:14:12
ORA-01219: database not open: queries allowed on fixed tables/views only
这里我们关闭数据库
Shut abort
Alter database recover managed standby database canel;
然后 shut immediate 把控制文件覆盖原控制文件。
然后 startup mount
Alter database recover managed standby database disconnect from session;
四、主库
切换即可,然后查看备库的归档应用状态。
Select sequence#,applied from v$archived_log;