Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.

Rasul Allah (sal Allahu alaihi wa sallam) said: "Restore the trusts of those who trust you, and deal not falsely with him who deals falsely with you." [Abu Dawud, Tirmidhi]

Search This Blog

Saturday, August 22, 2015

Oracle Performing manual switchover to standby database.


Performing graceful switchover to standby database.


Current status:

Primary:
SQL>  select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME              OPEN_MODE        DATABASE_ROLE    SWITCHOVER_STATUS
------------------------------ -------------------- ---------------- --------------------
orcl                  READ WRITE        PRIMARY         TO STANDBY


Standby:
SQL>  select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME              OPEN_MODE        DATABASE_ROLE    SWITCHOVER_STATUS
------------------------------ -------------------- ---------------- --------------------
msft                  MOUNTED           PHYSICAL STANDBY NOT ALLOWED

Now switchover the primary to standby:

SQL> alter database commit to switchover to standby with session shutdown;

Database altered.

SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.


SQL> startup mount;
ORACLE instance started.

Total System Global Area  430075904 bytes
Fixed Size           2214056 bytes
Variable Size         343934808 bytes
Database Buffers       79691776 bytes
Redo Buffers           4235264 bytes
Database mounted.
SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME              OPEN_MODE        DATABASE_ROLE    SWITCHOVER_STATUS
------------------------------ -------------------- ---------------- --------------------
orcl                  MOUNTED           PHYSICAL STANDBY TO PRIMARY

SQL> recover managed standby database disconnect;
Media recovery complete.

Now switchover the standby to PRIMARY:

During the primary switchover(orcl) standby (msft) switchover_status automatically changed from “NOT ALLOWED” to “TO PRIMARY”

SQL>  select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME              OPEN_MODE        DATABASE_ROLE    SWITCHOVER_STATUS
------------------------------ -------------------- ---------------- --------------------
msft                  MOUNTED           PHYSICAL STANDBY TO PRIMARY

SQL> alter database commit to switchover to primary with session shutdown;

Database altered.

SQL> alter database open;

Database altered.

SQL> select db_unique_name,open_mode,database_role,switchover_status from v$database;

DB_UNIQUE_NAME              OPEN_MODE        DATABASE_ROLE    SWITCHOVER_STATUS
------------------------------ -------------------- ---------------- --------------------
msft                  READ WRITE        PRIMARY         TO STANDBY

No comments: