Oraclue

Oracle internals, debugging and undocumented features

Role-Based Database Service

Starting with 11.2 role based services are managed by Clusterware.
For previous releases we had to use after db_role_change trigger.That is  no longer required.

So in the past :

/* Create Service */

exec DBMS_SERVICE.CREATE_SERVICE(service_name =>’taf’,network_name =>’taf’,aq_ha_notifications
=>true,failover_method =>’BASIC’,failover_type =>’SELECT’,failover_retries =>180,failover_delay => 5);

and have database trigger to start service in case database role switch happens:

CREATE OR REPLACE TRIGGER set_rc_svc 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(‘taf’);
ELSE
DBMS_SERVICE.STOP_SERVICE(‘taf’);
END IF;
END;
/

In 11.2  we can create database service which does not require this trigger.Clusterware will handle role change:

Oracle Notification Service ( ONS) and ONS for Enterprise Manager (ONS) must be enabled

So command to create role-based service looks something like this:

srvctl add service -d test -s taf -l PRIMARY -e session -m basic -q TRUE

It will enabled when database is serving as primary database.

Similar service can be created for STANDBY database:

srvctl add service -d test -s tafstandby -l PHYSICAL_STANDBY -e session -m basic -q TRUE

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: