Oracle 12C Service

目标

该文档介绍Service的特性以及Service的管理。

概述

Oracle Service 向客户端提供一个统一的服务名,Service位置透明,一个Service能定义多个数据库实例,一个数据库实例可以属于多个Service。Oracle Service 服务分为默认服务和自定义的集群管理服务。默认服务定义为DB_UNIQUE_NAME or DB_NAME or PDB_NAME,SYS$BACKGROUND(后台进程使用)和 SYS$USERS (默认用户session),Oracle默认服务oracle内部管理,不能被禁用,不能被计划停止服务,不能故障转移到ORACLE DATA GUARD。Oracle强烈建议不要使用默认Service给client提供服务,但是我遇到的几乎所有在运数据库使用默认Service向外提供服务,这样配置使用好像也没存在性能问题,故障转移负载均衡一切运作正常。

那为什么Oracle强力建议使用自定义Service向客户提供服务,基于下面考虑:

1:默认Service存在许多限制,不能管理,缺少灵活性

2:可依据用户应用类型建立不同Service分类管理应用

3:可动态灵活分配主要实例和可用实例给每个Service,以及动态迁移Service到其他实例

4:可以计划禁用Service满足计划停机事件

5:可依据应用定义链接时负载均衡和运行时负载均衡

基于以上好处强烈建议使用自定义Service提供服务

下面我们看看自定义服务的建立和相关重要属性:

用户可使用EM和srvctl建立、修改、禁用、启动、停止、查询。这里我们只讨论srvctl的使用方法,下面是12C的使用方法,注意12C和11G以及10G的使用方法差异巨大,10G的Service特性较少,11G的Service功能强大但是参数使用方法和12C完全不同,12C在11G基础增加功能。

下面我们列出12C的参数:

Usage: srvctl add service -db -service

[-role [PRIMARY][,PHYSICAL_STANDBY][,LOGICAL_STANDBY][,SNAPSHOT_STANDBY]] [-policy ]

[-notification ] [-clbgoal ] [-rlbgoal ]

[-failovertype ] [-failovermethod ][-failoverretry ] [-failoverdelay ] [-failover_restore ]

[-edition ] [-pdb

] [-global ] [-maxlag ] [-sql_translation_profile ]

[-commit_outcome ] [-retention ] [replay_init_time ] [-drain_timeout ]

[-stopoption ] [-session_state ] [-force]

-db Unique name for the database

-service Service name

-role Role of the service (primary, physical_standby, logical_standby, snapshot_standby)

-policy

Management policy for the service (AUTOMATIC or MANUAL)

-failovertype (NONE SESSION SELECT TRANSACTION) Failover type

-failovermethod (NONE BASIC) Failover method

-failoverdelay Failover delay (in seconds)

-failoverretry Number of attempts to retry connection

-failover_restore Option to restore initial environment for Application Continuity and TAF (NONE or LEVEL1)

-edition Edition (or "" for empty edition value)

-pdb

Pluggable database name

-maxlag 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

-notification (TRUE FALSE) Enable Fast Application Notification (FAN) for OCI connections

-global Global attribute (TRUE or FALSE)

-sql_translation_profile Specify a database object for SQL translation profile

-commit_outcome (TRUE FALSE) Commit outcome

-retention Specifies the number of seconds the commit outcome is retained

-replay_init_time Seconds after which replay will not be initiated

-session_state Session state consistency (STATIC or DYNAMIC)

-drain_timeout Service drain timeout specified in seconds

-stopoption Options to stop service (e.g. TRANSACTIONAL or IMMEDIATE)

-force Force the add operation even though a listener is not configured for a network

-verbose Verbose output

-help Print usage

这里我们看看主要的几个参数:

-policy : Service Management Policy 默认为AUTOMATIC,srvctl start database 自动启动service,建议默认。

-preferred :定义优先的实例列表。

-available :定义可用的实例列表,当优先的实例不可用时使用。

-cardinality:Server Pool Assignment(资源池分配) You can define the service as either UNIFORM (running on allinstances in the serverpool) or SINGLETON (running on only one instance in theserver pool) using the -cardinality parameter

-rlbgoal:定义Run-time Connection LoadBalancing,默认为NONE,SERVICE_TIME:基于单个事务处理效率向客户提供最好的服务质量,OLTP使用。THROUGHPUT:基于长时间查询和单个完整工作完成效率向客户提供最大吞吐量,OLAP使用。

-clbgoal:定义Connection Load Balancing Goal,默认值为LONG:如果 -rlbgoal 参数不为NONE,Service定义为SINGLETON也就是只在一个服务器上运行则使用session count进行负载评判.如果Service定义为uniform在所以服务器上运行则使用run queue length进行评判。另外一个值为short: 如果 -rlbgoal 参数不为NONE,则使用GOODNESS进行判断提供负载均衡。

12C新增功能:

CreatingServices for Application Continuity and Transaction Guard

1:Creating Services for ApplicationContinuity

-replay_init_time:单位秒,默认值300s,定义replay初始化时间

-retention:单位秒,默认值86400(1 day),commit outcome信息保存时间。

-failoverretry:链接重试次数,建议30

-failoverdelay:每次重试延迟,建议10s

-notification:FAN is highly recommended—set this value to TRUE to enable FAN for OCI andODP.Net clients.

对数据库racdb 新增service app2 资源池Srvpool1 的示例:

srvctl add service -db racdb -service app2 -serverpool Srvpool1

-failovertype TRANSACTION -commit_outcome TRUE -replay_init_time 1800

-retention 86400 -notification TRUE -rlbgoal SERVICE_TIME -clbgoal SHORT

-failoverretry 30 -failoverdelay 10

2:Creating Services for TransactionGuard,启动事务保护

To enableTransaction Guard, but not Application Continuity, create the service using

SRVCTL and setonly -commit_outcome TRUE.

修改示例:

$ srvctl modify service -db racdb -service app2 -commit_outcome TRUE -retention 86400 -notification TRUE

另外必须

GRANT EXECUTE ON DBMS_APP_CONT;

其他操作:

Starting andStopping Services with SRVCTL:

$ srvctl start service -db db_unique_name [-service service_name_list][-instance inst_name] [-startoption start_options]

$ srvctl stop service -db db_unique_name -service service_name_list [-instance inst_name] [-startoption start_options]

Enabling andDisabling Services with SRVCTL:

$ srvctl enable service -db db_unique_name -service service_name_list [-instance inst_name]

$ srvctl disable service -db db_unique_name -service service_name_list [-instance inst_name]

RelocatingServices with SRVCTL:

The followingcommand relocates the crm service from instance apps1 to instance apps3:

$ srvctl relocate service -db apps -service crm -oldinst apps1 -newinst apps3

The followingcommand relocates the crm service from node1 to node3 using node

$ srvctl relocate service -db apps -service crm -currentnode node1 -targetnode node3

Obtaining theStatus of Services with SRVCTL:

$ srvctl status service -db dbname

Obtaining theConfiguration of Services with SRVCTL:

$ srvctl config service -db dbname -service service_name

原创文章,版权归本文作者所有,如需转载请注明出处

喜欢本文请长按下方的二维码订阅Oracle一体机用户组

  • 发表于:
  • 原文链接:http://kuaibao.qq.com/s/20180116G0N9SU00?refer=cp_1026

同媒体快讯

扫码关注云+社区