DG 修复(增量备份) (Doc ID 1531031.1)

APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.2.0.1 to 11.2.0.3 [Release 10.2 to 11.2]
Oracle Database - Enterprise Edition - Version 11.2.0.4 to 11.2.0.4 [Release 11.2]
Oracle Database - Enterprise Edition - Version 12.1.0.2 to 12.1.0.2 [Release 12.1]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Information in this document applies to any platform.<br* ***

GOAL

The steps in this section can used to resolve problems if a physical standby database has lost or corrupted archived redo data or has an unresolveable archive gap.

SOLUTION

1) On the standby database, stop the managed recovery process (MRP)

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

2) On the standby database, find the SCN which will be used for the incremental backup at the primary database:

SQL> SELECT CURRENT_SCN FROM V$DATABASE;

SQL> select min(checkpoint_change#) from v$datafile_header;
CHECKPOINT_CHANGE#
---------------------
3162298

In ideal situation the above 2 queries will return the almost same SCN. However if there is huge difference its better to take backup using the SCN from second query (lesser SCN), as one of the datafile may be behind.

3) In sqlplus, connect to the primary database and identify datafiles added:

SQL> SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# > <checkpoint_change# from 2>;

4) Using rman, create backup of missing datafiles and an incremental backup using the SCN derived in the previous step:

RMAN> backup datafile <missing file number>, <missing file number>, <missing file number>, <missing file number> format '/tmp/ForStandby_%U' tag 'FORSTANDBY';

RMAN> backup incremental from SCN 3162298 database format '/tmp/ForStandby_%U' tag 'FORSTANDBY';

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

5) Transfer all backup sets created on the primary system to the standby system.

scp /tmp/ForStandby* standby:/tmp

6) Restore new controlfile and catalog the backup transfered in step #5:

RMAN> shutdown;

RMAN> startup nomount;

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

RMAN> alter database mount;

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_2lkglss4_1_1
File Name: /tmp/ForStandby_2mkglst8_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_2lkglss4_1_1
File Name: /tmp/ForStandby_2mkglst8_1_1

7) Restore missing datafiles:

run

{

set newname for datafile X to '+DISKGROUP';

set newname for datafile Y to '+DISKGROUP';

set newname for datafile Z to '+DISKGROUP';

etc.

restore datafile x,y,z,....;

}

8) Rename the datafiles in new standby controlfile

Since the controlfile is restored from PRIMARY the datafile locations in STANDBY controlfile will be same as PRIMARY database, so catalog datafiles in STANDBY will do the necessary rename operations.

Perform the below step  in STANDBY for each diskgroup where the datafile directory structure between primary and standby are different.

RMAN> CATALOG START WITH '+DATA/<db_unqiue_name>/datafile/';

List of Files Unknown to the Database
=====================================
File Name: +data/<db_unqiue_name>/DATAFILE/SYSTEM.309.685535773
File Name: +data/<db_unqiue_name>/DATAFILE/SYSAUX.301.685535773
File Name: +data/<db_unqiue_name>/DATAFILE/UNDOTBS1.302.685535775
File Name: +data/<db_unqiue_name>/DATAFILE/SYSTEM.297.688213333
File Name: +data/<db_unqiue_name>/DATAFILE/SYSAUX.267.688213333
File Name: +data/<db_unqiue_name>/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/<db_unqiue_name>/DATAFILE/SYSTEM.297.688213333
File Name: +data/<db_unqiue_name>/DATAFILE/SYSAUX.267.688213333
File Name: +data/<db_unqiue_name>/DATAFILE/UNDOTBS1.268.688213335

 Once all files have been cataloged, switch the database to copy:

RMAN> SWITCH DATABASE TO COPY;

datafile 1 switched to datafile copy "+DATA/<db_unqiue_name>/datafile/system.297.688213333"
datafile 2 switched to datafile copy "+DATA/<db_unqiue_name>/datafile/undotbs1.268.688213335"
datafile 3 switched to datafile copy "+DATA/<db_unqiue_name>/datafile/sysaux.267.688213333"

9) Recover the standby database with the cataloged incremental backup:

RMAN> RECOVER DATABASE NOREDO;

starting recover at 03-JUN-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=28 devtype=DISK
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DATA/<db_unqiue_name>/datafile/system.297.688213333
destination for restore of datafile 00002: +DATA/<db_unqiue_name>/datafile/undotbs1.268.688213335
destination for restore of datafile 00003: +DATA/<db_unqiue_name>/datafile/sysaux.267.688213333
channel ORA_DISK_1: reading from backup piece /tmp/ForStandby_2lkglss4_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/tmp/ForStandby_2lkglss4_1_1 tag=FORSTANDBY
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished recover at 03-JUN-09

10) If the standby database needs to be configured for FLASHBACK use the below step to enable.

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

11) On standby database, clear all standby redo log groups:

SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 2;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 3;
....

12) On the standby database, start the MRP

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
posted @ 2023-08-04 10:51  阿西吧li  阅读(21)  评论(0编辑  收藏  举报