实验DG 跳归档恢复
2017-07-04 20:15
225 查看
当前备库正常状态
主库切换归档SQL> alter system switch logfile;备库应用71号归档日志,等待72号归档日志
2017-07-01T21:51:28.075316+08:00 Archived Log entry 5 added for T-1.S-71 ID 0x22fd0e8 LAD:1 2017-07-01T21:51:28.075490+08:00 RFS[5]: Selected log 5 for T-1.S-72 dbid 36700136 branch 947543403 2017-07-01T21:51:28.273330+08:00 Media Recovery Waiting for thread 1 sequence 72 (in transit) 2017-07-01T21:51:28.273507+08:00 Recovery of Online Redo Log: Thread 1 Group 5 Seq 72 Reading mem 0 Mem# 0: /u01/app/oracle/oradata/newcdb/stdbyredo02.log检查主库的最近的归档日志文件是71号
RMAN> crosscheck archivelog all; using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=120 device type=DISK validation succeeded for archived log archived log file name=/archive/1_70_947543403.dbf RECID=163 STAMP=948232255 validation succeeded for archived log archived log file name=/archive/1_71_947543403.dbf RECID=165 STAMP=948232288 Crosschecked 2 objects
模拟故障
关闭备库SQL> shutdown immediate主库生成测试数据
SQL> desc test; ERROR: ORA-04043: object test does not exist SQL> create table test as select * from dba_objects; Table created.主库切换归档
SQL> alter system switch logfile; System altered. SQL> alter system switch logfile; System altered.修改归档文件
[oracle@12cr2 archive]$ mv 1_72_947543403.dbf 1_72_947543403.dbf.bak启动备库
SQL> startup mountdgmgrl发现归档日志有断档
DGMGRL> SHOW CONFIGURATION; Configuration - dg_newcdb Protection Mode: MaxPerformance Members: newcdb - Primary database Error: ORA-16724: cannot resolve gap for one or more members newcdbdg - Physical standby database Warning: ORA-16809: multiple warnings detected for the member Fast-Start Failover: DISABLED Configuration Status: ERROR (status updated 2 seconds ago)备库alert日志发现有断档
2017-07-01T22:00:55.860626+08:00 FAL[client]: Failed to request gap sequence GAP - thread 1 sequence 72-72 DBID 36700136 branch 947543403 FAL[client]: All defined FAL servers have been attempted. ------------------------------------------------------------------------- Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization parameter is defined to a value that's sufficiently large enough to maintain adequate log switch information to resolve archivelog gaps.
跳断档恢复备机
备库SCN号SQL> col CURRENT_SCN format 9999999999999999 SQL> SELECT CURRENT_SCN FROM V$DATABASE; CURRENT_SCN ----------------- 2020795主库SCN号
SQL> col CURRENT_SCN format 9999999999999999 SQL> SELECT CURRENT_SCN FROM V$DATABASE; CURRENT_SCN ----------------- 2026985主库指定备库的SCN做增量备份并传输到备库
RMAN> BACKUP INCREMENTAL FROM SCN 1576857 DATABASE FORMAT '/home/oracle/sdataguru_%U' tag 'FOR_STANDBY'; [oracle@12cr2 ~]$ scp sdataguru_* 192.168.16.130:/home/oracle/sdataguru主库备份控制文件并传输到备库
SQL> alter database create standby controlfile as '/home/oracle/std_con.ctl'; [oracle@12cr2 ~]$ scp std_con.ctl 192.168.16.130:/home/oracle/关闭备库,进行恢复
SQL> shutdown immediate备库恢复控制文件
[oracle@oracle sdataguru]$ rman target / Recovery Manager: Release 12.2.0.1.0 - Production on Sat Jul 1 22:07:51 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database (not started) RMAN> startup nomount; Oracle instance started Total System Global Area 838860800 bytes Fixed Size 8798312 bytes Variable Size 322965400 bytes Database Buffers 503316480 bytes Redo Buffers 3780608 bytes RMAN> restore standby controlfile from '/home/oracle/std_con.ctl'; Starting restore at 01-JUL-17 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=36 device type=DISK channel ORA_DISK_1: copied control file copy output file name=/u01/app/oracle/oradata/newcdb/control01.ctl output file name=/u01/app/oracle/oradata/newcdb/control02.ctl Finished restore at 01-JUL-17启动备库到mount状态
RMAN> alter database mount;备库注册主库的RMAN备份文件
[oracle@oracle ~]$ cd sdataguru/ [oracle@oracle sdataguru]$ ll total 68176 -rw-r----- 1 oracle oinstall 33587200 Jul 1 22:06 sdataguru_5ls89ot8_1_1 -rw-r----- 1 oracle oinstall 6406144 Jul 1 22:06 sdataguru_5ms89otc_1_1 -rw-r----- 1 oracle oinstall 5144576 Jul 1 22:06 sdataguru_5ns89otf_1_1 -rw-r----- 1 oracle oinstall 5652480 Jul 1 22:06 sdataguru_5os89otg_1_1 -rw-r----- 1 oracle oinstall 19021824 Jul 1 22:06 sdataguru_5qs89oth_1_1 RMAN> catalog start with '/home/oracle/sdataguru'; searching for all files that match the pattern /home/oracle/sdataguru List of Files Unknown to the Database ===================================== File Name: /home/oracle/sdataguru/sdataguru_5qs89oth_1_1 File Name: /home/oracle/sdataguru/sdataguru_5ls89ot8_1_1 File Name: /home/oracle/sdataguru/sdataguru_5ns89otf_1_1 File Name: /home/oracle/sdataguru/sdataguru_5os89otg_1_1 File Name: /home/oracle/sdataguru/sdataguru_5ms89otc_1_1 Do you really want to catalog the above files (enter YES or NO)? yes cataloging files... cataloging done List of Cataloged Files ======================= File Name: /home/oracle/sdataguru/sdataguru_5qs89oth_1_1 File Name: /home/oracle/sdataguru/sdataguru_5ls89ot8_1_1 File Name: /home/oracle/sdataguru/sdataguru_5ns89otf_1_1 File Name: /home/oracle/sdataguru/sdataguru_5os89otg_1_1 File Name: /home/oracle/sdataguru/sdataguru_5ms89otc_1_1recover database noredo
RMAN> recover database noredo; Starting recover at 01-JUL-17 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=54 device type=DISK channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /u01/app/oracle/oradata/newcdb/system01.dbf destination for restore of datafile 00003: /u01/app/oracle/oradata/newcdb/sysaux01.dbf destination for restore of datafile 00004: /u01/app/oracle/oradata/newcdb/undotbs01.dbf destination for restore of datafile 00007: /u01/app/oracle/oradata/newcdb/users01.dbf channel ORA_DISK_1: reading from backup piece /home/oracle/sdataguru_5ls89ot8_1_1 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 07/01/2017 22:11:44 ORA-19870: error while restoring backup piece /home/oracle/sdataguru/sdataguru_5ls89ot8_1_1 ORA-19573: cannot obtain exclusive enqueue for datafile 1 ORA-45909: restore, recover or block media recovery may be in progress以上报错原因,由于DG broker会自动启动备机的日志同步,此时需要关闭日志同步
SQL> RECOVER MANAGED STANDBY DATABASE CANCEL; Media recovery complete.重新recover 数据库
RMAN> recover database noredo; Starting recover at 01-JUL-17 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=48 device type=DISK channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /u01/app/oracle/oradata/newcdb/system01.dbf destination for restore of datafile 00003: /u01/app/oracle/oradata/newcdb/sysaux01.dbf destination for restore of datafile 00004: /u01/app/oracle/oradata/newcdb/undotbs01.dbf destination for restore of datafile 00007: /u01/app/oracle/oradata/newcdb/users01.dbf channel ORA_DISK_1: reading from backup piece /home/oracle/sdataguru_5ls89ot8_1_1 channel ORA_DISK_1: errors found reading piece handle=/home/oracle/sdataguru_5ls89ot8_1_1 channel ORA_DISK_1: failover to piece handle=/home/oracle/sdataguru/sdataguru_5ls89ot8_1_1 tag=FOR_STANDBY channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00009: /u01/app/oracle/oradata/newcdb/dgpdb1/system01.dbf destination for restore of datafile 00010: /u01/app/oracle/oradata/newcdb/dgpdb1/sysaux01.dbf destination for restore of datafile 00011: /u01/app/oracle/oradata/newcdb/dgpdb1/undotbs01.dbf destination for restore of datafile 00012: /u01/app/oracle/oradata/newcdb/dgpdb1/users01.dbf channel ORA_DISK_1: reading from backup piece /home/oracle/sdataguru_5ms89otc_1_1 channel ORA_DISK_1: errors found reading piece handle=/home/oracle/sdataguru_5ms89otc_1_1 channel ORA_DISK_1: failover to piece handle=/home/oracle/sdataguru/sdataguru_5ms89otc_1_1 tag=FOR_STANDBY channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00013: /u01/app/oracle/oradata/newcdb/dgpdb2/system01.dbf destination for restore of datafile 00014: /u01/app/oracle/oradata/newcdb/dgpdb2/sysaux01.dbf destination for restore of datafile 00015: /u01/app/oracle/oradata/newcdb/dgpdb2/undotbs01.dbf destination for restore of datafile 00016: /u01/app/oracle/oradata/newcdb/dgpdb2/users01.dbf channel ORA_DISK_1: reading from backup piece /home/oracle/sdataguru_5ns89otf_1_1 channel ORA_DISK_1: errors found reading piece handle=/home/oracle/sdataguru_5ns89otf_1_1 channel ORA_DISK_1: failover to piece handle=/home/oracle/sdataguru/sdataguru_5ns89otf_1_1 tag=FOR_STANDBY channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00017: /u01/app/oracle/oradata/newcdb/dgpdb3/system01.dbf destination for restore of datafile 00018: /u01/app/oracle/oradata/newcdb/dgpdb3/sysaux01.dbf destination for restore of datafile 00019: /u01/app/oracle/oradata/newcdb/dgpdb3/undotbs01.dbf destination for restore of datafile 00020: /u01/app/oracle/oradata/newcdb/dgpdb3/users01.dbf channel ORA_DISK_1: reading from backup piece /home/oracle/sdataguru_5os89otg_1_1 channel ORA_DISK_1: errors found reading piece handle=/home/oracle/sdataguru_5os89otg_1_1 channel ORA_DISK_1: failover to piece handle=/home/oracle/sdataguru/sdataguru_5os89otg_1_1 tag=FOR_STANDBY channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished recover at 01-JUL-17DG broker enable备库
DGMGRL> enable database newcdbdg; Enabled. DGMGRL> SHOW CONFIGURATION; Configuration - dg_newcdb Protection Mode: MaxPerformance Members: newcdb - Primary database newcdbdg - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS (status updated 2 seconds ago) DGMGRL> show database newcdbdg; Database - newcdbdg Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 0 seconds ago) Apply Lag: 0 seconds (computed 0 seconds ago) Average Apply Rate: 18.00 KByte/s Real Time Query: OFF Instance(s): newcdb Database Status: SUCCESS
SQL> alter database open; DGMGRL> show database newcdbdg; Database - newcdbdg Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 1 second ago) Apply Lag: 0 seconds (computed 1 second ago) Average Apply Rate: 39.00 KByte/s Real Time Query: ON Instance(s): newcdb Database Status: SUCCESS SQL> select count(*) from test; COUNT(*) ---------- 72683
备库72号归档不存在,已使用增量恢复。
[oracle@oracle archive]$ ll
total 22680
-rw-r----- 1 oracle oinstall 144896 Jul 1 21:50 1_70_947543403.dbf
-rw-r----- 1 oracle oinstall 20480 Jul 1 21:51 1_71_947543403.dbf
-rw-r----- 1 oracle oinstall 5632 Jul 1 22:08 1_73_947543403.dbf
-rw-r----- 1 oracle oinstall 78848 Jul 1 22:08 1_74_947543403.dbf
-rw-r----- 1 oracle oinstall 80384 Jul 1 22:08 1_75_947543403.dbf
-rw-r----- 1 oracle oinstall 4111360 Jul 1 22:08 1_76_947543403.dbf
-rw-r----- 1 oracle oinstall 18172928 Jul 1 22:08 1_77_947543403.dbf
-rw-r----- 1 oracle oinstall 595968 Jul 1 22:13 1_78_947543403.dbf
相关文章推荐
- 利用增量备份恢复gap归档丢失DG
- DG有归档无备份时的数据文件恢复
- DG丢失归档,使用增量备份恢复一例
- 利用增量备份恢复因归档丢失造成的DG gap
- rman实验之归档模式有备份,正常关机丢失控制文件的恢复
- rman实验之归档模式无备份,正常关机丢失当前联机重做日志文件的恢复
- DG丢失归档,使用增量备份恢复一例 ,基于scn恢复备库
- oralce搭建DG恢复归档时遇到一个"大坑"
- 【DATAGUARD】物理dg在主库丢失归档文件的情况下的恢复(七)
- 【DATAGUARD】物理dg在主库丢失归档文件的情况下的恢复(七)
- 我的备份与恢复实验(归档模式下用户管理的不完全恢复,基于时间点的)
- 运用incremental backup恢复归档GAP的DG-上篇 推荐
- rman实验之归档模式有备份,正常关机丢失数据文件的恢复
- Oracle11gr2_ADG管理之跳归档恢复dg实战
- 运用incremental backup恢复归档GAP的DG-下篇
- rman实验之归档模式无备份,正常关机丢失数据文件的恢复
- (归档模式)丢失非关键文件恢复
- ORA-00376错误 利用归档日志恢复数据文件
- 用归档日志恢复丢失的数据文件
- Oracle 10g中使用RMAN进行备份恢复的几个实验手记