Rumah  >  Artikel  >  pangkalan data  >  DataGuard角色切换

DataGuard角色切换

WBOY
WBOYasal
2016-06-07 17:12:20999semak imbas

Step 1 Verify that the primary database can be switched to the standby role.验证主库能够切换到备用角色。SELECT SWITCHO

Step 1   Verify that the primary database can be switched to the standby role.
验证主库能够切换到备用角色。
SELECT SWITCHOVER_STATUS FROM V$DATABASE;
idle>:wq

SWITCHOVER_STATUS
--------------------
TO STANDBY

Step 2   Initiate the switchover on the primary database.
在主库上面开始切换
alter database commit to switchover to physical standby with session shutdown ;

Step 3   Shut down and then mount the former primary database.
关闭并且mount上从前的主库。

shutdown abort;
startup mount ;

Step 4   Verify that the switchover target is ready to be switched to the primary role.
验证转换目标已经准备好转换为主库角色
SWITCHOVER_STATUS
--------------------
SWITCHOVER LATENT

这里查询出来的值不为TO_PRIMARY即有点问题。
执行下一步的时候可能会出现问题。

Step 5   Switch the target physical standby database role to the primary role.
转换目标逻辑备用库角色为主库角色。

sys@DEX>  ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
 ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN
*
ERROR at line 1:
ORA-16139: media recovery required

这里提示需要介质恢复。

sys@DEX> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Database altered.

sys@DEX> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS
--------------------
TO PRIMARY

sys@DEX> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;

Database altered.

Step 6   Open the new primary database.
打开新的主库
sys@DEX> ALTER DATABASE OPEN;

Database altered.

Step 7 Verify the switch role .
验证角色转换

主库执行
sys@DEX> alter system switch logfile ;

System altered.


sys@DEX> select sequence# from v$log ;


 SEQUENCE#
----------
        40
        41
        42


sys@DEX>

standby库执行

sys@DEX> select sequence# from v$log ;

 SEQUENCE#
----------
        40
        42
        41


sys@DEX>

linux

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:SQLite的C语言接口Artikel seterusnya:基于SQLite数据库的C语言编程