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

步骤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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/13024285/viewspace-679535/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值