10g r2上switch over主備庫的過程示範

來源:互聯網
上載者:User

目前狀態是dg1為主庫,備庫為dg2
先檢查主備庫狀態:
dg1

SQL> select name,database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;DATABASE_ROLE    OPEN_MODE  SWITCHOVER_STATUS---------------- ---------- --------------------PRIMARY          READ WRITE SESSIONS ACTIVE

dg2

SQL> select database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;DATABASE_ROLE    OPEN_MODE  SWITCHOVER_STATUS---------------- ---------- --------------------PHYSICAL STANDBY MOUNTED    NOT ALLOWED

現在dg1當前主庫)上操作以下步驟: 

SQL>  alter database commit to switchover to physical standby with session shutdown;Database altered.SQL> shutdown immediate;ORA-01507: database not mountedORACLE instance shut down.SQL> startup mount;ORACLE instance started.Total System Global Area  390070272 bytesFixed Size                  2021024 bytesVariable Size             150997344 bytesDatabase Buffers          234881024 bytesRedo Buffers                2170880 bytesDatabase mounted.SQL> select switchover_status from v$database;SWITCHOVER_STATUS--------------------TO PRIMARY

現在dg2當前備庫)上操作以下步驟: 

SQL> select name,database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;NAME      DATABASE_ROLE    OPEN_MODE  SWITCHOVER_STATUS--------- ---------------- ---------- --------------------ORCLDB    PHYSICAL STANDBY MOUNTED    TO PRIMARYSQL> select switchover_status from v$database;SWITCHOVER_STATUS--------------------TO PRIMARYSQL>  alter database commit to switchover to primary;Database altered.SQL> alter database open;Database altered.SQL> select name,database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;NAME      DATABASE_ROLE    OPEN_MODE  SWITCHOVER_STATUS--------- ---------------- ---------- --------------------ORCLDB    PRIMARY          READ WRITE SESSIONS ACTIVE


以上的操作已經完成了主備的切換,現在dg2為主庫,dg1為備庫,接下來我們在現在的主庫dg2上做幾次日誌變化,看dg1能否同步過來。
dg1上看已經歸檔的日誌:

SQL> select registrar,creator thread#,sequence#,first_change#,next_change# from v$archived_log;REGISTR THREAD#  SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#------- ------- ---------- ------------- ------------FGRD    FGRD            29        586174       586196dg2上經過幾次日誌切換,SQL> select * from v$log;GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------1          1         36   52428800          1 NO  CURRENT                 586469 05-JAN-142          1         34   52428800          1 YES INACTIVE                586464 05-JAN-143          1         35   52428800          1 YES INACTIVE                586467 05-JAN-14

可以看出現在日誌已經到了36,那麼我們在dg1上應用日誌,應該會應用到日誌35;
以下操作驗證:

SQL> alter database recover managed standby database disconnect from session;Database altered.SQL> select registrar,creator thread#,sequence#,first_change#,next_change# from v$archived_log;REGISTR THREAD#  SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#------- ------- ---------- ------------- ------------RFS     ARCH            34        586464       586467RFS     ARCH            35        586467       586469

以上的主備切換過程就已經順利進行完成。

 

本文出自 “阿布” 部落格,請務必保留此出處http://carefree.blog.51cto.com/5771371/1351018

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.