A scenario where we need to do some changes on database but want to revert back to the previous state of the database and also fix the dataguard instance after reverting to previous state.
There are simple 13 steps to achieve this and those are:
Make sure that the FLASHBACK is ON under Primary and DR. Then get the SCN on the database from any of the PRIMARY nodes.
There are simple 13 steps to achieve this and those are:
- Make sure that the FLASHBACK is ON under Primary and DR. Then get the SCN on the database from any of the PRIMARY nodes.
- Turn off the log transport.
- Shutdown Primary database and DR database.
- Start up mount database on one of the nodes under primary side.
- Log in to database and flashback database to SCN captured in step 1.
- Shutdown database on Primary side and Start up database on all nodes on primary side.
- SQLPLUS to primary and get the Resetlog SCN .
- Turn the log transport on and wait for 5 mins for logs to be shipped to DR side.
- Start the database on DR.
- From primary side connect to dgmgrl and show configuration.
- On DR side create a sqlplus session and flashback database to Resetlog SCN taken in step 7.
- Shutdown DR and start is up.
- You are done, have a cup of coffee :)
Blow are the actual commands that I have used in my environment to achieve this outcome:
Make sure that the FLASHBACK is ON under Primary and DR. Then get the SCN on the database from any of the PRIMARY nodes.
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES
SQL>
SQL> select dbms_flashback.get_system_change_number begin_scn from dual;
BEGIN_SCN
---------------------
20778833
SQL>
Turn off the log transport.
[oracle@rac2 ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/******@RAC
Connected.
DGMGRL>
DGMGRL> show database 'RAC'
Database - RAC
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
RAC1
RAC2
Database Status:
SUCCESS
DGMGRL> show database verbose 'RAC'
Database - RAC
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
RAC1
RAC2
Properties:
DGConnectIdentifier = 'RAC'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '30'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = '+DATA/rac_stby, +DATA/rac'
LogFileNameConvert = '+FRA/rac_stby, +FRA/rac, +DATA/rac_stby, +DATA/rac'
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
SidName(*)
StaticConnectIdentifier(*)
StandbyArchiveLocation(*)
AlternateLocation(*)
LogArchiveTrace(*)
LogArchiveFormat(*)
TopWaitEvents(*)
(*) - Please check specific instance for the property value
Database Status:
SUCCESS
DGMGRL>
DGMGRL> edit database 'RAC' set state=TRANSPORT-OFF;
Succeeded.
DGMGRL> show database 'RAC'
Database - RAC
Role: PRIMARY
Intended State: TRANSPORT-OFF
Instance(s):
RAC1
RAC2
Database Status:
SUCCESS
DGMGRL>
Shutdown Primary database and DR database.
[oracle@rac1 ~]$ srvctl stop database -d RAC
[oracle@racdr1 ~]$ srvctl stop database -d RAC_STBY
Start up mount database on one of the nodes under primary side.
srvctl start database -d RAC -o mount -i RAC1Log in to database and flashback database to SCN captured in step 1.
SQL> flashback database to scn 20778833;Shutdown database on Primary side and Start up database on all nodes on primary side.
Flashback complete.
SQL>
SQL> alter database open resetlogs;
Database altered.
SQL>
[oracle@rac1 ~]$ srvctl stop database -d RACSQLPLUS to primary and get the Resetlog SCN .
[oracle@rac1 ~]$
[oracle@rac1 ~]$ srvctl start database -d RAC
[oracle@rac1 ~]$
[oracle@rac1 ~]$ srvctl status database -d RAC
Instance RAC1 is running on node rac1
Instance RAC2 is running on node rac2
[oracle@rac1 ~]$
SQL> select resetlogs_change# from v$database;Turn the log transport on and wait for 5 mins for logs to be shipped to DR side.
RESETLOGS_CHANGE#
-----------------
20778835
SQL>
DGMGRL> edit database 'RAC' set state=TRANSPORT-ON;Start the database on DR.
Succeeded.
DGMGRL>
[oracle@racdr1 ~]$ srvctl start database -d RAC_STBYFrom primary side connect to dgmgrl and show configuration.
[oracle@racdr1 ~]$ srvctl status database -d RAC_STBY
Instance RAC_STBY1 is running on node racdr1
[oracle@racdr1 ~]$
DGMGRL> show configurationOn DR side create a sqlplus session and flashback database to Resetlog SCN taken in step 7.
Configuration - racdg
Protection Mode: MaxPerformance
Databases:
RAC - Primary database
Error: ORA-16810: multiple errors or warnings detected for the database
RAC_STBY - Physical standby database
Error: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Fast-Start Failover: DISABLED
Configuration Status:
ERROR
DGMGRL>
SQL> flashback database to SCN 20778835;Shutdown DR and start is up.
Flashback complete.
SQL>
[oracle@racdr1 ~]$ srvctl stop database -d RAC_STBYYou are done have a break and get a cup of coffee :)
[oracle@racdr1 ~]$
[oracle@racdr1 ~]$ srvctl start database -d RAC_STBY
DGMGRL> show configuration
Configuration - racdg
Protection Mode: MaxPerformance
Databases:
RAC - Primary database
RAC_STBY - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
DGMGRL>
No comments:
Post a Comment