Use RMAN Incremental backup to process the gap and rmandataguard caused by archive loss of Dataguard.

Source: Internet
Author: User

Use RMAN Incremental backup to process the gap and rmandataguard caused by archive loss of Dataguard.


Scenario:

The following error occurs when the standby database executes the log application:


Thu Mar 29 11:21:45 2018
FAL [client]: Failed to request gap sequence
GAP-thread 1 sequence 184-185
DBID 1484954774 branch960494131
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.

Query missing archive logs:

SQL> select * from v $ archive_gap;

THREAD # LOW_SEQUENCE # HIGH_SEQUENCE #
-------------------------------------
1 183 185


Check the archive in the master database and find that the archive has been lost.

SQL> archive log list;

Database log mode Archive Mode
Automatic archival Enabled
Archive destination/u01/archivelog
Oldest online log sequence 186
Next log sequence to archive 188
Current log sequence 188


[Oracle @ prim archivelog] $ pwd
/U01/archivelog
[Oracle @ prim archivelog] $ ls-ltr
Total 1964
-Rw-r ----- 1 oracle oinstall 74752 Mar 29 running 186_960494131.dbf
-Rw-r ----- 1 oracle oinstall 1930240 Mar 29 running 187_960494131.dbf


The following describes how to use RMAN to restore an instance based on SCN Incremental backup. For more information, see the document ID 836986.1.

 

1. Cancel the standby database log application

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel;

2. on the slave database, determine the SCN to start Incremental backup.

SQL> SELECT CURRENT_SCN FROM V $ DATABASE;

CURRENT_SCN
-----------
3505254

