When the physical standby generation GAP is simulated, the gap in the dataguardOracledatabase database may be generated because the archive file is too large or the network is unstable, and some archives cannot be uploaded to the standby. General Solution:-Add the compression Parameter
log_archive_dest_2='SERVICE=orcl_standby ASYNC COMPRESSION=ENABLE' -MAX_CONNECTIONS log_archive_dest_2='SERVICE=orcl_standby ASYNC MAX_CONNECTIONS=3'
The following describes how to handle the gap problem. 1. Stop the listener of the standby database.
[oracle@rhel132~]$ lsnrctl stop
2. the master database needs to be restarted. (If the listener is disabled in the slave database, the communication between the master database and the slave database is still not broken. It is a persistent connection ), then perform the following operations to switch logfile:
SQL>shutdown immediate;Databaseclosed.Databasedismounted.ORACLE instanceshut down.SQL> startupORACLE instancestarted.Total SystemGlobal Area 281018368 bytesFixed Size 1218944 bytesVariableSize 100664960 bytesDatabaseBuffers 171966464 bytesRedoBuffers 7168000 bytesDatabasemounted.Databaseopened.SQL> altersystem switch logfile;System altered.SQL> altersystem switch logfile;System altered.SQL> altersystem switch logfile;System altered.
3. view the archive information in the master database:
SQL>select sequence#,standby_dest,archived,applied from v$archived_log;SEQUENCE# STAARC APP---------- ------ --- 103 NO YES NO 104 YES YES NO 104 NO YES NO 105 YES YES YES 105 NO YES NO 106 YES YES YES 106 NO YES NO 107 NO YES NO 108 NO YES NO 109 NO YES NO 110 NO YES NO187rows selected.
You can also query in the slave database:
SQL>select sequence#,standby_dest,archived,applied from v$archived_log;SEQUENCE# STAARC APP---------- ------ --- 94 NO YES YES 95 NO YES YES 96 NO YES YES 97 NO YES YES 98 NO YES YES 99 NO YES YES 100 NO YES YES 101 NO YES YES 102 NO YES YES 103 NO YES YES 104 NO YES YES SEQUENCE# STA ARC APP---------- ------ --- 105 NO YES YES 106 NO YES YES112rows selected.
This is probably because 107 ~ Archive 110. The log files of the slave database are also waiting for archiving at 107: tue Aug 6 11:08:04 2013 Media RecoveryLog/u01/app/oracle/oradata/orcl/archivelog/paipai_791095797.dbf Media Recovery Waiting for thread 1 sequence 107 4. how can we simulate the gap? Because the simulated log files are too large and the network is unstable, we only need to change the names of the logs in the master database so that they cannot be synchronized to the slave database. In the master database:
[oracle@rhel131~]$ cd /u01/app/oracle/oradata/orcl/archivelog/[oracle@rhel131archivelog]$ mv 1_107_793805797.dbf 1_107_793805797.dbf.bk[oracle@rhel131archivelog]$ mv 1_108_793805797.dbf 1_108_793805797.dbf.bk[oracle@rhel131archivelog]$ mv 1_109_793805797.dbf 1_109_793805797.dbf.bk[oracle@rhel131archivelog]$ mv 1_110_793805797.dbf 1_110_793805797.dbf.bk
5. In this case, you can enable the standby Database Listener:
[oracle@rhel132~]$ lsnrctl start
6. Perform switchlogfile several times in the master database:
SQL> altersystem switch logfile;System altered.SQL> alter system switch logfile;System altered.
After a while, the slave database logs are as follows, indicating that the new arch synchronization is coming, but the log of 107-110 is missing. Tue Aug 6 11:24:28 2013 Redo ShippingClient Connected as PUBLIC -- ConnectedUser is Valid RFS [5]: Assigned to RFS process 4084 RFS [5]: identified database type as 'physical standby' RFS [5]: Archived Log: '/u01/app/oracle/oradata/orcl/archivelog/20171120.791095797.dbf 'rfs [5]: Archived Log: '/u01/app/oracle/oradata/orcl/archivelog/effect_791_5797.dbf' Tue Aug 6 11:24:30 2013 Fetching gap sequence in thread 1, gap sequence107-110 Tue Aug 6 11:25:00 2013 FAL [client]: failedto request gap sequence GAP-thread 1 sequence 107-110 DBID 1321586530 branch 793805797 FAL [client]: All defined FAL servers have beenattempted. you can also obtain information by querying the standby database view:
SQL> select* from v$archive_gap; THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#----------------------- -------------- 1 107 110
7. Start recovery now. copy the logs of the master database and register them with the slave database:
[oracle@rhel131archivelog]$ scp 1_107_793805797.dbf.bk 172.17.61.132:/tmp oracle@172.17.61.132's password:1_107_793805797.dbf.bk 100% 1024 1.0KB/s 00:00[oracle@rhel131archivelog]$ scp 1_108_793805797.dbf.bk 172.17.61.132:/tmporacle@172.17.61.132'spassword:1_108_793805797.dbf.bk 100% 75KB 74.5KB/s 00:00[oracle@rhel131archivelog]$ scp 1_109_793805797.dbf.bk 172.17.61.132:/tmporacle@172.17.61.132'spassword:1_109_793805797.dbf.bk 100% 4608 4.5KB/s 00:00[oracle@rhel131archivelog]$ scp 1_110_793805797.dbf.bk 172.17.61.132:/tmporacle@172.17.61.132'spassword:1_110_793805797.dbf.bk 100% 2560 2.5KB/s 00:00SQL> alterdatabase register logfile '/tmp/1_107_793805797.dbf.bk';Databasealtered.SQL> alterdatabase register logfile '/tmp/1_108_793805797.dbf.bk';Databasealtered.SQL> alterdatabase register logfile '/tmp/1_109_793805797.dbf.bk';Databasealtered.SQL> alterdatabase register logfile '/tmp/1_110_793805797.dbf.bk';Databasealtered.
8. The slave database information at this time:
alter databaseregister logfile '/tmp/1_107_793805797.dbf.bk'Tue Aug 6 11:43:28 2013There are 1logfiles specified.ALTER DATABASEREGISTER [PHYSICAL] LOGFILECompleted:alter database register logfile '/tmp/1_107_793805797.dbf.bk'Tue Aug 6 11:43:30 2013Media RecoveryLog /tmp/1_107_793805797.dbf.bkMedia RecoveryWaiting for thread 1 sequence 108Fetching gapsequence in thread 1, gap sequence 108-110Tue Aug 6 11:43:42 2013alter databaseregister logfile '/tmp/1_108_793805797.dbf.bk'Tue Aug 6 11:43:42 2013There are 1logfiles specified.ALTER DATABASEREGISTER [PHYSICAL] LOGFILECompleted:alter database register logfile '/tmp/1_108_793805797.dbf.bk'Tue Aug 6 11:43:49 2013alter databaseregister logfile '/tmp/1_109_793805797.dbf.bk'There are 1logfiles specified.ALTER DATABASEREGISTER [PHYSICAL] LOGFILECompleted:alter database register logfile '/tmp/1_109_793805797.dbf.bk'Tue Aug 6 11:43:56 2013alter databaseregister logfile '/tmp/1_110_793805797.dbf.bk'Tue Aug 6 11:43:56 2013There are 1logfiles specified.ALTER DATABASEREGISTER [PHYSICAL] LOGFILECompleted:alter database register logfile '/tmp/1_110_793805797.dbf.bk'Tue Aug 6 11:44:00 2013Media RecoveryLog /tmp/1_108_793805797.dbf.bkMedia RecoveryLog /tmp/1_109_793805797.dbf.bkMedia RecoveryLog /tmp/1_110_793805797.dbf.bkMedia RecoveryLog /u01/app/oracle/oradata/orcl/archivelog/1_111_793805797.dbfMedia RecoveryLog /u01/app/oracle/oradata/orcl/archivelog/1_112_793805797.dbfMedia RecoveryLog /u01/app/oracle/oradata/orcl/archivelog/1_113_793805797.dbfMedia Recovery Waiting for thread 1 sequence 114(in transit)
All archived logs have been applied.