01.02. Creation new service and connection string (TAF)

                   <<< Back   Next >>>
1. Creation new service
BEGIN
DBMS_SERVICE.CREATE_SERVICE('bank_srv','bank_srv');
END;
/

2. Startup new service
BEGIN
DBMS_SERVICE.START_SERVICE('bank_srv');
END;
/
-- notes
-- stop service
-- exec DBMS_SERVICE.STOP_SERVICE('bank_srv');    
-- delete service
-- exec DBMS_SERVICE.DELETE_SERVICE('bank_srv'); 

3. Checking new service on primary
select * from v$services;
lsnrctl services

4. Add triggers to manage the new service (startup only on PRIMARY):
create trigger managed_service_bank_srv
after DB_ROLE_CHANGE on database
declare
role varchar(30);
begin
  select database_role into role from v$database;
   if role = 'PRIMARY' then
     DBMS_SERVICE.START_SERVICE('bank_srv');
   else
     DBMS_SERVICE.STOP_SERVICE('bank_srv');
   end if;
end;
/
create trigger managed_start_bank_srv
after startup on database
declare
role varchar(30);
begin
   select database_role into role from v$database;
   if role = 'PRIMARY' then
     DBMS_SERVICE.START_SERVICE('bank_srv');
   else
     DBMS_SERVICE.STOP_SERVICE('bank_srv');
   end if;
end;
/

5. Copying the new connection string (TAF) on application servers
bank_srv =
 (DESCRIPTION=
  (FAILOVER=on)
  (LOAD_BALANCE=off)
  (CONNECT_TIMEOUT=1)(TRANSPORT_CONNECT_TIMEOUT=1)(RETRY_COUNT=1)
  (ADDRESS=(PROTOCOL=tcp) (HOST=ora-fsfo-db01) (PORT=1521))
  (ADDRESS=(PROTOCOL=tcp) (HOST=ora-fsfo-db02) (PORT=1521))
  (CONNECT_DATA=
     (SERVICE_NAME=bank_srv)
     (FAILOVER_MODE= (TYPE=select) (METHOD=basic) (retries=3)(delay=3))
  ))
                   <<< Back   Next >>>

No comments:

Post a Comment