Oracle Dataguard Switchover and Switchback
After you
configure your Dataguard (10g) or Active Dataguard (11g, 12c), to be ensure
that your system is working well, it’s very important to test to change the
database role, to be sure that your can efficiently use your disaster recovery
site in case of failure, without loss of data or without resetting logs.
Find below the
steps called switchover and switchback.
Switchover:
Before
performing switchover, kindly verify the state of data guard on both the
instances by following SQL queries:
SQL> SELECT
SEQUENCE#, to_char(FIRST_TIME, 'dd/mm/yyyy hh24:mi:ss'), to_char(NEXT_TIME,
'dd/mm/yyyy hh24:mi:ss'),applied FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
……..
………
SEQUENCE# TO_CHAR(FIRST_TIME, TO_CHAR(NEXT_TIME,'
APPLIED
---------- ------------------- -------------------
---------
13298
09/12/2017 23:33:04 10/12/2017 01:07:16 YES
13299
10/12/2017 01:07:16 10/12/2017 02:15:16 YES
13299
10/12/2017 01:07:16 10/12/2017 02:15:16 YES
13300
10/12/2017 02:15:16 10/12/2017 02:15:19 YES
13300
10/12/2017 02:15:16 10/12/2017 02:15:19 YES
13301
10/12/2017 02:15:19 10/12/2017 02:19:17 YES
13301
10/12/2017 02:15:19 10/12/2017 02:19:17 NO
13302
10/12/2017 02:22:38 10/12/2017 02:16:39 YES
13303
10/12/2017 02:16:39 10/12/2017 02:16:40 YES
13304
10/12/2017 02:16:40 10/12/2017 02:24:43 YES
13305
10/12/2017 02:24:43 10/12/2017 02:24:49 YES
6226 rows selected.
SQL> select dest_name,status,error from
v$archive_dest where dest_name='LOG_ARCHIVE_DEST_2';
DEST_NAME
--------------------------------------------------------------------------------
STATUS ERROR
---------
-----------------------------------------------------------------
LOG_ARCHIVE_DEST_2
VALID
SQL> select
message from v$dataguard_status;
SQL> select message from v$dataguard_status;
MESSAGE
--------------------------------------------------------------------------------
ARC0: Archival started
ARC1: Archival started
ARC2: Archival started
ARC1: Becoming the 'no FAL' ARCH
ARC1: Becoming the 'no SRL' ARCH
ARC2: Becoming the heartbeat ARCH
ARC1: Beginning to archive thread 2 sequence 13008
(11271382796885-1127138280134
7)
ARC1: Completed archiving thread 2 sequence 13008
(11271382796885-11271382801347
)
MESSAGE
--------------------------------------------------------------------------------
ARC3: Archival started
ARC0: Standby redo logfile selected for thread 2
sequence 13008 for destination
LOG_ARCHIVE_DEST_2
LNS: Standby redo logfile selected for thread 2
sequence 13010 for destination L
OG_ARCHIVE_DEST_2
LNS: Beginning to archive log 4 thread 2 sequence
13010
ARC3: Beginning to archive thread 2 sequence 13009
(11271382801347-1127138280552
3)
MESSAGE
--------------------------------------------------------------------------------
ARC3: Completed archiving thread 2 sequence 13009
(11271382801347-11271382805523
)
ARC0: Standby redo logfile selected for thread 2
sequence 13009 for destination
LOG_ARCHIVE_DEST_2
LNS: Completed archiving log 4 thread 2 sequence 13010
ARC1: Beginning to archive thread 2 sequence 13010
(11271382805523-1127191041305
2)
MESSAGE
--------------------------------------------------------------------------------
LNS: Standby redo logfile selected for thread 2
sequence 13011 for destination L
OG_ARCHIVE_DEST_2
LNS: Beginning to archive log 3 thread 2 sequence
13011
ARC1: Completed archiving thread 2 sequence 13010
(11271382805523-11271910413052
)
LNS: Completed archiving log 3 thread 2 sequence 13011
ARC3: Beginning to archive thread 2 sequence 13011
(11271910413052-1127191041325
2)
MESSAGE
--------------------------------------------------------------------------------
LNS: Standby redo logfile selected for thread 2
sequence 13012 for destination L
OG_ARCHIVE_DEST_2
LNS: Beginning to archive log 4 thread 2 sequence
13012
ARC3: Completed archiving thread 2 sequence 13011
(11271910413052-11271910413252
)
25 rows selected.
Note: This command will give you appropriate message about
the data guard current status.
After getting
confirmation on data guard smooth activity, we can instantiate switchover
activity by issuing following sort of commands:
On Primary database:
Step 1 : Connect to Primary database and
convert primary database to standby.
[oracle@entdb ~]$ sqlplus / as sysdba
SQL>
alter database commit to switchover to standby;
Database altered.
Step 2 : Normally, after the first step, the primary database goes down. if you
are on cluster configuration, all the instances stopped. If not, Shutdown primary database:
SQL> shutdown immediate;
If
you are on cluster :
[oracle@entdb ~]$ srvctl stop database -d LXXXXXXX
[oracle@entdb ~]$
Step 3 : Startup nomount
old primary database as new standby database and then start the apply process :
$ sqlplus / as
sysdba
SQL> startup nomount
ORACLE instance started.
SQL> alter database mount standby database;
Database
altered.
SQL> alter
database recover managed standby database using current logfile disconnect;
Database
altered.
Verify database role on old primary database:
SQL> select
name,open_mode,database_role from v$database;
NAME OPEN_MODE
DATABASE_ROLE
---------
-------------------- ----------------
LIFECXDB
MOUNTED PHYSICAL STANDBY
On Standby database:
Step 4 :
On original standby database, Convert old standby database to primary database:
[oracle@yde ~]$ sqlplus / as sysdba
SQL> alter database commit to switchover to
primary;
Database altered.
Step 5 : Restart the old
standby database as primary:
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
If you had a cluster standby database :
[oracle@yde
~]$ srvctl stop database -d STBXXXXXX
[oracle@yde
~]$
SQL> startup
ORACLE instance started.
Database mounted.
Database opened.
If you had a cluster standby database :
[oracle@yde
~]$ srvctl start database -d STBXXXXXX
[oracle@yde
~]$
Verify database role on old standby database:
SQL> select
name,open_mode,database_role from v$database;
NAME OPEN_MODE
DATABASE_ROLE
---------
-------------------- ----------------
LIFECXDB READ
WRITE PRIMARY
Switch over
activity have completed successfully, our old primary database has become
standby and old standby database has become primary database.
Note : To test above switchover activity, generate multiple archive logs on
primary database and verify those archive logs being transferred on standby
database.
Switchback:
To switchback, you have to follow same above mentioned from step 1 to
step 6.
Aucun commentaire:
Enregistrer un commentaire