oracle中的service理解

1.sevice概念是什么时候开始出现的呢?

oracle从10g开始引入service的概念,按照个人理解service就是数据库管理工作负载的一种方式。

2.service具体的作用是什么呢?

假设一个数据库上既要运行批量作业,也要运行联机交易,那如何去管理这两种类型的数据库任务呢,而数据库默认只提供了一个连接方式,那怎么去统计这两种任务的负载呢?因此也就引入了service的概念,即可以在数据库中创建不同的服务,创建的服务既可以指定运行在单个实例上,也可以运行在多个实例上,这样不同的任务就可以通过不同的服务连接到数据库,从而实现对不同类型的任务管理,我们在awr中也经常见到有过servce的相关统计信息。但是根据我的观察,很多公司在实际环境中,并没有做这么方面的工作,一般都是通过数据库提供的默认service连接到数据库。

3.在12C数据库上如何创建、启动、停止、删除服务?

  • 创建多边服务(两个节点同时能提供服务)

************** 添加服务 ************** [oracle@12c1 ~]$ srvctl add service -d racdb -s racdb_test -pdb dayupdb1 -P BASIC -q TRUE -e SESSION -m BASIC -role PRIMARY -r racdb1,racdb2
<具体命令比较长,所以我们要学会使用help,help里有比较详细的参数解释。>
*************** 启动服务 *************** [oracle@12c1 ~]$ srvctl start service -d racdb -s racdb_test *************** 查看监听 *************** [oracle@12c1 ~]$ lsnrctl status LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 18-AUG-2018 22:02:26 Copyright (c) 1991, 2014, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production Start Date 18-AUG-2018 19:35:40 Uptime 0 days 2 hr. 26 min. 46 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/12.1.0/grid/network/admin/listener.ora Listener Log File /u01/app/grid/diag/tnslsnr/12c1/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.100)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.101)(PORT=1521))) Services Summary... Service "+ASM" has 1 instance(s). Instance "+ASM1", status READY, has 1 handler(s) for this service... Service "-MGMTDBXDB" has 1 instance(s). Instance "-MGMTDB", status READY, has 1 handler(s) for this service... Service "_mgmtdb" has 1 instance(s). Instance "-MGMTDB", status READY, has 1 handler(s) for this service... Service "dayupdb1" has 1 instance(s). Instance "racdb1", status READY, has 1 handler(s) for this service... Service "r12c_cluster" has 1 instance(s). Instance "-MGMTDB", status READY, has 1 handler(s) for this service... Service "racdb" has 1 instance(s). Instance "racdb1", status READY, has 1 handler(s) for this service... Service "racdbXDB" has 1 instance(s). Instance "racdb1", status READY, has 1 handler(s) for this service... Service "racdb_test" has 1 instance(s). Instance "racdb1", status READY, has 1 handler(s) for this service... The command completed successfully [grid@12c1 ~]$ crsctl stat res -t -------------------------------------------------------------------------------- Name Target State Server State details -------------------------------------------------------------------------------- Local Resources -------------------------------------------------------------------------------- ora.DATA.dg ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.LISTENER.lsnr ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.MGMT.dg ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.OCR.dg ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.asm ONLINE ONLINE 12c1 Started,STABLE ONLINE ONLINE 12c2 Started,STABLE ora.net1.network ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.ons ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE -------------------------------------------------------------------------------- Cluster Resources -------------------------------------------------------------------------------- ora.12c1.vip 1 ONLINE ONLINE 12c1 STABLE ora.12c2.vip 1 ONLINE ONLINE 12c2 STABLE ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE 12c1 STABLE ora.MGMTLSNR 1 ONLINE ONLINE 12c1 169.254.219.15 10.16 8.8.100,STABLE ora.cvu 1 ONLINE ONLINE 12c2 STABLE ora.mgmtdb 1 ONLINE ONLINE 12c1 Open,STABLE ora.oc4j 1 ONLINE ONLINE 12c2 STABLE ora.rac.db 1 OFFLINE OFFLINE STABLE ora.racdb.db 1 ONLINE ONLINE 12c1 Open,STABLE 2 ONLINE ONLINE 12c2 Open,STABLE ora.racdb.racdb_test.svc 1 ONLINE ONLINE 12c1 STABLE 2 ONLINE ONLINE 12c2 STABLE ora.scan1.vip 1 ONLINE ONLINE 12c1 STABLE --------------------------------------------------------------------------------
  • 创建单边服务(指定到单节点):

[oracle@12c1 ~]$ srvctl add service -db racdb -service racdb_test1 -preferred "racdb1" -available "racdb2" -failovermethod basic -failovertype SESSION -failoverretry 10 -failoverdelay 3 -clbgoal SHORT -rlbgoal THROUGHPUT -tafpolicy BASIC [grid@12c1 ~]$ crsctl stat res -t -------------------------------------------------------------------------------- Name Target State Server State details -------------------------------------------------------------------------------- Local Resources -------------------------------------------------------------------------------- ora.DATA.dg ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.LISTENER.lsnr ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.MGMT.dg ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.OCR.dg ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.asm ONLINE ONLINE 12c1 Started,STABLE ONLINE ONLINE 12c2 Started,STABLE ora.net1.network ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE ora.ons ONLINE ONLINE 12c1 STABLE ONLINE ONLINE 12c2 STABLE -------------------------------------------------------------------------------- Cluster Resources -------------------------------------------------------------------------------- ora.12c1.vip 1 ONLINE ONLINE 12c1 STABLE ora.12c2.vip 1 ONLINE ONLINE 12c2 STABLE ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE 12c1 STABLE ora.MGMTLSNR 1 ONLINE ONLINE 12c1 169.254.219.15 10.16 8.8.100,STABLE ora.cvu 1 ONLINE ONLINE 12c2 STABLE ora.mgmtdb 1 ONLINE ONLINE 12c1 Open,STABLE ora.oc4j 1 ONLINE ONLINE 12c2 STABLE ora.rac.db 1 OFFLINE OFFLINE STABLE ora.racdb.db 1 ONLINE ONLINE 12c1 Open,STABLE 2 ONLINE ONLINE 12c2 Open,STABLE ora.racdb.racdb_test.svc 1 ONLINE ONLINE 12c1 STABLE 2 ONLINE ONLINE 12c2 STABLE ora.racdb.racdb_test1.svc 1 ONLINE ONLINE 12c1 STABLE ora.scan1.vip 1 ONLINE ONLINE 12c1 STABLE

(关于这种服务的创建方式,说些题外话,前些日子晚上在支持ABC客户做service的相关变更时,因为没有指定相应的pdb名字导致服务起来后用户并不能连接,最终废了很大的周折才将问题解决,希望以此为戒。)

  • 启动、停止、删除服务
********************
停止服务
********************
[oracle@12c1 ~]$ srvctl stop service -d racdb -s racdb_test
********************
打开服务
********************
[oracle@12c1 ~]$ srvctl start service -d racdb -s racdb_test
********************
删除服务
********************
srvctl remove service -d racdb -s racdb_test
********************
查看服务状态
********************

  [oracle@12c1 ~]$ srvctl status service -d racdb
  Service racdb_test is running on instance(s) racdb1,racdb2
  Service racdb_test1 is not running.
  Service racdb_test2 is running on instance(s) racdb2

  [oracle@12c1 ~]$ srvctl status service -d racdb -s racdb_test1
  Service racdb_test1 is running on instance(s) racdb1
  [oracle@12c1 ~]$ srvctl status service -d racdb -s racdb_test
  Service racdb_test is running on instance(s) racdb1,racdb2

 

附一:offical document

扫描二维码关注公众号,回复: 2858659 查看本文章

Oracle Database 10g introduced an automatic workload management facility, called services. A service represents the workload of applications with common attributes, performance thresholds, and priorities. A single service can represent an application, multiple applications or a subset of a single application. A single service can be associated with one or more instances of an Oracle RAC database, and a single instance can support multiple services. Services provide the following benefits:

  • A single entity for managing applications that compete for the same resources

  • Allow each workload to be managed as a single unit

  • Hide the complexity of the cluster from the client

To manage workloads, you can define services that you assign to a particular application or to a subset of an application's operations. You can also use services to manage the workload for different types of work. For example, online users can use one service while batch processing can use a different service and reporting can use yet another service type.

Traditionally an Oracle database provided a single service and all users connected to the same service. A database will always have this default database service that is the database name. This service cannot be modified and will always allow you to connect to the database.

Note:

Do not use the default database service for application workloads. Create at least one service as described in  "Creating Services".

When a user or application connects to a database, Oracle recommends that you use a service for the connection. Applications and mid-tier connection pools select a service by using the service name in their connection data. For more flexibility in the management of the workload using the database, Oracle Database enables you to create multiple services and specify which database instances offer the services.

Services are integrated with the Database Resource Manager, which enables you to restrict the resources that are used by a service within an instance. In addition, Oracle Scheduler jobs can run using a service, as opposed to using a specific instance.

附二:add service help

Adds a service configuration to the Oracle Clusterware.

