物理DG主備切換小結

來源:互聯網
上載者:User

物理DG主備切換小結

環境檢查

檢查兩RAC的參數檔案配置

SQL> show parameter spfile;

SQL>show parameter fal;

lsnrctl status 查看RAC環境中監聽狀態

tnsping 查看TNS的連通情況

如果需要RAC作為備庫執行如下步驟

①.為RAC環境添加standby redolog,而且作為備庫redolog group數要多於或等於主庫:

SQL>alter database add standby logfile thread 1 group 5 size 50M ,group 6 size 50M ,group 7 size 50M ;

單一實例添加方法:

SQL>alter database add standby logfile group 7 '/oradata/racdb/onlinelog/group_7.log' size 50M;

②.配置RAC環境中以下兩個參數指定到自己的檔案路徑

SQL> alter system set db_file_name_convert='+DATA/phydb/','+DATA/racdb/' sid='*' scope=spfile;

SQL> alter system set  log_file_name_convert='+DATA/phydb/','+DATA/racdb/' sid='*' scope=spfile;

檢查standby資料庫
SQL> select status from v$instance;
 SQL> select open_mode from v$database;
 SQL> select member from v$logfile;

如果沒有standby redolog需要建立,文法如下:

SQL>alter database add standby logfile group 7 '/oradata/racdb/onlinelog/group_7.log' size 50M;

SQL> select name from v$datafile;

SQL> select name from v$tempfile;

SQL> show parameter control;

正常切換

①. 切換前檢查RAC環境中資料庫狀態

SQL> select dbid,name,protection_mode,database_role,open_mode,switchover_status from gv$database;

關閉任一節點資料庫

SQL> shutdown immediate;

②.將主庫切換為備庫

SQL>alter database commit to switchover to physical standby with session shutdown;

切換過程中查看資料庫狀態

③.備庫將已經完成傳輸的日誌應用完成,確保資料不會丟失

SQL> alter database recover managed standby database disconnect from session;

SQL> select name,creator,sequence#,applied,completion_time from v$archived_log;

SQL> alter database recover managed standby database cancel;

④. 斷開所有串連會話(或者重啟備庫到mount狀態),切換至主庫

SQL> alter database commit to switchover to primary;(mount狀態)

⑤.開啟資料庫,查看新主庫的狀態是否正常

SQL>alter database open;

SQL> select dbid,name,protection_mode,database_role,open_mode,switchover_status from v$database;

主庫故障無法修複,快速切換備庫為主庫

啟動備庫到mount狀態,查看資料庫standby資訊:

SQL>startup mount;

開機記錄應用,確保最大限度的可以日誌應用完成後,再開始切換

SQL> alter database recover managed standby database disconnect from session;

SQL> select name,creator,sequence#,applied,completion_time from v$archived_log;

SQL> alter database recover managed standby database cancel;

SQL>select thread#,low_sequence#,high_sequence from v$archive_gap;

確保日誌傳輸完成,如果有返回記錄,需要去主庫上將該檔案copy至備庫相應目錄下,並執行以下語句使之生效

SQL> alter database register physical logfile 'filespecl';

主備庫上都查詢一下歸檔的最大序號,確保主庫的歸檔備庫上都有,如果發現備庫沒有的,需要手動的複製至備庫。查詢語句如下:

SQL> select distinct thread#,max(sequence#) over(partition by thread#) a from v$archived_log;

停止當前的RFS進程,並立即執行failover

SQL> alter database recover managed standby database finish force;

切換備庫為主庫,並開啟資料庫

SQL> alter database commit to switchover to primary;

SQL> alter database open;

--------------------------------------分割線 --------------------------------------

Oracle Data Guard 重要配置參數

基於同一主機配置 Oracle 11g Data Guard

探索Oracle之11g DataGuard

Oracle Data Guard (RAC+DG) 歸檔刪除策略及指令碼

Oracle Data Guard 的角色轉換

Oracle Data Guard的日誌FAL gap問題

Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 處理方法

--------------------------------------分割線 --------------------------------------

相關文章

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.