Está en la página 1de 2

Performing a Switchover between Primary and Standby Databases

If you’ve ever performed a switchover operation between a primary and a standby database
without Data Guard Broker, I’m sure you’ll agree that it’s a tedious, manually-intensive process
that involves several distinct steps which must be performed carefully and in precise order to
insure a successful role transition. Here’s a brief summary of the steps required:

1.) Check the status of the primary database. Column V$DATABASE.SWITCHOVER_STATUS on


the primary database must reflect the proper state of the primary database. Either a value of
TO_STANDBY or SESSIONS_ACTIVE indicates that a switchover is possible; otherwise, redo
transport services haven’t been configured properly.

2.) Start the switchover process on the primary database. Next, the standby database has to be
prepared to handle switchover by issuing the appropriate switchover command from SQL*Plus.
During this process, the primary database is prepared to assume the standby role, and its control
file is backed up to make sure it could be reconstructed in case a failure occurs.

-- If no sessions are active ...


SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
-- ... but if sessions are active:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH
SESSION SHUTDOWN;

3.) Shut down, then mount, the original primary database. Once the role transition is complete on
the original primary (and soon to become the standby) database, it’s time to shut it down and
mount it.

SQL> SHUTDOWN IMMEDIATE;


SQL> STARTUP MOUNT;

4.) Check that the target database’s status is ready for switchover. The target standby database
must be ready to accept its new primary role. Column V$DATABASE.SWITCHOVER_STATUS on
this database must contain a value of either TO_PRIMARY or SESSIONS_ACTIVE to indicate
that a switchover is possible; otherwise, redo transport services haven’t been configured properly.

5.) Switch the target database to its new primary role. Depending on the result from the previous
step, the appropriate command needs to be issued on the (soon to be) primary database from
SQL*Plus:

-- If no sessions are active ...


SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
-- ... but if sessions are active:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION
SHUTDOWN;

6.) Open the new primary database. It’s time to activate the new primary database from
SQL*Plus:

SQL> ALTER DATABASE OPEN;

7.) Make the original primary database into the standby database. To complete the role transition,
the original primary database must be enabled to accept its new standby role.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE


USING CURRENT LOGFILE
DISCONNECT FROM SESSION;
In this relatively simple example of a role transition, notice that I haven’t discussed what to do if
there’s a failure at any point during this process. Frankly, I’d much rather have a lot more
insurance should the process fail at any point … and that’s where Data Guard Broker comes in.

También podría gustarte