SWITCHOVER PROCESS


                                                                     

1) Application stop

2) Open Flashback in Primary sistem

sqlplus / as sysdba

alter system set db_recovery_file_dest_size=20g scope=both;
alter system set db_recovery_file_dest='+ARCH' scope=both;

srvctl stop database -d DEMO
sqlplus / as sysdba
startup nomount
alter database mount;
ALTER DATABASE FLASHBACK ON;
alter database open;
sqlplus / as sysdba
shutdown abort;

srvctl start database -d KBAZER

3) Primary :

  alter system set job_queue_processes=0 scope=both sid='*';
  srvctl stop instance -i DEMO2 -d DEMO

  sqlplus / as sysdba
  create restore point grp_switchover_start_primary guarantee flashback database;

4) Standby:

  alter system set job_queue_processes=0 scope=both sid='*';

  sqlplus / as sysdba
  create restore point grp_switchover_start_testist guarantee flashback database;

5) Primary :

  alter system switch logfile;
  alter system switch logfile;
  alter system switch logfile;
  alter system switch logfile;

6) Primary: 

select thread#, max(sequence#) from v$log_history group by thread#;
alter session set nls_date_format='DD-MM-YYYY HH24:MI:SS';
select thread#, sequence#, first_time from (select * from v$log_history order by first_time desc) where rownum < 4;
select inst_id, process, pid, status, thread#, sequence#, block#, blocks from gv$managed_standby;  

Checking  prosess:

 select inst_id, process, pid, status, thread#, sequence#, block#, blocks from gv$managed_standby

   INST_ID PROCESS                                     PID STATUS                                              THREAD#  SEQUENCE#     BLOCK#     BLOCKS
---------- ------------------------------------ ---------- ------------------------------------------------ ---------- ---------- ---------- ----------
         1 ARCH                                      22472 CLOSING                                                   2      30183       6144       1088
         1 ARCH                                      22476 CLOSING                                                   1      30865      57344       1718
         1 ARCH                                      22478 CONNECTED                                                 0          0          0          0
         1 ARCH                                      22482 CLOSING                                                   1      30866      28672       1732
         1 RFS                                       27802 IDLE                                                      1      30867       5383          1
         1 RFS                                       27806 IDLE                                                      0          0          0          0
         1 RFS                                       27808 IDLE                                                      0          0          0          0
         1 RFS                                       27804 IDLE                                                      2      30184       1411          1
         1 MRP0                                      28337 APPLYING_LOG                                              1      30867       5382    1024000

7) Primary:

select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE

8) Switch Option:

-- Primary - database starting switch process.

alter database commit to switchover to physical standby with session shutdown;

-- Need to see it alert log.

Switchover: Complete - Database shutdown required
Completed: alter database commit to switchover to physical standby with session shutdown

-- Checking database role ve switchover_status 

select NAME,OPEN_MODE,DATABASE_ROLE,SWITCHOVER_STATUS,PROTECTION_MODE,PROTECTION_LEVEL from v$database;

NAME      OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS    PROTECTION_MODE      PROTECTION_LEVEL
--------- -------------------- ---------------- -------------------- -------------------- --------------------
TESTCRD   READ WRITE           PHYSICAL STANDBY RECOVERY NEEDED      MAXIMUM AVAILABILITY UNPROTECTED

9) Primary:

shutdown abort

10) Standby : 

alter database commit to switchover to primary with session shutdown;

-- alert log

Completed: alter database commit to switchover to primary with session shutdown

alter database open

11) Open old primary database:

sqlplus / as sysdba
startup nomount
alter database mount standby database

-- Checking database role ve switchover_status 

select NAME,OPEN_MODE,DATABASE_ROLE,SWITCHOVER_STATUS,PROTECTION_MODE,PROTECTION_LEVEL from v$database;

NAME      OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS    PROTECTION_MODE      PROTECTION_LEVEL
--------- -------------------- ---------------- -------------------- -------------------- --------------------
TESTCRD   READ WRITE           PHYSICAL STANDBY RECOVERY NEEDED      MAXIMUM AVAILABILITY UNPROTECTED

recover managed standby database using current logfile disconnect from session;

12) Checking all archivelog: 

-- primary 

alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;

-- primary and  standby

select NAME,OPEN_MODE,DATABASE_ROLE,SWITCHOVER_STATUS,PROTECTION_MODE,PROTECTION_LEVEL from v$database;
select inst_id, process, pid, status, thread#, sequence#, block#, blocks from gv$managed_standby;
select thread#, max(sequence#) from v$log_history group by thread#;
alter session set nls_date_format='DD-MM-YYYY HH24:MI:SS';
select thread#, sequence#, first_time from (select * from v$log_history order by first_time desc) where rownum < 4;

-- primary and  standby 

alter system set job_queue_processes=1000 scope=both sid='*';

13) Drop restore points:

drop restore point grp_switchover_start_primary;
select * from v$restore_point;

drop restore point grp_switchover_start_testist;
select * from v$restore_point;

14) Restart Primary and Standby Database

Old primary

sqlplus / as sysdba
recover managed standby database cancel;
shutdown immediate;
startup nomount;
alter database mount;
recover managed standby database using current logfile disconnect from session;

Old Standby

sqlplus / as sysdba
shutdown immediate;
startup;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: