ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle Data Guard主库备库角色切换(Switchovers)

Oracle Data Guard主库备库角色切换(Switchovers)

原创 Linux操作系统 作者:lyf625 时间:2010-11-23 17:00:55 0 删除 编辑

步骤1:验证主库能否进行角色切换,TO STANDBY表示可以进行
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
-----------------
TO STANDBY
1 row selected

The TO STANDBY value in the SWITCHOVER_STATUS column indicates that it is
possible to switch the primary database to the standby role. If the TO STANDBY value
is not displayed, then verify the Data Guard configuration is functioning correctly (fo
example, verify all LOG_ARCHIVE_DEST_n parameter values are specified correctly).
If the value in the SWITCHOVER_STATUS column is SESSIONS ACTIVE, perform. the
steps described in SectionA.4, "Problems Switching Over to a Standby Database" on
pageA-4 to identify and terminate active user or SQL sessions that might prevent a

switchover from being processed. If, after performing these steps, the SWITCHOVER_
STATUS column still displays SESSIONS ACTIVE, you can successfully perform. a
switchover by appending the WITH SESSION SHUTDOWN clause to the ALTER
DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY statement
described in Step 2.
See Oracle Database Reference for information about other valid values for the
SWITCHOVER_STATUS column of the V$DATABASE view.

步骤2:在主库上执行角色切换到从库角色
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;

After this statement completes, the primary database is converted into a standby
database. The current control file is backed up to the current SQL session trace file
before the switchover. This makes it possible to reconstruct a current control file, if
necessary.

步骤3:关闭并重新启动之前的主库实例
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;

At this point in the switchover process, both databases are configured as standby
databases.

步骤4:在备库的V$DATABASE视图中查看备库的切换状态
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
-----------------
TO_PRIMARY
1 row selected

If the value in the SWITCHOVER_STATUS column is SESSIONS ACTIVE, perform. the
steps described in SectionA.4, "Problems Switching Over to a Standby Database" on
pageA-4 to identify and terminate active user or SQL sessions that might prevent a
switchover from being processed. If, after performing these steps, the SWITCHOVER_
STATUS column still displays SESSIONS ACTIVE, you can proceed to Step 5, and
append the WITH SESSION SHUTDOWN clause to the switchover statement. See Oracle
Database Reference for information about other valid values for the SWITCHOVER_
STATUS column of the V$DATABASE view

步骤5:切换备库到主库角色
You can switch a physical standby database from the standby role to the primary role
when the standby database instance is either mounted in Redo Apply mode or open
for read-only access. It must be in one of these modes so that the primary database
switchover request can be coordinated. After the standby database is in an appropriate
mode, issue the following SQL statement on the physical standby database that you
want to change to the primary role:


SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

步骤6:完成备库到主库的切换
1. 如果备库没有以只读模式打开,直接执行以下语句打开到新的主库。
SQL> ALTER DATABASE OPEN;

2. 如果备库以只读模式打开,先关闭数据,然后再重新启动。
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;

步骤7:如果有必要,重新启动一下新的备库上的重做日志应用服务
For the new physical standby database and for each other physical or logical standby
database in the Data Guard configuration, if log apply services were not previously
configured to continue operating through a switchover, use an appropriate command
to restart log apply services. See Chapter6, "Log Apply Services" for more information
about how to configure and start log apply services.
SQL> alter database recover managed standby database disconnect from session;

(注:可以通过select message from v$dataguard_status;查看当前备库应用重做日志的状态)

步骤8:开始发送重做数据到备库上
Issue the following statement on the new primary database:
SQL> ALTER SYSTEM SWITCH LOGFILE;

v$database Switchover_Status值的含义

NOT ALLOWED

当前的数据库不是带有备用数据库的主数据库

PREPARING DICTIONARY

该逻辑备用数据库正在向一个主数据库和其他备用数据库发送它的重做数据,以便为切换做准备

PREPARING SWITCHOVER

接受用于切换的重做数据时,逻辑备用配置会使用它

RECOVERY NEEDED

备用数据库还没有接收到切换请求

SESSIONS ACTIVE

在主数据库中存在活动的SQL会话;在继续执行之前必须断开这些会话

SWITCHOVER PENDING

适用于那些已收到主数据库切换请求但是还没有处理该请求的备用数据库

SWITCHOVER LATENT

切换没有完成并返回到主数据库

TO LOGICAL STANDBY

主数据库已经收到了来自逻辑备用数据库的完整的字典

TO PRIMARY

该备用数据库可以转换为主数据库

TO STANDBY

该主数据库可以转换为备用数据库

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13024285/viewspace-679535/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-03-06

  • 博文量
    41
  • 访问量
    57164