144 DBMS_SERVICE
The DBMS_SERVICE
package lets you create, delete, activate, and deactivate services for a single instance.
The chapter contains the following topics:
-
Summary of DBMS_SERVICE Subprograms
See Also:
Oracle Real Application Clusters Administration and Deployment Guide for administering services in Oracle Real Application Clusters.
144.1 DBMS_SERVICE Overview
DBMS_SERVICE
supports the workload management of high availability, quality of service, job scheduling, and other planned operations in the RDBMS for the purposes of workload measurement, management, prioritization, and XA and distributed transaction management.
Oracle Real Application Clusters (RAC) can manage service names across instances as administered through SRVCTL
. The DBMS_SERVICE
package allows the creation, deletion, starting, and stopping of services in a single instance. Additionally, it provides the ability to disconnect all sessions that connect to an instance with a service name.
See Also:
For more information about Oracle Real Application Clusters, Oracle Real Application Clusters Administration and Deployment Guide.
144.2 DBMS_SERVICE Security Model
The DBMS_SERVICE
package has certain security requirements.
Privileges
The client using this package must have the ALTER
SYSTEM
execution privilege and the V$SESSION
table read privilege.
Schemas
This package must be installed under SYS
schema.
Roles
The EXECUTE
privilege of the package is granted to the DBA
role only.
144.3 DBMS_SERVICE Constants
The DBMS_SERVICE
package provides constants that can be used for specifying parameter values.
-
Constants used in calling arguments are described in Table 144-1
-
Constants used in connection balancing goal arguments are described in Table 144-2
-
Constants used in TAF failover attribute arguments are described in Table 144-3
Table 144-1 Constants Used in Calling Arguments
Name | Type | Value | Description |
---|---|---|---|
|
|
|
Disables Load Balancing Advisory |
|
|
|
Load Balancing Advisory is based on elapsed time for work done in the service plus available bandwidth to the service |
|
|
|
Load Balancing Advisory is based on the rate that work is completed in the service plus available bandwidth to the service |
Table 144-2 Constants Used in Connection Balancing Goal Arguments
Name | Type | Value | Description |
---|---|---|---|
|
|
|
Connection load balancing uses Load Balancing Advisory, when Load Balancing Advisory is enabled (either |
|
|
|
Balances the number of connections for each instance using session count for each service. This setting is recommended for applications with long connections such as forms. This setting can be used with Load Balancing Advisory when the connection pool is sized to accommodate gravitation within the pool itself (without adding or removing connections). The latter is the most efficient design. |
Table 144-3 Constants Used in High Availability Attribute Arguments for FAN, Application Continuity, Transaction Guard and TAF
Name | Type | Value | Description |
---|---|---|---|
|
|
|
Server side TAF is not enabled for this service |
|
|
|
|
|
|
Server side TAF type is |
|
|
|
Server side TAF failover type is |
|
|
|
Server side TAF failover type is |
|
|
|
Number of connection attempts when failover occurs. Specifies the number of times for Application Continuity and TAF to attempt the reconnect and re-authenticate pair. The value must be an integer greater than 0. The default in Oracle Database 12c Release 1 (12.1) for Application Continuity is 30. |
|
|
|
|
The initial state is not restored before replaying for Application Continuity and TAF. This is recommended for OCI applications that use Application Continuity and build their own state in the request. For example, SQLPLUS. |
|
|
|
This is the recommended value for Java and ODP.NET applications using Application Continuity. The initial states that the user knows are restored automatically before replaying. If the user needs additional states, a callback must be registered. |
|
|
Number of seconds delay between each connection attempt. This is the delay that Application Continuity and TAF waits if a reconnect and re-authentication fails. The value must be an integer greater than 0. The default in Oracle Database 12c Release 1 (12.1)is 10s when using Application Continuity. Using |
|
|
|
Sessions are not disconnected. |
|
|
|
Sessions are disconnected immediately after the |
|
|
Sessions are disconnected after the transactions during the |
||
|
|
For Application Continuity, this parameter specifies whether the session state that is not transactional is changed by the application during request execution. A value of |
Usage Notes
-
If a TAF callback has been registered, then the failover retries and failover delay are ignored. If an error occurs, TAF continues to re-attempt the connect and authentication as long as the callback returns a value of
OCI_FO_RETRY
. Any delay must be coded into the callback logic -
Server side TAF settings override client-side counterparts that might be configured in TNS connect descriptors. If TAF is not configured on the client side, then at a minimum, the failover type must be set to enable TAF. If the failover type is set on the server side, then the failover method defaults to
BASIC
. Delay and retries are optional and may be specified independently.
144.4 DBMS_SERVICE Operating Procedures
You cannot use the following procedures with Oracle Real Applications Clusterware, Oracle Restart, and Oracle Global Data Services.
-
With Oracle Database 12c release 1, you are advised to use the parameter interface in all service -related subprorgrams.
-
If you wish to use
DBMS_SERVICE
on a pluggable database (PDB) in a single instance, you must connect to that PDB first.
144.5 DBMS_SERVICE Exceptions
This table lists the exceptions raised by the DBMS_SERVICE
package.
Table 144-4 DBMS_SERVICE Exceptions
Exception | Error Code | Description |
---|---|---|
|
44301 |
Service name argument was found to be |
|
44302 |
Network name argument was found to be |
|
44303 |
Service name already exists |
|
44304 |
Specified service does not exist |
|
44305 |
Specified service was running |
|
44306 |
Service name was too long |
|
44307 |
Network name, excluding the domain, was too long |
|
44308 |
Services layer was not yet initialized |
|
44309 |
An unknown failure |
|
44310 |
Maximum number of services has been reached |
|
44311 |
Specified service was not running |
|
44312 |
Database was closed |
|
44313 |
Instance name argument was not valid |
|
44314 |
Network name already exists |
|
44315 |
All attributes specified were |
|
44316 |
Invalid argument supplied |
|
44317 |
Database is open read-only |
|
44318 |
Total length of all running service network names exceeded the maximum allowable length |
|
44319 |
Cannot delete AQ service |
|
44320 |
Cannot delete global service |
|
44771 |
Invalid name for a pluggable database |
|
44772 |
Cluster ready services (CRS) operation failed |
|
44773 |
Cannot perform requested service operation |
|
44774 |
Pluggable database attribute cannot be changed |
|
44775 |
Pluggable database service cannot be created |
|
44776 |
Pluggable database service cannot be deleted |
|
44777 |
Pluggable database service cannot be started |
144.6 Summary of DBMS_SERVICE Subprograms
This table lists the DBMS_SERVICE
subprograms and briefly describes them.
Table 144-5 DBMS_SERVICE Package Subprograms
Subprogram | Description |
---|---|
Creates service |
|
Deletes service |
|
Disconnects sessions running under this service |
|
Modifies service |
|
Activates service |
|
Stops service |
144.6.1 CREATE_SERVICE Procedure
This procedure creates a service name in the data dictionary. Services are also created in the data dictionary implicitly when you set the service in the service_name
parameter or by means of the ALTER
SYSTEM
SET
SERVICE_NAMES
command.
Note:
You cannot use the second version of subprogram if your services are managed by Oracle Clusterware, Oracle Restart or Oracle Global Data Services. The version with the parameter array interface applies to databases that are not managed by Oracle Clusterware, Oracle Restart or Oracle Global Data Services. New attributes are only available using the parameter interface.
Syntax
DBMS_SERVICE.CREATE_SERVICE( service_name IN VARCHAR2, network_name IN VARCHAR2, parameter_array IN TABLE OF VARCHAR2(100));
This overload is maintained for backward compatibility:
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);
Parameters
Table 144-6 CREATE_SERVICE Procedure Parameters
Parameter | Description |
---|---|
|
Name of the service, limited to 64 characters in the Data Dictionary |
|
Network name of the service as used in SQLNet connect descriptors for client connections. This is limited to the NET |
|
Associative array with name-value pairs of the service attributes. Supported names:
|
|
Workload management goal directive for the service. Valid values:
|
|
Declares the service to be for X/Open Distributed Transaction Processing (DTP) or any distributed transaction (especially XA) |
|
Determines whether Fast Application Notification (FAN) is enabled for OCI/OCCI/ODP. In Oracle Database12c, FAN uses Oracle Notification Services (ONS). This parameter is still used to enable FAN. FAN is recommended for all High Availability systems, and is on by default for Application Continuity |
|
Failover |
|
|
|
Number of connection retries for Application Continuity and TAF. Using the |
|
Delay in seconds between connection retries for Application Continuity and TAF. The default is 10 seconds for Application Continuity. Do not use a 0-second delay if the service needs time to failover and register. Long delays are good for planned outages and to failover to Data Guard. Short delays work well with RAC when the service is already available. |
|
If this argument has a non- During service creation or modification, no validation is performed on this parameter. At connection time, if the connecting user does not have |
|
If this parameter is defined, all sessions connected to that service are drained by the client drivers and pools using Fast Connection Failover (FCF). The |
|
Provides options to terminate a session. The supported values are:
However, these parameter values can be overridden using the command line. |
|
Determines whether transaction
|
|
Used in conjunction with |
|
For Application Continuity, |
|
Describes how nontransactional is changed during a request (values are |
|
Name of SQL translation unit |
|
Method used for Connection Load Balancing (see Table 144-2) |
Examples
DBMS_SERVICE.CREATE_SERVICE('ernie.example.com','ernie.example.com'); DECLARE params dbms_service.svc_parameter_array; BEGIN params('FAILOVER_TYPE') :='TRANSACTION'; params('REPLAY_INITIATION_TIMEOUT'):=1800; params('RETENTION_TIMEOUT') :=86400; params('FAILOVER_DELAY') :=10; params('FAILOVER_RETRIES') :=30; params('DRAIN_TIMEOUT') :=60; params('STOP_OPTION') :='DBMS_SERVICE.STOP_OPTION_IMMEDIATE'; params('FAILOVER_RESTORE') :='DBMS_SERVICE.FAILOVER_RESTORE_BASIC'; params('commit_outcome') :='true'; params('aq_ha_notifications') :='true'; DBMS_SERVICE.MODIFY_SERVICE('GOLD',params); END;
144.6.2 DELETE_SERVICE Procedure
This procedure deletes a service from the data dictionary.
Note:
You cannot use this subprogram if your services are managed by Oracle Clusterware, Oracle Restart, or Oracle Global Data Services.
Syntax
DBMS_SERVICE.DELETE_SERVICE( service_name IN VARCHAR2);
Parameters
Table 144-7 DELETE_SERVICE Procedure Parameters
Parameter | Description |
---|---|
|
Name of the service, limited to 64 characters in the Data Dictionary |
Examples
DBMS_SERVICE.DELETE_SERVICE('ernie.example.com');
144.6.3 DISCONNECT_SESSION Procedure
This procedure disconnects sessions with the named service at the current instance.
Syntax
DBMS_SERVICE.DISCONNECT_SESSION( service_name IN VARCHAR2, disconnect_option IN NUMBER DEFAULT POST_TRANSACTION;
Parameters
Table 144-8 DISCONNECT_SESSION Procedure Parameters
Parameter | Description |
---|---|
|
Name of the service, limited to 64 characters in the Data Dictionary |
|
The options, package constants, are expressed as
Note: |
Usage Notes
-
This procedure can be used in the context of a single instance as well as with Oracle Real Application Clusters.
-
This subprogram does not return until all corresponding sessions are disconnected. Therefore, use the
DBMS_JOB
package or put the SQL session in background if the caller does not want to wait for all corresponding sessions to be disconnected.
Examples
This disconnects sessions with service_name
'ernie.example.com'
.
DBMS_SERVICE.DISCONNECT_SESSION('ernie.example.com');
If a service is using application continuity, and you do not want the sessions replayed but simply terminated, use the following:
EXECUTE DBMS_SERVICE.DISCONNECT_SESSION('service name', DBMS_SERVICE.NOREPLAY);
144.6.4 MODIFY_SERVICE Procedure
This procedure modifies an existing service.
Note:
You cannot use the second version of subprogram if your services are managed by Oracle Clusterware, Oracle Restart, or Oracle Global Data Services. The version with the parameter array interface applies to databases that are not managed by Oracle Clusterware, Oracle Restart or Oracle Global Data Services. New attributes are only available using the parameter interface.
Syntax
DBMS_SERVICE.MODIFY_SERVICE( service_name IN VARCHAR2, parameter_array IN svc_parameter_array);
This overload is maintained for backward compatibility:
DBMS_SERVICE.MODIFY_SERVICE( service_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, modify_edition IN BOOLEAN DEFAULT FALSE;
Parameters
Table 144-9 MODIFY_SERVICE Procedure Parameters
Parameter | Description |
---|---|
|
Name of the service, limited to 64 characters in the Data Dictionary |
|
Associative array with name/value pairs of the service attributes. Supported names:
|
|
Workload management goal directive for the service. Valid values:
|
|
Declares the service to be for X/Open Distributed Transaction Processing (DTP) or any distributed transaction (especially XA) |
|
Determines whether Fast Application Notification (FAN) is enabled for OCI/OCCI/ODP. In Oracle Database12c, FAN uses Oracle Notification Services (ONS). This parameter is still used to enable FAN. FAN is recommended for all High Availability systems, and is on by default for Application Continuity |
|
Failover |
|
Failover |
|
For Application Continuity, when the For AC OCI, use |
|
Number of connection retries for Application Continuity and TAF. Using the |
|
Delay in seconds between connection retries for Application Continuity and TAF. The default is 10 seconds for Application Continuity. Do not use a 0-second delay if the service needs time to failover and register. Long delays are good for planned outages and to failover to Data Guard. Short delays work well with Oracle RAC when the service is already available. |
|
When this parameter is set, all sessions connected to that service are drained by the client drivers and pools using Fast Connection Failover (FCF). The |
|
If this argument has a non- During service creation or modification, no validation is performed on this parameter. At connection time, if the connecting user does not have |
|
Determines whether transaction
|
|
Used in conjunction with |
|
For Application Continuity, |
|
Describes how nontransactional is changed during a request (values are |
|
Name of SQL translation unit |
|
If |
|
Method used for Connection Load Balancing (see Table 144-2) |
Usage Notes
-
If you are using Clustered Managed Services with Oracle Clusterware, or using Oracle Restart with your single instance database, you must modify services using the
srvctl
command rather thanDBMS_SERVICE
. When the service is started by Oracle Clusterware or Oracle Restart, the service is modified in the database to match the resource defined to either Oracle Clusterware or Oracle Restart. Any changes made withDBMS_SERVICE
are lost unless they are also made with the correspondingsrvctl
command. Starting with 11.2.0.2, service attribute modifications take effect immediately when the service is started or modified bysrvctl
. -
Although users can modify the edition attribute while the service is up and running, it may not be safe to do so. Users must proceed with caution because this causes new connections to be connected at the new edition, while the existing connection is not affected. This can cause mid-tier operations to connect to the wrong edition.
144.6.5 START_SERVICE Procedure
This procedure starts a service. In Oracle RAC, implementing this option acts on the instance specified.
Note:
You cannot use this subprogram if your services are managed by Oracle Clusterware, Oracle Restart or Oracle Global Data Services.
Syntax
DBMS_SERVICE.START_SERVICE( service_name IN VARCHAR2, instance_name IN VARCHAR2);
Parameters
Table 144-10 START_SERVICE Procedure Parameters
Parameter | Description |
---|---|
|
Name of the service limited to 64 characters in the Data Dictionary |
|
Name of the instance where the service must be activated (optional). |
Examples
DBMS_SERVICE.START_SERVICE('ernie.example.com');
144.6.6 STOP_SERVICE Procedure
This procedure stops a service.
Note:
You cannot use this subprogram if your services are managed by Oracle Clusterware, Oracle Restart or Oracle Global Data Services.
Syntax
DBMS_SERVICE.STOP_SERVICE( service_name IN VARCHAR2, instance_name IN VARCHAR2;
Parameters
Table 144-11 STOP_SERVICE Procedure Parameters
Parameter | Description |
---|---|
|
Name of the service limited to 64 characters in the Data Dictionary |
|
Name of the instance where the service must be stopped (optional). |
|
The time in seconds for the session to drain. |
|
To specify how sessions are stopped with draining. The possible values are as follows:
These values can be overridden on the command line using |
|
Disconnected sessions are not recovered by Application Continuity. |
Examples
DBMS_SERVICE.STOP_SERVICE('ernie.example.com');