快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

如何实现OracleDataGuard主库备库角色切换

如何实现Oracle Data Guard主库备库角色切换,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

企业建站必须是能够以充分展现企业形象为主要目的,是企业文化与产品对外扩展宣传的重要窗口,一个合格的网站不仅仅能为公司带来巨大的互联网上的收集和信息发布平台,成都创新互联面向各种领域:成都发电机回收网站设计营销型网站建设解决方案、网站设计等建站排名服务。


步骤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;

NOT ALLOWED

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

PREPARING DICTIONARY

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

PREPARING SWITCHOVER

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

RECOVERY NEEDED

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

SESSIONS ACTIVE

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

SWITCHOVER PENDING

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

SWITCHOVER LATENT

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

TO LOGICAL STANDBY

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

TO PRIMARY

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

TO STANDBY

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

v$database Switchover_Status值的含义

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注创新互联行业资讯频道,感谢您对创新互联的支持。


名称栏目:如何实现OracleDataGuard主库备库角色切换
当前URL:http://6mz.cn/article/iiishj.html

其他资讯