Get the App
SLTechnology News&Howtos  ›  Database  › 

How to realize seamless switching of physical DataGuard client

Shulou Source: shulou.com Published: 2022-05-31 15:08:04 10月24日 Update

This article mainly explains "how to achieve physical DataGuard client seamless switching", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to achieve physical DataGuard client seamless switching"!

Project customers have always wanted to automate the master / slave switching of DataGuard, that is, automatically switch to the standby database after the failure of the master database, and this process should be aware of the application. After consulting DG broker, considering its usability, ease of use, and license problems, broker was abandoned. However, switching from the physical backup library to the main library can still be transparent to the application. Before I had a crooked article, through the IP drift setting of the linux system, to achieve the transparency of the active / standby switch to the application. For dataguard switchover of oracle 11g, automatic switching can be achieved by creating triggers. Here are the main steps:

The main library executes:

1. Create 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

/

two。 Create a stored procedure, and the main library starts service snooping

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 lists procedure and function in package

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 a trigger, which is triggered when the master / slave is switched

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. Client configuration:

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)

)

)

)

Thank you for reading, the above is the content of "how to achieve seamless switching of physical DataGuard client". After the study of this article, I believe you have a deeper understanding of how to achieve seamless switching of physical DataGuard client, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Switching customer client physical seamless learning application content articles triggers processes problems crooked ways can be passed usability that is ideas situations failures ways Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MariaDB Microsoft Apple Xiaomi