Oracle Service Names

(一)概述

Service是Oracle管理负载的一个抽象概念,通过service把整个负载分成不同的组,每个service代表具有相同属性,服务级别阈值和优先级的一类工作负载

Database services (services) are logical abstractions for managing workloads in Oracle Database. Services divide workloads into mutually disjoint不相干的 groupings. Each service represents a workload with common attributes, service-level thresholds, and priorities.

服务信息存于数据字典

The services are tightly integrated with Oracle Database and are maintained in the data dictionary.
一个service可以表示同一数据库下一个或多个实例的集合,而一个实例可同时属于多个服务。数据库创建的SERVICE会动态注册到监听,用户通过SERVICE来连接数据库,而不需要知道连接的实例名

The service name is included in the connect data part of the connect descriptor. When an instance starts, it registers itself with a listener using one or more service names. When a client program or database connects to a listener, it requests a connection to a service.

A service name can identify multiple database instances, and an instance can belong to multiple services. Clients connecting to a service need not specify which instance they require.

Associating multiple services with one database enables the following functionality:

  1. A single database can be identified different ways by different clients.
  2. A database administrator can limit or reserve system resources. This level of control enables better allocation of resources to clients requesting one of the services.

下图为RAC中每个实例设置不同service name来接收不同类型负载请求

  • 使用SERVICE

有两种方式使用ORACLE SERVICE:

如果你没有使用Oracle Restart或RAC,你需要使用DBMS_SERVICE

如果你使用了Oracle Restart或RAC,不要使用DBMS_SERVICE而是SRVCTL

SERVICE属性有很多不清楚,用时再看吧

You can create, modify, or remove a service in the following ways:

  1. If your single-instance database is being managed by Oracle Restart or your Oracle RAC database is being managed by Oracle Clusterware, then use the Server Control (SRVCTL) utility to create, modify, or remove the service.

To create a service for a PDB using the SRVCTL utility, use the add service command and specify the PDB in the -pdb parameter. If you do not specify a PDB in the -pdb parameter when you create a service, then the service is associated with the root.

You can use other SRVCTL commands to manage the service, such as the start service and stop service commands, even if they do not include the -pdb parameter.

  1. If your database is not being managed by Oracle Restart or Oracle Clusterware, then use the DBMS_SERVICE package to create or remove a database service.

To create a service with a PDB property set to a specific PDB using the DBMS_SERVICE package, run the CREATE_SERVICE procedure when the current container is that PDB. If you create a service using the CREATE_SERVICE procedure when the current container is the root, then the service is associated with the root.

You cannot modify the PDB property of a service with the DBMS_SERVICE package. However, you can remove a service in one PDB and create a similar service in a different PDB. In this case, the new service has the PDB property of the PDB in which it was created.

You can also use other DBMS_SERVICE subprograms to manage the service, such as the START_SERVICE and STOP_SERVICE procedures. Use the DELETE_SERVICE procedure to remove a service.

Note: If your database is being managed by Oracle Restart or Oracle Clusterware, then use the SRVCTL utility to manage services. Do not use the DBMS_SERVICE package.

  1. 使用SRVCTL管理SERVICE:    ------看RAC时再看!!!!!!!

Creating a Service for a PDB Using the SRVCTL Utility

This example adds the salesrep service for the PDB salespdb in the CDB with DB_UNIQUE_NAME mycdb:

srvctl add service -db mycdb -service salesrep -pdb salespdb

Modifying the PDB Property of a Service Using the SRVCTL Utility

This example modifies the salesrep service in the CDB with DB_UNIQUE_NAME mycdb to associate the service with the hrpdb PDB:

$ srvctl modify service -db mycdb -service salesrep -pdb hrpdb

Removing a Service Using the SRVCTL Utility

$ srvctl remove service -db mycdb -service salesrep

  1. 使用DBMS_SERVICE Package

SQL> EXEC DBMS_SERVICE.CREATE_SERVICE(service_name => 'hr', network_name => 'hr');

SQL> EXEC DBMS_SERVICE.START_SERVICE(service_name => 'hr');

SQL> EXEC DBMS_SERVICE.DISCONNECT_SESSION(

service_name => 'hr', disconnect_option=>DBMS_SERVICE.NOREPLAY);

SQL> EXEC DBMS_SERVICE.STOP_SESSION(service_name => 'hr');

SQL> Exec DBMS_SERVICE.DELETE_SERVICE('hr');

还有DBMS_SERVICE.MODIFY_SERVICE,但SERVICE属性太多不清楚什么意思,有时间再看

  1. 关于参数service_names

PDB是无法更改SERVICE_NAMES参数的,即此方法配置服务只能用于CDB$ROOT.

使用ALTER SYSTEM SET SERVICE_NAMES会隐式在数据字典创建service,并自动开始此服务,可以使用dbms_service或srvctl来start/stop/modify/disconnect更改此服务,但不能删除它。

  • 相关视图

SERVICE很多属性不清楚什么意思,下面只列了常用的

  1. CDB_SERVICES

NETWORK_NAME:表示SERVICE_NAME注册到监听的监听服务名,用于用户连接

SET LINESIZE 200

COL NAME FORMAT A30

COL NETWORK_NAME FORMAT A30

COL PDB FORMAT A30

SELECT NAME, NETWORK_NAME, PDB FROM CDB_SERVICES;

SELECT NAME, NETWORK_NAME, FAILOVER_METHOD, FAILOVER_TYPE, FAILOVER_RETRIES, FAILOVER_DELAY FROM CDB_SERVICES;

  1. Select NAME,NETWORK_NAME from V$ACTIVE_SERVICES;

SET LINESIZE 200

COL NAME FORMAT A30

COL NETWORK_NAME FORMAT A30

COL CON_NAME FORMAT A30

SELECT CON_NAME, NAME, NETWORK_NAME, BLOCKED FROM V$ACTIVE_SERVICES;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值