Summary of dbms_service subprograms
Table 130-5 dbms_service package subprograms
| Subprogram |
Description |
Create_service procedure |
Creates Service |
Delete_service procedure |
Deletes Service |
Disconnect_session procedure |
Disconnects Service |
Modify_service procedure |
Modifies Service |
Start_service procedure |
Activates Service |
Stop_service procedure |
Stops Service |
1. Use dbms_service to create service resources
Syntax
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);
--The network name of the service as used in SQLNet connect descriptors for client connections. This is limited to the NET service_names character set (see Oracle Database Net Services Reference).
Example:
set linesize 200 col name for a20 col network_name for a20
BeginDBMS_SERVICE.CREATE_SERVICE(service_name=>'ractest3',
network_name=>'ractest3',
failover_method=>dbms_service.failover_method_basic,
failover_type=>dbms_service.failover_type_select,
failover_retries=>180,
failover_delay=>5);
end;
/
When you create a service resource using the dbms_service stored procedure, you cannot know the list of preferred nodes and slave nodes of the service, because these attributes are managed and controlled by clusterware.
2. Use dbms_service to modify service resources
begin
DBMS_SERVICE.MODIFY_SERVICE(service_name=>'ractest3',
failover_method=>dbms_service.failover_method_basic,
failover_method=>dbms_service.failover_type_session);
end;
/
3. Use dbms_service to start service resources
begin
DBMS_SERVICE.START_SERVICE(service_name=>'ractest3',instance_name=>'rac1');
end;
/
After starting a service resource using the preceding method, you can view the service status as follows:
[oracle@rac1 admin]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-AUG-2013 22:27:11Copyright (c) 1991, 2011, Oracle. All rights reserved.Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date 14-AUG-2013 19:59:06Uptime 0 days 2 hr. 28 min. 5 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/11.2.0/grid/network/admin/listener.oraListener Log File /u01/app/grid/diag/tnslsnr/rac1/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.21)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.11)(PORT=1521)))Services Summary...Service "+ASM" has 1 instance(s). Instance "+ASM1", status READY, has 1 handler(s) for this service...Service "rac" has 1 instance(s). Instance "rac1", status READY, has 1 handler(s) for this service...Service "racXDB" has 1 instance(s). Instance "rac1", status READY, has 1 handler(s) for this service...Service "ractest3" has 1 instance(s). Instance "rac1", status READY, has 1 handler(s) for this service...The command completed successfully
SQL> select * from gv$services where name='ractest3'; INST_ID SERVICE_ID NAME NAME_HASH NETWORK_NAME CREATION_DATE CREATION_DATE_HASH GOAL D AQ_ CLB_G---------- ---------- ---------- ---------- -------------------- ------------------- ------------------ ------------ - --- ----- 1 7 ractest3 3415106618 ractest3 2013-08-14 22:12:02 2590462208 NONE N NO LONG
4. Use dbms_service to stop service resources
begin
DBMS_SERVICE.STOP_SERVICE(service_name=>'ractest3',instance_name=>'rac1');
end;
/
[oracle@rac1 admin]$ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-AUG-2013 22:32:09Copyright (c) 1991, 2011, Oracle. All rights reserved.Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 11.2.0.3.0 - ProductionStart Date 14-AUG-2013 19:59:06Uptime 0 days 2 hr. 33 min. 3 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/11.2.0/grid/network/admin/listener.oraListener Log File /u01/app/grid/diag/tnslsnr/rac1/listener/alert/log.xmlListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.21)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.11)(PORT=1521)))Services Summary...Service "+ASM" has 1 instance(s). Instance "+ASM1", status READY, has 1 handler(s) for this service...Service "rac" has 1 instance(s). Instance "rac1", status READY, has 1 handler(s) for this service...Service "racXDB" has 1 instance(s). Instance "rac1", status READY, has 1 handler(s) for this service...The command completed successfully
5. Use dbms_service to delete service resources
begin
DBMS_SERVICE.DELETE_SERVICE(service_name=>'ractest3');
end;
/
SQL> begin 2 DBMS_SERVICE.DELETE_SERVICE(service_name=>'ractest3'); 3 end; 4 /PL/SQL procedure successfully completed.SQL> select * from gv$services where name='ractest3';no rows selected
Note: The service resources created using the dbms_service package cannot be registered to OCR. Therefore, you cannot use tools such as srvctl to perform operations that do not exist.
Resources are managed. When the RAC node fails, these resources cannot be failover with the VIP to the surviving node.
Srvctl manages services and clusterware's high availability switch over services are implemented by calling the dbms_service package based on certain rules.
For reprinting, please indicate the author's source and original article links; otherwise, you will be held legally responsible:
Author: xiangsir
Link: http://blog.csdn.net/xiangsir/article/details/9973037
QQ: 444367417
MSN: xiangsir@hotmail.com