adg的archive出現gap,使用增量恢復的方式進行恢復adg,RMAN-06094: datafile 1 must be restored
① 主庫丟失歸檔檔案,然後在不重建物理dg的情況下來恢復物理dg
一.4.2 實驗過程
一.4.2.1 主備庫環境
檢視主庫的資訊:
SQL>select protection_mode,protection_level,database_role,force_logging,open_mode,switchover_status from v$database;
PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE FOR OPEN_MODE SWITCHOVER_STATUS
----------- -------------------- -------------------- ---------------- --- -------------------- --------------------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PRIMARY YES READ WRITE TO STANDBY
SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination /u01/arch/prod Oldest online log sequence 153 Next log sequence to archive 0 Current log sequence 155
檢視備庫的資訊:
SQL>select protection_mode,protection_level,database_role,force_logging,open_mode,switchover_status from v$database;
PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE FOR OPEN_MODE SWITCHOVER_STATUS
---------- -------------------- -------------------- ---------------- --- -------------------- --------------------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PHYSICAL STANDBY YES READ ONLY WITH APPLY NOT ALLOWED
已用時間: 00: 00: 00.06
20:40:44 SQL>
SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination /u01/arch/phy1 Oldest online log sequence 153 Next log sequence to archive 0 Current log sequence 155
20:43:23 SQL>
一.4.2.2 模擬歸檔丟失
備庫操作,備庫取消歸檔應用,讓備庫處於只讀模式:
20:43:23 SQL> ALTER ATABASE recover managed standby DATABASE cancel;
資料庫已更改。
SQL>select protection_mode,protection_level,database_role,open_mode,switchover_status from v$database;
PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE FOR OPEN_MODE SWITCHOVER_STATUS
---------- -------------------- -------------------- ---------------- --- -------------------- --------------------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PHYSICAL STANDBY YES READ ONLY NOT ALLOWED
主庫配置歸檔2的狀態為defer,目的是為了不把歸檔自動傳遞到備庫,實際情況下往往是由於網路故障,備庫掛掉等等情況導致,我們多次切換主庫日誌:
20:50:48 SQL> ALTER system SET log_archive_dest_state_2 = 'defer';
SQL> alter system switch logfile;
、、、、、、、、、、
SQL> select count(*) from test.test;
COUNT(*) ---------- 658944
SQL> SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination /u01/arch/prod Oldest online log sequence 170 Next log sequence to archive 172 Current log sequence 172 SQL> col name for a100 set linesize 9999 pagesize 9999 SELECT dest_id,THREAD#,NAME,sequence#,archived,applied,a.NEXT_CHANGE# FROM v$archived_log a WHERE a.sequence# >= 40 AND resetlogs_change# =(SELECT d.RESETLOGS_CHANGE# FROM v$database d) ORDER BY a.THREAD#,a.sequence#,a.dest_id;SQL> SQL> 2 3 4
DEST_ID THREAD# NAME SEQUENCE# ARC APPLIED NEXT_CHANGE# ---------- ---------- ---------------------------------------------------------------------------------------------------- ---------- --- --------- ------------ 2 1 ogg1 156 YES NO 1024803 1 1 /u01/arch/prod/1_157_981738248.arc 157 YES NO 1024808 1 1 /u01/arch/prod/1_158_981738248.arc 158 YES NO 1024814 1 1 /u01/arch/prod/1_159_981738248.arc 159 YES NO 1024817 1 1 /u01/arch/prod/1_160_981738248.arc 160 YES NO 1024820 1 1 /u01/arch/prod/1_161_981738248.arc 161 YES NO 1024825 1 1 /u01/arch/prod/1_162_981738248.arc 162 YES NO 1025156 1 1 /u01/arch/prod/1_163_981738248.arc 163 YES NO 1025163 1 1 /u01/arch/prod/1_164_981738248.arc 164 YES NO 1025171 1 1 /u01/arch/prod/1_165_981738248.arc 165 YES NO 1025174 1 1 /u01/arch/prod/1_166_981738248.arc 166 YES NO 1025177 1 1 /u01/arch/prod/1_167_981738248.arc 167 YES NO 1025182 1 1 /u01/arch/prod/1_168_981738248.arc 168 YES NO 1025185 1 1 /u01/arch/prod/1_169_981738248.arc 169 YES NO 1025398 1 1 /u01/arch/prod/1_170_981738248.arc 170 YES NO 1025405 1 1 /u01/arch/prod/1_171_981738248.arc 171 YES NO 1025412
159 rows selected.
SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination /u01/arch/phy1 Oldest online log sequence 154 Next log sequence to archive 0 Current log sequence 156 SQL> col name for a100 set linesize 9999 pagesize 9999 SELECT dest_id,THREAD#,NAME,sequence#,archived,applied,a.NEXT_CHANGE# FROM v$archived_log a WHERE a.sequence# >= 40 AND resetlogs_change# =(SELECT d.RESETLOGS_CHANGE# FROM v$database d) ORDER BY a.THREAD#,aSQL> SQL> 2 3 4 .sequence#,a.dest_id;
DEST_ID THREAD# NAME SEQUENCE# ARC APPLIED NEXT_CHANGE# ---------- ---------- ---------------------------------------------------------------------------------------------------- ---------- --- --------- ------------ 1 1 /u01/arch/phy1/1_152_981738248.arc 152 YES YES 1015367 1 1 /u01/arch/phy1/1_153_981738248.arc 153 YES YES 1015455 1 1 /u01/arch/phy1/1_154_981738248.arc 154 YES YES 1016001 1 1 /u01/arch/phy1/1_155_981738248.arc 155 YES NO 1024646 1 1 /u01/arch/phy1/1_156_981738248.arc 156 YES NO 1024803
40 rows selected.
可以看到,備庫已經斷檔了,157到171都沒有接收,接下來我們刪除主庫的歸檔日誌,我們只刪除54、55這2 個歸檔日誌:
[[email protected] prod]$ rm -rf 1_162_981738248.arc [[email protected] prod]$ rm -rf 1_163_981738248.arc [[email protected] prod]$ rm -rf 1_164_981738248.arc [[email protected] prod]$ rm -rf 1_165_981738248.arc [[email protected] prod]$ rm -rf 1_166_981738248.arc [[email protected] prod]$ rm -rf 1_167_981738248.arc [[email protected] prod]$ rm -rf 1_168_981738248.arc [[email protected] prod]$ rm -rf 1_169_981738248.arc
主庫開啟備庫的歸檔:
SQL> ALTER system SET log_archive_dest_state_2 = 'enable';
備庫開啟日誌恢復模式:
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> select thread#,low_sequence#,high_sequence# from v$archive_gap;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE# ---------- ------------- -------------- 1 162 169
可以看到備庫已經產生gap 了。
一.4.2.3 主庫基於SCN備份
162-169號日誌不見了,這個時候我們以162號的歸檔日誌的next_change#即161號的first_change#為scn號來對主庫基於scn的rman 增量備份。
SQL> SELECT (SELECT MIN(d.CHECKPOINT_CHANGE#) FROM v$datafile d) datafile_scn, (SELECT MIN(d.CHECKPOINT_CHANGE#) FROM v$datafile_header d WHERE rownum = 1) datafile_header_scn, (SELECT current_scn FROM v$database) current_scn, (SELECT b.NEXT_CHANGE# FROM v$archived_log b WHERE b.SEQUENCE# = 161 AND resetlogs_change# = (SELECT d.RESETLOGS_CHANGE# FROM v$database d) AND rownum = 1) NEXT_CHANGE# FROM dual; 2 3 4 5 6
DATAFILE_SCN DATAFILE_HEADER_SCN CURRENT_SCN NEXT_CHANGE# ------------ ------------------- ----------- ------------ 1024825 1024825 1024824
這幾個值基本上差不多,我們可以以 2241214 或者2241213為基準來備份,若是資料檔案和檔案頭的scn 不一致我們應該取這幾個值中最小的一個。
在主庫上進行增量備份:
RMAN> run { allocate channel d1 type disk; allocate channel d2 type disk; backup as compressed backupset incremental from SCN 1024824 database format '/u01/app/oracle/backup/standby_%d_%T_%U.bak' ; release channel d1; release channel d2; }
using target database control file instead of recovery catalog allocated channel: d1 channel d1: SID=139 device type=DISK
allocated channel: d2 channel d2: SID=30 device type=DISK
Starting backup at 19-SEP-18 channel d1: starting compressed full datafile backup set channel d1: specifying datafile(s) in backup set input datafile file number=00003 name=/u01/app/oracle/oradata/ogg2/undotbs01.dbf channel d1: starting piece 1 at 19-SEP-18 channel d2: starting compressed full datafile backup set channel d2: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle/oradata/ogg2/system01.dbf input datafile file number=00007 name=/u01/app/oracle/oradata/ogg2/test03.dbf input datafile file number=00009 name=/u01/app/oracle/oradata/ogg2/test05.dbf input datafile file number=00010 name=/u01/app/oracle/oradata/ogg2/test031.dbf input datafile file number=00011 name=/u01/app/oracle/oradata/ogg2/test032.dbf channel d2: starting piece 1 at 19-SEP-18 channel d2: finished piece 1 at 19-SEP-18 piece handle=/u01/app/oracle/backup/standby_OGG2_20180919_1ctdg6a9_1_1.bak tag=FOR STANDBY comment=NONE channel d2: backup set complete, elapsed time: 00:01:26 channel d2: starting compressed full datafile backup set channel d2: specifying datafile(s) in backup set input datafile file number=00002 name=/u01/app/oracle/oradata/ogg2/sysaux01.dbf input datafile file number=00004 name=/u01/app/oracle/oradata/ogg2/users01.dbf input datafile file number=00005 name=/u01/app/oracle/oradata/ogg2/test01.dbf input datafile file number=00006 name=/u01/app/oracle/oradata/ogg2/test02.dbf input datafile file number=00008 name=/u01/app/oracle/oradata/ogg2/test04.dbf channel d2: starting piece 1 at 19-SEP-18 channel d1: finished piece 1 at 19-SEP-18 piece handle=/u01/app/oracle/backup/standby_OGG2_20180919_1btdg6a9_1_1.bak tag=FOR STANDBY comment=NONE channel d1: backup set complete, elapsed time: 00:01:34 channel d1: starting compressed full datafile backup set channel d1: specifying datafile(s) in backup set including standby control file in backup set channel d1: starting piece 1 at 19-SEP-18 channel d1: finished piece 1 at 19-SEP-18 piece handle=/u01/app/oracle/backup/standby_OGG2_20180919_1etdg6d7_1_1.bak tag=FOR STANDBY comment=NONE channel d1: backup set complete, elapsed time: 00:00:02 channel d2: finished piece 1 at 19-SEP-18 piece handle=/u01/app/oracle/backup/standby_OGG2_20180919_1dtdg6cv_1_1.bak tag=FOR STANDBY comment=NONE channel d2: backup set complete, elapsed time: 00:00:30 Finished backup at 19-SEP-18
released channel: d1
released channel: d2
進行控制檔案的備份:
RMAN> run { allocate channel c1 type disk; backup current controlfile for standby format '/u01/app/oracle/backup/db_%T_%d_%t_%s_%p.ctl'; }2> 3> 4> 5>
released channel: ORA_DISK_1 allocated channel: c1 channel c1: SID=139 device type=DISK
Starting backup at 19-SEP-18 channel c1: starting full datafile backup set channel c1: specifying datafile(s) in backup set including standby control file in backup set channel c1: starting piece 1 at 19-SEP-18 channel c1: finished piece 1 at 19-SEP-18 piece handle=/u01/app/oracle/backup/db_20180919_OGG2_987241142_47_1.ctl tag=TAG20180919T093902 comment=NONE channel c1: backup set complete, elapsed time: 00:00:01 Finished backup at 19-SEP-18 released channel: c1
將備份端資料啟動該nomount進行恢復控制檔案,然後啟動到mount,在恢復資料檔案
[[email protected] backup]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Sep 19 09:55:15 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: OGG2 (not mounted)
RMAN> restore standby controlfile to '/u01/app/oracle/flash_recovery_area/ogg1/control02.ctl' from '/u01/app/oracle/backup/db_20180919_OGG2_987241142_47_1.ctl';
Starting restore at 19-SEP-18 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=125 device type=DISK
channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 19-SEP-18
RMAN> alter database mount;
database mounted released channel: ORA_DISK_1
二、 恢復備庫,注意這個資料檔案是主庫中的資料檔名稱,要先在資料庫中將其修改成備庫的資料庫名稱 RMAN> report schema 2> ; RMAN-06139: WARNING: control file is not current for REPORT SCHEMA Report of database schema for database with db_unique_name STANDBY
RMAN> report schema;
Starting implicit crosscheck backup at 19-SEP-18 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=139 device type=DISK Finished implicit crosscheck backup at 19-SEP-18
Starting implicit crosscheck copy at 19-SEP-18 using channel ORA_DISK_1 Crosschecked 2 objects Finished implicit crosscheck copy at 19-SEP-18
searching for all files in the recovery area cataloging files... no files cataloged
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA Report of database schema for database with db_unique_name OGG1
List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 0 SYSTEM *** /u01/app/oracle/oradata/ogg1/system01.dbf 2 0 SYSAUX *** /u01/app/oracle/oradata/ogg1/sysaux01.dbf 3 0 UNDOTBS1 *** /u01/app/oracle/oradata/ogg1/undotbs01.dbf 4 0 USERS *** /u01/app/oracle/oradata/ogg1/users01.dbf 5 10 TEST *** /u01/app/oracle/oradata/ogg1/test01.dbf 6 0 TEST *** /u01/app/oracle/oradata/ogg1/test02.dbf 7 0 TEST *** /u01/app/oracle/oradata/ogg1/test03.dbf 8 10 TEST2 *** /u01/app/oracle/oradata/ogg1/test04.dbf 9 10 TEST2 *** /u01/app/oracle/oradata/ogg1/test05.dbf 10 0 TEST *** /u01/app/oracle/oradata/ogg1/test031.dbf 11 10 TEST *** /u01/app/oracle/oradata/ogg1/test032.dbf
List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name ---- -------- -------------------- ----------- -------------------- 1 20 TEMP 32767 /u01/app/oracle/oradata/ogg1/temp01.dbf
但是備份端的資料檔名稱和主庫的資料檔名稱和路徑不一致: [[email protected] ogg1]$ ll total 2549432 -rw-r----- 1 oracle oinstall 10043392 Sep 19 10:01 control01.ctl -rw-r----- 1 oracle oinstall 52429312 Sep 14 13:44 redo01.log -rw-r----- 1 oracle oinstall 52429312 Sep 14 13:44 redo02.log -rw-r----- 1 oracle oinstall 52429312 Sep 14 13:44 redo03.log -rw-r----- 1 oracle oinstall 52429312 Sep 19 10:01 standby01.log -rw-r----- 1 oracle oinstall 52429312 Sep 19 09:29 standby02.log -rw-r----- 1 oracle oinstall 52429312 Sep 14 13:25 standby03.log -rw-r----- 1 oracle oinstall 52429312 Sep 14 13:25 standby04.log -rw-r----- 1 oracle oinstall 629153792 Sep 19 09:29 sysaux.dbf -rw-r----- 1 oracle oinstall 734011392 Sep 19 09:29 system.dbf -rw-r----- 1 oracle oinstall 10493952 Sep 19 09:29 test01.dbf -rw-r----- 1 oracle oinstall 10493952 Sep 19 09:29 test032.dbf -rw-r----- 1 oracle oinstall 10493952 Sep 19 09:29 test04.dbf -rw-r----- 1 oracle oinstall 10493952 Sep 19 09:29 test05.dbf -rw-r----- 1 oracle oinstall 823140352 Sep 19 09:29 undotbs1.dbf -rw-r----- 1 oracle oinstall 5251072 Sep 19 09:29 users.dbf [[email protected] ogg1]$ ls control01.ctl redo02.log standby01.log standby03.log sysaux.dbf test01.dbf test04.dbf undotbs1.dbf redo01.log redo03.log standby02.log standby04.log system.dbf test032.dbf test05.dbf users.dbf [[email protected] ogg2]$ ls temp01.dbf test02.dbf test031.dbf test03.dbf 所以要先進行:
#####如果想避免出現這種情況的話,在進行異地備份恢復的時候,在進行資料檔案命名的時候嚴格按照主庫的資料檔名稱來定義###### [[email protected] ogg2]$ mv * ../ogg1 [[email protected] ogg2]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Sep 19 11:09:48 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database rename file '/u01/app/oracle/oradata/ogg2/test02.dbf' to '/u01/app/oracle/oradata/ogg1/test02.dbf';
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/ogg2/test03.dbf' to '/u01/app/oracle/oradata/ogg1/test03.dbf';
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/ogg2/temp01.dbf' to '/u01/app/oracle/oradata/ogg1/temp01.dbf';
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/ogg2/test031.dbf' to '/u01/app/oracle/oradata/ogg1/test031.dbf';
Database altered.
SQL> alter system set standby_file_management=auto scope=both sid='*';
System altered.
SQL> alter system set standby_file_management=manual scope=both;
System altered.
SQL> alter database rename file '/u01/app/oracle/oradata/ogg1/system01.dbf' to '/u01/app/oracle/oradata/ogg1/system.dbf';
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/ogg1/sysaux01.dbf' to '/u01/app/oracle/oradata/ogg1/sysaux.dbf';
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/ogg1/users01.dbf' to '/u01/app/oracle/oradata/ogg1/users.dbf';
Database altered.
SQL> alter database rename file '/u01/app/oracle/oradata/ogg1/undotbs01.dbf' to '/u01/app/oracle/oradata/ogg1/undotbs1.dbf';
Database altered.
SQL> alter system set standby_file_management=auto scope=both sid='*';
System altered.
RMAN> report schema;
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA Report of database schema for database with db_unique_name STANDBY
List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 700 SYSTEM *** /u01/app/oracle/oradata/ogg1/system.dbf 2 600 SYSAUX *** /u01/app/oracle/oradata/ogg1/sysaux.dbf 3 785 UNDOTBS1 *** /u01/app/oracle/oradata/ogg1/undotbs1.dbf 4 5 USERS *** /u01/app/oracle/oradata/ogg1/users.dbf 5 10 TEST *** /u01/app/oracle/oradata/ogg1/test01.dbf 6 10 TEST *** /u01/app/oracle/oradata/ogg1/test02.dbf 7 10 TEST *** /u01/app/oracle/oradata/ogg1/test03.dbf 8 10 TEST2 *** /u01/app/oracle/oradata/ogg1/test04.dbf 9 10 TEST2 *** /u01/app/oracle/oradata/ogg1/test05.dbf 10 10 TEST *** /u01/app/oracle/oradata/ogg1/test031.dbf 11 10 TEST *** /u01/app/oracle/oradata/ogg1/test032.dbf
List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name ---- -------- -------------------- ----------- -------------------- 1 20 TEMP 32767 /u01/app/oracle/oradata/ogg1/temp01.dbf
RMAN> recover database noredo;
Starting recover at 19-SEP-18 using channel ORA_DISK_1 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/ogg1/system.dbf destination for restore of datafile 00002: /u01/app/oracle/oradata/ogg1/sysaux.dbf destination for restore of datafile 00004: /u01/app/oracle/oradata/ogg1/users.dbf destination for restore of datafile 00006: /u01/app/oracle/oradata/ogg1/test02.dbf destination for restore of datafile 00008: /u01/app/oracle/oradata/ogg1/test04.dbf destination for restore of datafile 00010: /u01/app/oracle/oradata/ogg1/test031.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/standby_OGG2_20180919_1gtdg6n4_1_1.bak channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/standby_OGG2_20180919_1gtdg6n4_1_1.bak tag=TAG20180919T093948 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:08 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 00003: /u01/app/oracle/oradata/ogg1/undotbs1.dbf destination for restore of datafile 00005: /u01/app/oracle/oradata/ogg1/test01.dbf destination for restore of datafile 00007: /u01/app/oracle/oradata/ogg1/test03.dbf destination for restore of datafile 00009: /u01/app/oracle/oradata/ogg1/test05.dbf destination for restore of datafile 00011: /u01/app/oracle/oradata/ogg1/test032.dbf channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/standby_OGG2_20180919_1htdg6n4_1_1.bak channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/standby_OGG2_20180919_1htdg6n4_1_1.bak tag=TAG20180919T093948 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 19-SEP-18
RMAN> exit
Recovery Manager complete. [[email protected] dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Sep 19 11:21:20 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> col name for a100 set linesize 9999 pagesize 9999 SELECT dest_id,THREAD#,NAME,sequence#,archived,applied,a.NEXT_CHANGE# FROM v$archived_log a WHERE a.sequence# >= 40 AND resetlogs_change# =(SELECT d.RESETLOGS_CHANGE# FROM v$database d) ORDER BY a.THREAD#,aSQL> SQL> .sequence#,a.dest_id; 2 3 4 DEST_ID THREAD# NAME SEQUENCE# ARC APPLIED NEXT_CHANGE# ---------- ---------- ---------------------------------------------------------------------------------------------------- ---------- --- --------- ------------ 2 1 /u01/arch/phy1/1_173_981738248.arc 173 YES NO 1027491 2 1 /u01/arch/phy1/1_174_981738248.arc 174 YES NO 1027693 1 1 /u01/arch/phy1/1_175_981738248.arc 175 YES NO 1027993 1 1 /u01/arch/phy1/1_176_981738248.arc 176 YES NO 1031524 1 1 /u01/arch/phy1/1_177_981738248.arc 177 YES NO 1032805 1 1 /u01/arch/phy1/1_178_981738248.arc 178 YES NO 1033214
6 rows selected.
SQL> alter database recover managed standby database using current logfile disconnect from session;
Database altered.
SQL> col name for a100 set linesize 9999 pagesize 9999 SELECT dest_id,THREAD#,NAME,sequence#,archived,applied,a.NEXT_CHANGE# FROM v$archived_log a WHERE a.sequence# >= 40 AND resetlogs_change# =(SELECT d.RESETLOGS_CHANGE# FROM v$database d) ORDER BY a.THREAD#,aSQL> SQL> 2 3 4 .sequence#,a.dest_id;
DEST_ID THREAD# NAME SEQUENCE# ARC APPLIED NEXT_CHANGE# ---------- ---------- ---------------------------------------------------------------------------------------------------- ---------- --- --------- ------------ 2 1 /u01/arch/phy1/1_173_981738248.arc 173 YES YES 1027491 2 1 /u01/arch/phy1/1_174_981738248.arc 174 YES YES 1027693 1 1 /u01/arch/phy1/1_175_981738248.arc 175 YES YES 1027993 1 1 /u01/arch/phy1/1_176_981738248.arc 176 YES YES 1031524 1 1 /u01/arch/phy1/1_177_981738248.arc 177 YES YES 1032805 1 1 /u01/arch/phy1/1_178_981738248.arc 178 YES IN-MEMORY 1033214
6 rows selected.
SQL> select * from v$archive_gap;
no rows selected
四、 備庫read only 模式開啟
22:41:41 SQL> alter database recover managed standby database cancel;
資料庫已更改。
已用時間: 00: 00: 01.00
22:43:40 SQL> alter database open;
資料庫已更改
已用時間: 00: 00: 00.22
22:43:45 SQL> alter database recover managed standby database using current logfile disconnect from session;
資料庫已更改。