SQL> select min (checkpoint_change #) from v $ datafile_header
Where file # not in (select file # from v $ datafile where enabled = 'read only ');

MIN (CHECKPOINT_CHANGE #)
-----------------------

(If the result is blank, restart the slave database to the mount status)
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1002127360 bytes
Fixed Size 2259440 bytes
Variable Size 285214224 bytes
Database Buffers 708837376 bytes
Redo Buffers 5816320 bytes
Database mounted.
SQL> select min (checkpoint_change #) from v $ datafile_header
Where file # not in (select file # from v $ datafile where enabled = 'read only ');

MIN (CHECKPOINT_CHANGE #)
-----------------------
3505255

Select the minimum SCN in the above results as the starting point for Incremental Backup (350524 here ).

 

3. Perform SCN-Based Incremental backup on the master database

RMAN> backup incremental from scn 3505254 DATABASE format'/tmp/ForStandby _ % U' tag 'forstandby ';

 

4. Copy the backup file to the slave database.

Scp/tmp/ForStandby _ * 192.168.211.162:/tmp

 

5. register the copied backup to the control file of the slave database.

[Oracle @ stand ~] $ Rman target/

Recovery Manager: Release 11.2.0.4.0-Production on Thu Mar 29 11:37:52 2018

Copyright (c) 1982,201 1, Oracle and/or its affiliates. All rights reserved.

Connected to target database: ORCL (DBID = 1484954774, not open)

RMAN> catalog start with '/tmp/forstandby ';

Using target database control file instead of recovery catalog
Searching for all files that match the pattern/tmp/ForStandby

List of Files Unknown to the Database
============================================
File Name:/tmp/ForStandby_08sv0bdj_1_1
File Name:/tmp/ForStandby_07sv0bcg_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:/tmp/ForStandby_08sv0bdj_1_1
File Name:/tmp/ForStandby_07sv0bcg_1_1

 

6. Use Incremental backup to restore the slave Database

RMAN> recover database noredo;


Starting recover at 29-MAR-18
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: SID = 16 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/rzorcl/system01.dbf
Destination for restore of datafile 00002:/u01/app/oracle/oradata/rzorcl/sysaux01.dbf
Destination for restore of datafile 00003:/u01/app/oracle/oradata/rzorcl/undotbs01.dbf
Destination for restore of datafile 00004:/u01/app/oracle/oradata/rzorcl/users01.dbf
Destination for restore of datafile 00005:/u01/app/oracle/oradata/rzorcl/example01.dbf
Destination for restore of datafile 00006:/u01/app/oracle/oradata/rzorcl/odc_tps01.dbf
Destination for restore of datafile 00007:/u01/app/oracle/oradata/rzorcl/test01.dbf
Destination for restore of datafile 00008:/u01/app/oracle/oradata/rzorcl/big01.dbf
Destination for restore of datafile 00009:/u01/app/oracle/oradata/rzorcl/big02.dbf
Channel ORA_DISK_1: reading from backup piece/tmp/ForStandby_07sv0bcg_1_1
Channel ORA_DISK_1: piece handle =/tmp/ForStandby_07sv0bcg_1_1 tag = FORSTANDBY
Channel ORA_DISK_1: restored backup piece 1
Channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished recover at 29-MAR-18


7. Back up the control file for the slave database in the master database and scp it to the slave database.

RMAN> backup current controlfile for standby format'/tmp/ForStandbyCTRL. bck ';

Starting backup at 29-MAR-18
Using target database control file instead of recovery catalog
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: SID = 9 device type = DISK
Channel ORA_DISK_1: starting full datafile backup set
Channel ORA_DISK_1: specifying datafile (s) in backup set
Including standby control file in backup set
Channel ORA_DISK_1: starting piece 1 at 29-MAR-18
Channel ORA_DISK_1: finished piece 1 at 29-MAR-18
Piece handle =/tmp/ForStandbyCTRL. bck tag = TAG20180329T114413 comment = NONE
Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-MAR-18

 

[Oracle @ prim tmp] $ scp ForStandbyCTRL. bck 192.168.211.162:/tmp
Oracle@192.168.211.162's password:
ForStandbyCTRL. bck 100% 9856KB 9.6 MB/s

 

8. Backup database restoration control file:

RMAN> shutdown immediate;

Database dismounted

Oracle instance shut down

RMAN> startup nomount;

Connected to target database (not started)
Oracle instance started

Total System Global Area 1002127360 bytes

Fixed Size 2259440 bytes
Variable Size 285214224 bytes
Database Buffers 708837376 bytes
Redo Buffers 5816320 bytes

 

RMAN> restore standby controlfile from '/tmp/ForStandbyCTRL. bck ';

Starting restore at 29-MAR-18
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: SID = 10 device type = DISK

Channel ORA_DISK_1: restoring control file
Channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Output file name =/u01/app/oracle/oradata/rzorcl/control01.ctl
Output file name =/u01/app/oracle/oradata/rzorcl/control02.ctl
Finished restore at 29-MAR-18

 

9. Restart the slave database to mount

RMAN> SHUTDOWN;
RMAN> startup mount;

 

10. If the database uses the OMF method to manage data files, you need to re-register the data files in the control file of the slave database, for example:

(Skip this step if the data file is stored in the file system and OMF is not used)

RMAN> catalog start with '+ DATA/rzorcl/datafile /';

List of Files Unknown to the Database
============================================
File Name: + data/rzorcl/DATAFILE/SYSTEM.309.685535773
File Name: + data/rzorcl/DATAFILE/SYSAUX.301.685535773
File Name: + data/rzorcl/DATAFILE/UNDOTBS1.302.685535775
File Name: + data/rzorcl/DATAFILE/SYSTEM.297.688213333
File Name: + data/rzorcl/DATAFILE/SYSAUX.267.688213333
File Name: + data/rzorcl/DATAFILE/UNDOTBS1.268.688213335

Do you really want to catalog the above files (enter YES or NO )? YES
Cataloging files...
Cataloging done

List of Cataloged Files
======================================
File Name: + data/rzorcl/DATAFILE/SYSTEM.297.688213333
File Name: + data/rzorcl/DATAFILE/SYSAUX.267.688213333
File Name: + data/rzorcl/DATAFILE/UNDOTBS1.268.688213335

Make sure that no new data files are added to the master database after this SCN. If yes, you need to back up and restore the files separately. For more information, see document ID 836986.1.

SQL & gt; select file #, name from v $ datafile where creation_change # & gt; 3505254;

No rows selected

RMAN> switch database to copy;

Datafile 1 switched to datafile copy "+ DATA/rzorcl/datafile/system.297.688213333"
Datafile 2 switched to datafile copy "+ DATA/rzorcl/datafile/undotbs1.268.688213335"
Datafile 3 switched to datafile copy "+ DATA/rzorcl/datafile/sysaux.267.688213333"


11. If flash back is enabled for the standby database, you need to enable it again.


SQL> ALTER DATABASE FLASHBACK OFF;
SQL> ALTER DATABASE FLASHBACK ON;

 

12. Slave database clear standby log group

SQL> ALTER DATABASE CLEAR LOGFILE GROUP 4;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 5;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 6;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 7;


13. The log application is enabled for the slave database, and the entire process ends.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.