oracle中的service管理(12C)


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

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號第一次書寫

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM