High Availability Oracle 11g DG Broker Configuration service

premise:

Main Library: 10.9.21.178 db_name: db2

dg library: 10.9.21.179 db_name: db1

1. Configure create service dbha

2. Create a trigger to start automatically hbha service at the main library

3. Set the TAF service function in the primary library

4. Modify the program url, automatic switching and services

Two: explain a few concepts

1.TAF (Transparent Application Failover) application i.e. transparent failover techniques. When the problem can not be connected to initialize the connection occurs, the function can ensure that the application reconnect to available services. Re-connection process, before the active transaction will be rolled back, but in the "specific conditions" TAF can guarantee SELECT statements have not been terminated.

TAF features:

2: TAF can be generally divided into two kinds, the TAF and TAF session connection establishment;

3: TAF itself regardless of whether the RAC environment, but are generally used in a RAC environment, most applications to reduce the impact minimal, single example environment may also be used TAF, so that the use of PL / SQL developer connect to the database, even if the database instance restarted, You do not need to reconnect;

4: TAF can be configured on the server side, that is, when connecting to the database, such as the client program to add url,

Or tnsname.ora configuration FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETIRES = 180) (DELAY = 15))), which is configured on the client, the server is configured to modify each of the services, then the service side property!

begin

dbms_service.modify_service

(Dbha '

FAILOVER_METHOD=>'BASIC',

FAILOVER_TYPE=>'SELECT',

FAILOVER_RETRIES=>15,

FAILOVER_DELAY=>5);

end;

/

5: After configuring the parameters GLOBAL_DBNAME listener.ora file will disable the TAF;

6: the difference oracle TAF scan ip failover characteristics and is, if it is connected scan ip scan ip node failure is located,

Then the connection is disconnected, if there is no mechanism to automatically re-connect program, or the program from the connection pool timeout value has not

To time, then you must restart the service in order to reconnect to the database, but then will not let TAF program error, but will be rolled back

Did not submit the transaction, automatically reconnect to another node, and the lower FAILOVER_TYPE => 'SELECT' is not select this manner

Stop, the results continued to be detected in another node!

III: Specific process is as follows:

3.1 In the main library to add and start the service, note that this service is configured to give the program the URL used!

To add, and then start the service, if you do not start, then see the show parameter service_name, service_name parameters after starting on the emergence of new services and automate this process pmon service listens on registration, and restart the service added after database disappeared, ineffective!

Add the service package as follows:

DBMS_SERVICE.CREATE_SERVICE(

service_name IN VARCHAR2,

network_name IN VARCHAR2,

goal IN NUMBER DEFAULT NULL,

dtp IN BOOLEAN DEFAULT NULL,

aq_ha_notifications IN BOOLEAN DEFAULT NULL,

failover_method IN VARCHAR2 DEFAULT NULL,

failover_type IN VARCHAR2 DEFAULT NULL,

failover_retries IN NUMBER DEFAULT NULL,

failover_delay IN NUMBER DEFAULT NULL,

clb_goal IN NUMBER DEFAULT NULL,

edition IN VARCHAR2 DEFAULT NULL);

--The network name of the service as used in SQLNet connect descriptors for client connections. This is limited to the NET

Specific implementation: the first of which is to add a dbha service name, the second is the network service name

1. Add Service

begin

dbms_service.create_service('dbha','dbha');

end;

/

2. Start Services

begin

DBMS_SERVICE.START_SERVICE('dbha');

end;

/

This time you see a listening state, you will find just added services have been registered with the dynamic process pmon

 

3. Stop Service:

begin

DBMS_SERVICE.STOP_SERVICE('dbha');

end;

/

4. Remove the service:

begin

DBMS_SERVICE.DELETE_SERVICE('dbha');

end;

/

3.2 Adding triggers in the master library, the trigger action is to determine the role of this example, the primary library (read write) is added to start the front

Services (dbha)

create trigger tri_startservice after startup on database

declare

dg_role varchar(30);

begin

select database_role into dg_role from v$database;

if dg_role='PRIMARY' then

DBMS_SERVICE.START_SERVICE('dbha');

end if;

end;

/

3.3 to add the service to open in front of the main library in TAF characteristics:

begin

dbms_service.modify_service

(Dbha '

FAILOVER_METHOD=>'BASIC',

FAILOVER_TYPE=>'SELECT',

FAILOVER_RETRIES=>15,

FAILOVER_DELAY=>5);

end;

/

 

3.4. URL modification program

datasource.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.9.21.178)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=10.9.21.179)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=dbha)(FAILOVER_MODE=(TYPE=SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5)) ) )

If oracle rac words:

datasource.url=jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.216)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.217)(PORT = 1521))(LOAD_BALANCE = yes)(FAILOVER = yes)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = cbl)(FAILOVER_MODE=(TYPE = SELECT)(METHOD = BASIC)(RETIRES = 180)(DELAY = 15))))

So far oracle 11g adg service availability configuration is completed

Summary: This time next test, when you master database shutdown abort, you are automatically converted from the library into the main library, and then start the trigger dbha service, then automatically registered pmon listen, because you are then configured the TAF feature, so you the service does not complain (ORA-0133: ORACLE initialization or shutdown in progress error), but is automatically connected to the new main library!

Verification process:

1. Client Configuration tnsnames.ora

dbha =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.21.178)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 10.9.21.179)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = dbha)

)

)

2. dbha services connect to the database,

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jul 13 17:11:55 2019

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Make sure the connection is the main library db2

SQL> select instance_name from v$instance;

INSTANCE_NAME

----------------

db2

3. abnormal shutdown db2

SQL> shu abort

ORACLE instance shut down.

4. Prior to the connected session to research instance name, but is not being given the card, because the main library db2 has been closed, and dg library

db1 also automatic conversion, it can not provide the service (about 10 seconds), then connect the db1:

SQL> select instance_name from v$instance;

INSTANCE_NAME

----------------

db2

SQL> select instance_name from v $ instance; ----- card about 10 seconds after displaying db1

INSTANCE_NAME

----------------

db1

Guess you like

Origin www.linuxidc.com/Linux/2019-08/160286.htm