您好,登录后才能下订单哦!
这篇文章主要讲解了“怎么实现物理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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。