怎么实现物理DataGuard客户端无缝切换
这篇文章主要讲解了“怎么实现物理DataGuard客户端无缝切换”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么实现物理DataGuard客户端无缝切换”吧!
创新互联建站基于成都重庆香港及美国等地区分布式IDC机房数据中心构建的电信大带宽,联通大带宽,移动大带宽,多线BGP大带宽租用,是为众多客户提供专业四川电信科技城机房报价,主机托管价格性价比高,为金融证券行业服务器托管,ai人工智能服务器托管提供bgp线路100M独享,G口带宽及机柜租用的专业成都idc公司。
项目客户一直想实现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客户端无缝切换这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!
网站栏目:怎么实现物理DataGuard客户端无缝切换
URL地址:http://scjbc.cn/article/jeshjo.html