Thursday, October 17, 2019

SWTICHOVER from PRIMARY to STANDBY

ON PRIMARY:


SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PRIM      READ WRITE           PRIMARY

SQL> ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';

Session altered.

SQL> SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;

 SEQUENCE# FIRST_TIME           NEXT_TIME            APPLIED
---------- -------------------- -------------------- ---------
         8 15-OCT-2019 17:37:49 15-OCT-2019 19:33:06 NO
         9 15-OCT-2019 19:33:06 15-OCT-2019 19:33:15 NO
        10 15-OCT-2019 19:33:15 15-OCT-2019 22:01:23 NO
        11 15-OCT-2019 22:01:23 15-OCT-2019 22:02:08 NO
        12 15-OCT-2019 22:02:08 16-OCT-2019 11:19:43 NO
        13 16-OCT-2019 11:19:43 16-OCT-2019 13:17:32 NO
        14 16-OCT-2019 13:17:32 16-OCT-2019 18:44:53 NO
        15 16-OCT-2019 18:44:53 16-OCT-2019 19:20:48 NO
..
...
.....
       106 17-OCT-2019 11:25:41 17-OCT-2019 11:25:42 YES
       107 17-OCT-2019 11:25:42 17-OCT-2019 11:25:44 NO
       107 17-OCT-2019 11:25:42 17-OCT-2019 11:25:44 YES
       108 17-OCT-2019 11:25:44 17-OCT-2019 11:27:16 NO
       108 17-OCT-2019 11:25:44 17-OCT-2019 11:27:16 NO

195 rows selected.

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
TO STANDBY

SQL> alter database commit to switchover to standby;

Database altered.

SQL> shutdown immediate;
ORA-01012: not logged on
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@prod ~]$ sqlplus '/as sysdba'

SQL*Plus: Release 12.1.0.2.0 Production on Thu Oct 17 13:58:03 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  780140544 bytes
Fixed Size                  2929256 bytes
Variable Size             557845912 bytes
Database Buffers          213909504 bytes
Redo Buffers                5455872 bytes
SQL> alter database mount standby database;

Database altered.

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PRIM      MOUNTED              PHYSICAL STANDBY

SQL> alter database recover managed standby database disconnect from session;

Database altered.



On Standby:

SQL> alter database commit to switchover to primary;

Database altered.

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PRIM      MOUNTED              PRIMARY

SQL> alter database open;

Database altered.

SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PRIM      READ WRITE           PRIMARY



No comments:

Post a Comment