The DBMS_SERVICE
package lets you create, delete, activate, and deactivate services for a single instance.
The chapter contains the following topics:
Overview
Security Model
Constants
Operating Procedures
Exceptions
Summary of DBMS_SERVICE Subprograms
See Also:
Oracle Real Application Clusters Administration and Deployment Guide for administering services in Oracle Real Application Clusters.This section contains topics that relate to using the DBMS_SERVICE
package.
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.The client using this package must have the ALTER
SYSTEM
execution privilege and the V$SESSION
table read privilege.
This package must be installed under SYS
schema.
The EXECUTE
privilege of the package is granted to the DBA
role only.
The DBMS_SERVICE
package uses the constants shown in following tables:
Constants used in calling arguments are described in Table 142-1, "Constants Used in Calling Arguments"
Constants used in connection balancing goal arguments are described in Table 142-2, "Constants Used in Connection Balancing Goal Arguments"
Constants used in TAF failover attribute arguments are described in Table 142-3, "Constants Used in High Availability Attribute Arguments for FAN, Application Continuity, Transaction Guard and TAF"
Table 142-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 142-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 142-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. |
|
|
|
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 |
|
|
|
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 |
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.
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.
The following table lists the exceptions raised by DBMS_SERVICE
package.
Table 142-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 |
Table 142-5 DBMS_SERVICE Package Subprograms
Subprogram | Description |
---|---|
Creates service |
|
Deletes service |
|
Disconnects sessions running under this service |
|
Modifies service |
|
Activates service |
|
Stops service |
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.DBMS_SERVICE.CREATE_SERVICE( service_name IN VARCHAR2, network_name IN VARCHAR2, parameter_array IN svc_parameter_array);
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);
Table 142-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 |
|
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 |
|
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 142-2, "Constants Used in Connection Balancing Goal Arguments") |
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('commit_outcome') :='true'; params('aq_ha_notifications') :='true'; DBMS_SERVICE.MODIFY_SERVICE('GOLD',params); END;
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.This procedure disconnects sessions with the named service at the current instance.
DBMS_SERVICE.DISCONNECT_SESSION( service_name IN VARCHAR2, disconnect_option IN NUMBER DEFAULT POST_TRANSACTION);
Table 142-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: |
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.
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);
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.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;
Table 142-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 |
|
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 |
|
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 142-2, "Constants Used in Connection Balancing Goal Arguments") |
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 than DBMS_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 with DBMS_SERVICE
are lost unless they are also made with the corresponding srvctl
command. Starting with 11.2.0.2, service attribute modifications take effect immediately when the service is started or modified by srvctl
.
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.
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.Table 142-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). |
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.Table 142-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). |