RE: dataguard connection question

  • From: "Mathias Zarick" <Mathias.Zarick@xxxxxxxxxxxx>
  • To: <joan.hsieh@xxxxxxxxx>, "oracle_l" <ORACLE-L@xxxxxxxxxxxxx>
  • Date: Tue, 9 Jun 2009 09:05:51 +0200

Hi Joan,

the trick is like this:
It should also be described in on of the MAA White Papers.
Use an after startup on database trigger that starts up a service after
opening read write.
Use this service and both host in jdbc connect url.
It is important that dynamic service registration is able to connect to
local listener,
so local_listener init.ora Parameter has to be adapted correctly...


alter system set local_listener =
'(ADDRESS=(PROTOCOL=TCP)(HOST=test-xythdb-01)(PORT=11003))';


examples:

exec DBMS_SERVICE.CREATE_SERVICE ( -
  service_name => 'XYTHT_RW', -
  network_name => 'XYTHT_RW', -
  failover_method => 'BASIC', -
  failover_type => 'SESSION', -
  failover_retries => 3600, -
  failover_delay => 1);

exec DBMS_SERVICE.CREATE_SERVICE ( -
  service_name => 'XYTHT_RO', -
  network_name => 'XYTHT_RO', -
  failover_method => 'BASIC', -
  failover_type => 'SESSION', -
  failover_retries => 3600, -
  failover_delay => 1);
 

CREATE OR REPLACE TRIGGER service_trigger
  after startup on database
DECLARE
  db_name       VARCHAR(9);
  db_domain     VARCHAR(128);
  database_role VARCHAR(30);
BEGIN
  SELECT value 
    INTO db_name 
    FROM v$parameter 
      WHERE name = 'db_name';
  
  SELECT value 
    INTO db_domain 
    FROM v$parameter 
      WHERE name = 'db_domain';
  
  SELECT database_role 
    INTO database_role 
    FROM v$database;

  IF database_role = 'PRIMARY' THEN
    dbms_service.start_service(rtrim(db_name||'_RW.'||db_domain,'.'));
  ELSE
    dbms_service.start_service(rtrim(db_name||'_RO.'||db_domain,'.'));
  END IF;
END;
/ 

jdbc snippets:
String url =
"jdbc:oracle:thin:@(DESCRIPTION=(FAILOVER=ON)(LOADBALANCE=OFF)"
+ "(ADDRESS_LIST="
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=test-xythdb-01)(PORT=11003))"
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=test-xythdb-02)(PORT=11003))"
+ ")"
+ "(CONNECT_DATA=(SERVICE_NAME=XYTHT_RW)))";
ds = new oracle.jdbc.pool.OracleDataSource();
ds.setURL(url);
conn = ds.getConnection(user, password);

HTH Mathias



-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Joan Hsieh
Sent: Tuesday, June 09, 2009 1:35 AM
To: oracle_l
Subject: dataguard connection question

Hi List,

I have question regarding dataguard, the primary database is xytht1, the
standby is xytht2. the oracle is 11.1.0.7. Our client is using jdbc thin
client to connect the primary database. the connection string is

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test-xythdb-
01.uit.tufts.edu)(PORT=11003))(CONNECT_DATA=(SERVICE_NAME=XYTHT1)))
JDBCConnectionPool:395

After I tested switchover, the client lost connection, and have to
manually reconfigure to change the HOST and service name. This is not
acceptable to our client. I have no knowledge on how to automatically
switchover/failover for the client jdbc connection. Do you have any
ideas on this? Thank you for any helps.

Joan

--
//www.freelists.org/webpage/oracle-l


--
//www.freelists.org/webpage/oracle-l


Other related posts: