您好,登錄后才能下訂單哦!
這篇文章主要講解了“怎么實現物理DataGuard客戶端無縫切換”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“怎么實現物理DataGuard客戶端無縫切換”吧!
項目客戶一直想實現DataGuard的主備切換的自動化,即主庫故障后自動切換到備庫,并此過程要讓應用感知。咨詢了DG broker后,考慮到其可用性,易用性,和license問題,放棄了broker。但是物理備庫切換到主庫還是可以實現對應用透明的。之前我有篇歪門邪道的文章,通過linux系統的IP漂移設置,實現主備切換對應用的透明。對于oracle 11g的dataguard switchover,可以通過創建觸發器方式實現自動切換。下面是主要操作步驟:
主庫執行:
1.創建service
begin
DBMS_SERVICE.CREATE_SERVICE(service_name => 'dg_taf_pri',
network_name => 'dg_taf_pri',
aq_ha_notifications => TRUE,
failover_method => 'BASIC',
failover_type => 'SELECT',
failover_retries => 30,
failover_delay => 5);
end;
/
2.創建存儲過程,主庫啟動service監聽
create or replace procedure dg_taf_proc is
v_role VARCHAR(30);
begin
select DATABASE_ROLE into v_role from V$DATABASE;
if v_role = 'PRIMARY' then
DBMS_SERVICE.START_SERVICE('dg_taf_pri');
else
DBMS_SERVICE.STOP_SERVICE('dg_taf_pri');
end if;
end;
/
select owner,object_name ,procedure_name from dba_procedures where procedure_name='dg_taf_proc'; --procedure_name列出package中的procedure、function
select owner,object_name ,procedure_name from dba_procedures where object_name='DG_TAF_PROC';
select distinct name,owner from dba_source where name like 'DG_TAF_PROC%';
3.創建觸發器,主備切換時觸發
create or replace TRIGGER dg_taf_trg_startup
after startup or db_role_change on database
begin
dg_taf_proc;
end;
/
select trigger_name, trigger_name
from dba_triggers where trigger_name = 'DG_TAF_TRG_STARTUP';
4.客戶端配置:
dg_taf =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = 12.12.12.123)(PORT = 1521))
(ADDRESS = (PROTOCOL = tcp)(HOST = 12.12.12.125)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dg_taf_pri)
(FAILOVER_MODE =
(TYPE = session)
(METHOD = basic)
(RETRIES = 180)
(DELAY = 5)
)
)
)
感謝各位的閱讀,以上就是“怎么實現物理DataGuard客戶端無縫切換”的內容了,經過本文的學習后,相信大家對怎么實現物理DataGuard客戶端無縫切換這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。