Skip to content

How Srvctl Add Service

  • by

Srvctl Add Service

The default service name of a database is the DB_UNIQUE_NAME, if we'd like to add some other entries to service different kinds of user, we have two options, one is to use DBMS_SERVICE to create a service in database, the other is to use srvctl add service in cluster.

To create a new service to a pluggable database (PDB) by srvctl, there's a little different.

Let's see how we add a service to the cluster by srvctl.

1. srvctl add service

For a RAC database, you can use srvctl add service command to create a new service.

[oracle@primary01 ~]$ srvctl add service -d orcl -s CRM -r ORCL1,ORCL2

Or using the long form for release 12c and later.

[oracle@primary01 ~]$ srvctl add service -database orcl -service CRM -preferred ORCL1,ORCL2

This is the simplest way to create a service for a RAC database. However, the service can be configured as a failover-able one by adding more options to it, which means that it's able to failover sessions to another instance transparently if current instance is down.

srvctl config service

We should make sure all services in the database is correctly configured.

[oracle@primary01 ~]$ srvctl config service -d orcl
Service name: CRM
Server pool:
Cardinality: 2
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Global: false
Commit Outcome: false
Failover type:
Failover method:
Failover retries:
Failover delay:
Failover restore: NONE
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: NONE
Pluggable database name:
Hub service:
Maximum lag time: ANY
SQL Translation Profile:
Retention: 86400 seconds
Replay Initiation Time: 300 seconds
Drain timeout:
Stop option:
Session State Consistency: DYNAMIC
GSM Flags: 0
Service is enabled
Preferred instances: ORCL1,ORCL2
Available instances:
CSS critical: no

2. srvctl start service

At least 2 parameters should be added to the command to start the service.

[oracle@primary01 ~]$ srvctl start service -d orcl -s crm

srvctl status service

Then we check its status.

[oracle@primary01 ~]$ srvctl status service -d orcl -s crm
Service CRM is running on instance(s) ORCL1,ORCL2

As we can see, we started the service on both nodes.

Now we should check the statuses of both listeners.

lsnrctl status on Node 1

[oracle@primary01 ~]$ lsnrctl status
Service "CRM" has 1 instance(s).
  Instance "ORCL1", status READY, has 1 handler(s) for this service...

lsnrctl status on Node 2

[oracle@primary02 ~]$ lsnrctl status
Service "CRM" has 1 instance(s).
  Instance "ORCL2", status READY, has 1 handler(s) for this service...

The service is ready to accept connections.

3. srvctl stop service

If you want to remove service from the database, you have to stop it first. Otherwise, you will see PRCR-1025 error.

[oracle@primary01 ~]$ srvctl stop service -d orcl -s crm
[oracle@primary01 ~]$ srvctl status service -d orcl -s crm
Service CRM is not running.

4. srvctl remove service

We can remove the service once it's no longer used.

[oracle@primary01 ~]$ srvctl remove service -d orcl -s crm
[oracle@primary01 ~]$ srvctl config service -d orcl

There's nothing left. We have completed the life cycle of a database service by the above 4 steps.

In a multitenant environment, the service adding procedure for a pluggable databases (PDB) is almost the same. You may take a look.

Leave a Reply

Your email address will not be published. Required fields are marked *