oracle10g data guard role transition_physical_logical_switchover_failover

wisdomone1發表於2010-01-22
1,--rac備庫,轉換時,只有一個例項開啟,其它例項關閉,轉變角色後嗎,呵呵,其它例項會自動進行角色轉換喲,oracle我愛你
For a Real Application Clusters database, only one RAC instance on the standby database can be online during the role transition.
Shut down all other instances before starting the role transition.
Then, after the role transition completes, bring these instances back online.

Even though only one RAC instance on the standby database is open during the switchover, all other standby database
instances will automatically undergo a transition to their new role correctly when they are opened.

2
Data Guard provides the V$DATAGUARD_STATS view that can be used to estimate the viability of each standby database in terms of the currency
of the data in the standby database,
and the time it will take to perform. a role transition if all available redo data is applied to the standby database.


3 --花更多時間喲,如果備庫開啟模式(read only)
If the physical standby database is open for read-only access, the switchover still will take place, but will require additional time.

4
If possible, before performing a failover, you should transfer as much of the available and unapplied primary database redo data as possible to the standby database.


5 ---如果備庫處理最大保護模式,為了轉換角色,必須轉換為最大效能模式,轉換後,你可以再切換回來了
If a standby database currently running in maximum protection mode will be involved in the failover, first place it in maximum performance mode by issuing the following statement on the standby database:

SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;


6
Oracle recommends you use only the failover steps and commands described in the following sections to perform. a failover. Do not use the ALTER DATABASE ACTIVATE STANDBY DATABASE to perform. a failover, because this statement may cause data loss.

邏輯備庫切換出錯
到這一步不成了
Step 4   Ensure the current primary database is ready for the future primary database's redo stream.

Before you can complete the role transition of the primary database to the logical standby role, verify the LogMiner Multiversioned Data Dictionary was received by the primary database by querying the SWITCHOVER_STATUS column of the V$DATABASE fixed view on the primary database. Without the receipt of the LogMiner Multiversioned Data Dictionary, the switchover cannot proceed, because the current primary database will not be able to interpret the redo records sent from the future primary database. The SWITCHOVER_STATUS column shows the progress of the switchover.

When the query returns the TO LOGICAL STANDBY value, you can proceed with Step 5. For example:

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
-----------------
TO LOGICAL STANDBY
1 row selected



邏輯備庫之switchover

1,在主庫檢視是否可以切換為物理備庫
 SELECT SWITCHOVER_STATUS FROM V$DATABASE;--STANDBY or SESSIONS ACTIVE 表示可以切換,若為其它值,請檢查log_archive_dest_n相關配置是否正確;如值為not prepare,另急,稍侯,就可以了

2,在主庫準備切換為物理備庫
ALTER DATABASE PREPARE TO SWITCHOVER TO LOGICAL STANDBY;

3,在主庫檢視
SELECT SWITCHOVER_STATUS FROM V$DATABASE;--其值應為PREPARING SWITCHOVER;這個階段主庫已經作好切換為備庫的準備了,可以接受來自其它備庫的重作日誌傳輸

4,在邏輯備庫上,作好準備切換到主庫的工作
ALTER DATABASE PREPARE TO SWITCHOVER TO PRIMARY;--此步驟會傳送重作日誌到其它備庫和現在的主庫(原來的主庫)

5,在邏輯備庫檢視

SELECT SWITCHOVER_STATUS FROM V$DATABASE;--PREPARING DICTIONARY(剛開始第4步時:LogMiner Multiversioned Data Dictionary is being recorded in the redo stream),第四步完成變換為PREPARING SWITCHOVER.

6,在主庫檢視它已經作好切換到邏輯備庫的準備了
SELECT SWITCHOVER_STATUS FROM V$DATABASE; --若值為其下,說明可以正常切換了;看到其他值,請檢視邏輯備庫相關log_archive_dest配置,我就是檢視其值一直為PREPARING SWITCHOVER,後在備庫新增log_archive_dest_3='SERVICE=centos db_unique_name=centos';因為邏輯備庫會切換為主庫角色,他要把產生的歸檔傳到新的備庫(也就是原主庫)
TO LOGICAL STANDBY

   插補:
         You can cancel the switchover operation by issuing the following statements in the following order:

   1.

      Cancel switchover on the primary database:

      SQL> ALTER DATABASE PREPARE TO SWITCHOVER CANCEL;

   2.

      Cancel the switchover on the logical standby database:

      SQL> ALTER DATABASE PREPARE TO SWITCHOVER CANCEL;



7,實施切換主庫到邏輯備庫(在主庫)
 ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL STANDBY;


8,在邏輯備庫檢視可以切換為新的主庫
SELECT SWITCHOVER_STATUS FROM V$DATABASE;--若值為TO PRIMARY

9,在邏輯備庫,切換它為主庫
 ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

10,在新的備庫(原主庫)開啟sql應用
ALTER DATABASE START LOGICAL STANDBY APPLY;




邏輯備庫之failover

1,把主庫在邏輯備庫missing lag的歸檔日誌,全部cp到備庫,然後註冊
alter database register logical logfile 'missing lag archived log';---在邏輯備庫
2,確認所有的歸檔在邏輯備庫全部應用
select applied_scn,latest_scn from v$logstdby_progress;--二列值同,就ok
  note:如備庫未開啟sql apply,開啟此功能
     ALTER DATABASE START LOGICAL STANDBY APPLY FINISH;
3,把邏輯備庫啟用為新的主庫
ALTER DATABASE ACTIVATE LOGICAL STANDBY DATABASE FINISH APPLY;--加finish選項就是轉換角色前,把相關的歸檔全然在備庫上apply

4,若有其它的備庫配置,可以把他們加入新的dg環境中,方法如下
  在其它每個備庫上
    alter session disable guard;
    create database link 新主庫資料庫名 connect to username identified by password using '到新主庫的net service name';--構建到新主庫的資料庫連結
    alter session enable guard;--開啟guard配置
    select * from dba_logstdby_parameters@以上建立的資料庫連結名
5,在每個邏輯備庫上,實行sql apply
  alter database start logical standby apply new primary 新主庫資料庫名;

  若sql apply出現ora-16109,根據新主庫的備份重建出錯的邏輯備庫,然後把它加入到dg環境中


6,可選步,在failover後,馬上到新的主庫進行備份

7,原出故障的主庫恢復為新dg環境下的備庫,可採用flashback database或其它
 



物理備庫之switchover

1,先插述一段關於v$database中switchover_status所有列的相關解釋,相當實用

SWITCHOVER_STATUS     VARCHAR2(20)     Indicates whether switchover is allowed:

    *

      NOT ALLOWED - Either this is a standby database and the primary database has not been switched first or this is a primary database and there are no standby databases.
    *

      SESSIONS ACTIVE - Indicates that there are active SQL sessions attached to the primary or standby database that need to be disconnected before the switchover operation is permitted. Query the V$SESSION view to identify the specific processes that need to be terminated.
    *

      SWITCHOVER PENDING - This is a standby database and the primary database switchover request has been received but not processed.
    *

      SWITCHOVER LATENT - The switchover was in pending mode, but did not complete and went back to the primary database.
    *

      TO PRIMARY - This is a standby database and is allowed to switch over to a primary database.
    *

      TO STANDBY - This is a primary database and is allowed to switch over to a standby database.
    *

      RECOVERY NEEDED - This is a standby database that has not received the switchover request.
    *

      PREPARING SWITCHOVER - Either this is a primary database that is accepting redo data from a logical standby database in preparation for switch over to the logical standby database role, or it is a logical standby database sending redo data to a primary database and other standby databases in preparation for switch over to the primary database role. In the latter case, a completed dictionary has already been sent to the primary database and other standby databases.
    *

      PREPARING DICTIONARY - This is a logical standby database that is sending redo data to a primary database and other standby databases in the configuration in preparation for switch over to the primary database role.
    *

      TO LOGICAL STANDBY - This is a primary database that has received a complete dictionary from a logical standby database.


2,在作switchover前,最好對原主庫作個rman或全庫備份,萬一switchover失敗,也好恢復原狀,不然就麻煩了,成二吊子了

3,在作switchover前,在原物理務庫配置log_archive_dest_2(SERVICE),用於傳送歸檔到新的備庫(原主庫)

4,若switchover失敗,再次根據失敗切換的主庫再構建備庫,就會出錯,目前沒有找到原因

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

相關文章