Usage: srvctl add service -db <db_unique_name> -service <service_name> {-preferred "<preferred_list>" [-available "<available_list>"] [-tafpolicy {BASIC | NONE | PRECONNECT}] | -serverpool <pool_name> [-cardinality {UNIFORM | SINGLETON}] } [-netnum <network_number>] [-role "[PRIMARY][,PHYSICAL_STANDBY][,LOGICAL_STANDBY][,SNAPSHOT_STANDBY]"] [-policy {AUTOMATIC | MANUAL}] [-notification {TRUE|FALSE}] [-dtp {TRUE|FALSE}] [-clbgoal {SHORT|LONG}] [-rlbgoal {NONE|SERVICE_TIME|THROUGHPUT}] [-failovertype {NONE|SESSION|SELECT|TRANSACTION}] [-failovermethod {NONE|BASIC}] [-failoverretry <failover_retries>] [-failoverdelay <failover_delay>] [-edition <edition>] [-pdb <pluggable_database>] [-global {TRUE|FALSE}] [-maxlag <max_lag_time>] [-sql_translation_profile <sql_translation_profile>] [-commit_outcome {TRUE|FALSE}] [-retention <retention>] [-replay_init_time <replay_initiation_time>] [-session_state {STATIC|DYNAMIC}] [-pqservice <pq_service>] [-pqpool <pq_pool_list>] [-gsmflags <gsm_flags>] [-force] [-eval] [-verb]
    -db <db_unique_name>           Unique name for the database
    -service <service>             Service name
    -preferred "<preferred_list>"  Comma separated list of preferred instances
    -available "<available_list>"  Comma separated list of available instances
    -serverpool <pool_name>        Server pool name
    -cardinality                   (UNIFORM | SINGLETON) Service runs on every active server in the server pool hosting this service (UNIFORM) or just one server (SINGLETON)
    -netnum  <network_number>      Network number (default number is 1)
    -tafpolicy                     (NONE | BASIC | PRECONNECT)        TAF policy specification
    -role <role>                   Role of the service (primary, physical_standby, logical_standby, snapshot_standby)
    -policy <policy>               Management policy for the service (AUTOMATIC or MANUAL)
    -failovertype                  (NONE | SESSION | SELECT | TRANSACTION)      Failover type
    -failovermethod                (NONE | BASIC)     Failover method
    -failoverdelay <failover_delay> Failover delay (in seconds)
    -failoverretry <failover_retries> Number of attempts to retry connection
    -edition <edition>             Edition (or "" for empty edition value)
    -pdb <pluggable_database>      Pluggable database name
    -maxlag <maximum replication lag> Maximum replication lag time in seconds (Non-negative integer, default value is 'ANY')
    -clbgoal                       (SHORT | LONG)                   Connection Load Balancing Goal. Default is LONG.
    -rlbgoal                       (SERVICE_TIME | THROUGHPUT | NONE)     Runtime Load Balancing Goal
    -dtp                           (TRUE | FALSE)  Distributed Transaction Processing
    -notification                  (TRUE | FALSE)  Enable Fast Application Notification (FAN) for OCI connections
    -global <global>               Global attribute (TRUE or FALSE)
    -preferred <new_pref_inst>     Name of new preferred instance
    -available <new_avail_inst>    Name of new available instance
    -sql_translation_profile <sql_translation_profile> Specify a database object for SQL translation profile
    -commit_outcome                (TRUE | FALSE)          Commit outcome
    -retention <retention>         Specifies the number of seconds the commit outcome is retained
    -replay_init_time <replay_init_time> Seconds after which replay will not be initiated
    -session_state <session_state> Session state consistency (STATIC or DYNAMIC)
    -pqservice <pq_service>        Parallel query service name
    -pqpool <pq_pool>              Parallel query server pool name
    -gsmflags <gsm_flags>          Set locality and region failover values
    -eval                          Evaluates the effects of event without making any changes to the system
Usage: srvctl add service -db <db_unique_name> -service <service_name> -update {-preferred "<new_pref_inst>" | -available "<new_avail_inst>"} [-force] [-verbose]
    -db <db_unique_name>           Unique name for the database
    -service <service>             Service name
    -update                        Add a new instance to service configuration
    -preferred <new_pref_inst>     Name of new preferred instance
    -available <new_avail_inst>    Name of new available instance
    -force                         Force the add operation even though a listener is not configured for a network
    -verbose                       Verbose output
    -help                          Print usage

PS:2018年8月19号第一次书写

猜你喜欢

转载自www.cnblogs.com/dayu-liu/p/9501732.html