oracle 11g dg broker 開啟fast-start failover自動故障切換

賀子_DBA時代發表於2019-07-04
一.首先保證主從資料庫的閃回資料庫功能以及強制歸檔都開啟,如下保證都為yes
SQL> select flashback_on,force_logging from v$database;
FLASHBACK_ON       FOR
------------------ ---
NO                NO
1.1開啟閃回資料庫
SQL> ALTER SYSTEM SET db_recovery_file_dest_size=3g SCOPE=BOTH;
System altered.
SQL> alter system set  db_recovery_file_dest='/data/u01/app/oracle/fast_recovery_area';
System altered.
SQL> alter database flashback on;
Database altered.
1.2開啟強制歸檔
SQL>  alter database force logging;
Database altered.
SQL> select flashback_on,force_logging from v$database;
FLASHBACK_ON       FOR
------------------ ---
YES                YES

二:開啟fast-start failover
2.1:開啟 fast-start failover
[oracle@beijing-fuli-hadoop-02 ~]$ dgmgrl  sys/
DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL>  enable fast_start failover;
Enabled.
2.2.檢視配置狀態,發現警告,因為沒有啟動observer而告警!
DGMGRL> show configuration
Configuration - dbha_c
Protection Mode: MaxPerformance
Databases:
db2 - Primary database
Warning: ORA-16819: fast-start failover observer not started
db1 - (*) Physical standby database
Warning: ORA-16819: fast-start failover observer not started
Fast-Start Failover: ENABLED
Configuration Status:
WARNING
2.3開啟 啟動觀察器(observer):
DGMGRL> show configuration
Configuration - dbha_c
Protection Mode: MaxPerformance
Databases:
db2 - Primary database
db1 - (*) Physical standby database
Fast-Start Failover: ENABLED
Configuration Status:
SUCCESS
由於observer的啟動會一直佔用session 視窗的,所以建議寫成指令碼掛後臺
這裡我們在備庫上建立指令碼,具體如下
建立一個名叫observer.sql的指令碼,把下面的命令放進去,然後執行該指令碼即可。
nohup dgmgrl  sys/oracle@db2 "start observer">>observer.log 2>&1 &
三:驗證自動切換:
db2主庫:
SQL> select  DATABASE_ROLE,OPEN_MODE from  v$database;

DATABASE_ROLE    OPEN_MODE
---------------- --------------------
PRIMARY          READ WRITE
db1為standby
SQL> select  DATABASE_ROLE,OPEN_MODE from  v$database;
DATABASE_ROLE    OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY
db2主庫模擬異常關閉
SQL> shu abort
ORACLE instance shut down.
再次檢視db1的狀態:
SQL> select  DATABASE_ROLE,OPEN_MODE from  v$database;
DATABASE_ROLE    OPEN_MODE
---------------- --------------------
PRIMARY          READ WRITE


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

相關文章