本文主要是介绍ADG主库归档丢失,备库测试,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
ADG主库上归档丢失恢复备库测试模拟了下在主库上丢失归档导致备库出现gap,无需重建恢复备库的情况
1制造gap
主库
ALTER system SET log_archive_dest_state_2 = 'defer';
一些dml操作
alter system switch logfile;备库此时的mrp是等待log状态
SQL> select process,client_process,sequence#,status from v$managed_standby;PROCESS CLIENT_PROCESS SEQUENCE# STATUSARCH ARCH 0 CONNECTED
ARCH ARCH 0 CONNECTED
ARCH ARCH 0 CONNECTED
ARCH ARCH 22 CLOSING
RFS UNKNOWN 0 IDLE
RFS ARCH 0 IDLE
MRP0 N/A 23 WAIT_FOR_LOGSQL> select * from v$archive_gap;no rows selected
现在的这种情况oracle不认为是gap,所以没记录主库上查看当前sequence
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /data/arch
Oldest online log sequence 25
Next log sequence to archive 27
Current log sequence 27从库查看应用的归档
SQL> select sequence#, applied from v$archived_log where applied='YES' order by sequence#;SEQUENCE# APPLIED10 YES
11 YES
12 YES
13 YES
14 YES
14 YES
15 YES
15 YES
16 YES
16 YES
17 YES
18 YES
19 YES
20 YES
21 YES
22 YES主库上删除24,25,26三个sequence归档
select sequence#,name from v$archived_log;
主库
ALTER system SET log_archive_dest_state_2 = 'enable';在备库上查看
select * from v$archive_gap;THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#1 24 26
1
发现已经丢失了24,25,26三个归档文件
SQL> select sequence#,applied from v$archived_log;SEQUENCE# APPLIED10 YES
11 YES
12 YES
13 YES
14 YES
15 YES
15 YES
14 YES
16 YES
16 YES
17 YES
17 NO
18 YES
18 NO
19 YES
20 YES
21 YES
22 YES
23 YES
27 NO
停止从库的同步
SELECT (SELECT MIN(d.CHECKPOINT_CHANGE#) FROM vdatafile d) datafile_scn,(SELECT MIN(d.CHECKPOINT_CHANGE#) FROM vdatafile d) datafile_scn,(SELECT MIN(d.CHECKPOINT_CHANGE#)FROM vdatafile_header dWHERE rownum = 1) datafile_header_scn,(SELECT current_scn FROM vdatabase) current_scn,(SELECT b.NEXT_CHANGE# FROM vdatabase) current_scn,(SELECT b.NEXT_CHANGE#FROM varchived_log bWHERE b.SEQUENCE# = 23AND resetlogs_change# =(SELECT d.RESETLOGS_CHANGE# FROM v$database d)AND rownum = 1) NEXT_CHANGE#FROM dual;
查找最小的scn
DATAFILE_SCN DATAFILE_HEADER_SCN CURRENT_SCN NEXT_CHANGE#1017228 1017228 1017227 1017228
1
在主库备份增量
RMAN> backup as compressed backupset incremental from SCN 1017227 database format '/home/oracle/standby_%d_%T_%U.bak' include current controlfile for standby filesperset=5 tag 'FOR STANDBY';
传递到备库,注册应用
重启备库到nomount
show paramete controlRMAN> restore standby controlfile from '/home/oracle/standby_DBADB_20170422_0js2b2hl_1_1.bak';RMAN> alter database mount;RMAN> catalog start with '/home/oracle/archivelog';searching for all files that match the pattern /home/oracle/archivelogList of Files Unknown to the DatabaseFile Name: /home/oracle/archivelog/standby_DBADB_20170422_0is2b2hk_1_1.bakDo you really want to catalog the above files (enter YES or NO)? yes
cataloging files…
cataloging doneList of Cataloged Files
File Name: /home/oracle/archivelog/standby_DBADB_20170422_0is2b2hk_1_1.bakRMAN> recover database noredo;alter database recover managed standby database using current logfile disconnect from session;
SQL> SELECT * FROM V$ARCHIVE_GAP;no rows selectedselect sequence#,applied from v$archived_log;
SEQUENCE# APPLIED28 YES
1
此时的备库是mount状态的,需要到open状态
alter database recover managed standby database cancel;
alter database open;
alter database recover managed standby database using current logfile disconnect from session;
————————————————
版权声明:本文为CSDN博主「aoerqileng」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/aoerqileng/article/details/70432602
这篇关于ADG主库归档丢失,备库测试的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!