邏輯備庫Switchover

duduyey發表於2014-08-14



系統資訊:Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux
資料庫版本:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

主庫資訊:

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE
--------- ------------------------------ ----------------
AARON     aaron                          PRIMARY

備庫資訊

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE
--------- ------------------------------ ----------------
AARONSTB  aaronstb                       LOGICAL STANDBY


1. 檢視主庫狀態

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

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

如果狀態為TO STANDBY或者SESSIONS ACTIVE 表示可以轉換為邏輯備庫。

2.當前主庫準備switchover

SQL> ALTER DATABASE PREPARE TO SWITCHOVER TO LOGICAL STANDBY;

Database altered.

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS
--------------------
PREPARING SWITCHOVER

3. 當前備庫準備switchover

SQL> ALTER DATABASE PREPARE TO SWITCHOVER TO PRIMARY;

Database altered.


SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS
--------------------
PREPARING SWITCHOVER

4. 確保當前主庫準備好swithover到備庫

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

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


TO LOGICAL STANDBY表示準備好switchover為備庫,如果不是此狀態,使用如下語句取消switchover
主庫:
SQL> ALTER DATABASE PREPARE TO SWITCHOVER CANCEL;
備庫:
SQL> ALTER DATABASE PREPARE TO SWITCHOVER CANCEL;

5. 切換當前主庫為備庫

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL STANDBY;

Database altered.

6. 確保備庫準備好成為主庫

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

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


7. 切換當前備庫為主庫

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

Database altered.

8. 開啟SQL Apply(新備庫)

SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;

Database altered.




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28719055/viewspace-1251278/,如需轉載,請註明出處,否則將追究法律責任。

相關文章