這篇文章主要講解了“怎么實(shí)現(xiàn)物理DataGuard客戶端無(wú)縫切換”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么實(shí)現(xiàn)物理DataGuard客戶端無(wú)縫切換”吧!
創(chuàng)新互聯(lián)建站基于成都重慶香港及美國(guó)等地區(qū)分布式IDC機(jī)房數(shù)據(jù)中心構(gòu)建的電信大帶寬,聯(lián)通大帶寬,移動(dòng)大帶寬,多線BGP大帶寬租用,是為眾多客戶提供專業(yè)四川電信科技城機(jī)房報(bào)價(jià),主機(jī)托管價(jià)格性價(jià)比高,為金融證券行業(yè)服務(wù)器托管,ai人工智能服務(wù)器托管提供bgp線路100M獨(dú)享,G口帶寬及機(jī)柜租用的專業(yè)成都idc公司。
項(xiàng)目客戶一直想實(shí)現(xiàn)DataGuard的主備切換的自動(dòng)化,即主庫(kù)故障后自動(dòng)切換到備庫(kù),并此過程要讓應(yīng)用感知。咨詢了DG broker后,考慮到其可用性,易用性,和license問題,放棄了broker。但是物理備庫(kù)切換到主庫(kù)還是可以實(shí)現(xiàn)對(duì)應(yīng)用透明的。之前我有篇歪門邪道的文章,通過linux系統(tǒng)的IP漂移設(shè)置,實(shí)現(xiàn)主備切換對(duì)應(yīng)用的透明。對(duì)于oracle 11g的dataguard switchover,可以通過創(chuàng)建觸發(fā)器方式實(shí)現(xiàn)自動(dòng)切換。下面是主要操作步驟:
主庫(kù)執(zhí)行:
1.創(chuàng)建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.創(chuàng)建存儲(chǔ)過程,主庫(kù)啟動(dòng)service監(jiān)聽
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.創(chuàng)建觸發(fā)器,主備切換時(shí)觸發(fā)
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)
)
)
)
感謝各位的閱讀,以上就是“怎么實(shí)現(xiàn)物理DataGuard客戶端無(wú)縫切換”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)怎么實(shí)現(xiàn)物理DataGuard客戶端無(wú)縫切換這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!