1 说明

Oracle Clusterware现在提供了一组评估命令,来确定在实际执行操作之前该操作的影响。这个特性帮助了DBA们确定自己所执行的操作对集群的影响,从而能够做出正确并影响小的决定。

2 查看帮助命令

[Expect-le@www.cndba.cn~]$ crsctl -help

Usage: crsctl add - add a resource, type or other entity
crsctl check - check the state or operating status of a service, resource, or other entity
crsctl config - display automatic startup configuration
crsctl debug - display or modify debug state
crsctl delete - delete a resource, type or other entity
crsctl disable - disable automatic startup
crsctl discover - discover DHCP server
crsctl enable - enable automatic startup
crsctl eval - evaluate operations on resource or other entity without performing them
crsctl get - get an entity value
crsctl getperm - get entity permissions
crsctl lsmodules - list debug modules
crsctl modify - modify a resource, type or other entity
crsctl query - query service state
crsctl pin - make the leases of specified nodes immutable
crsctl relocate - relocate a resource, server or other entity
crsctl replace - change the location of voting files
crsctl release - release a DHCP lease
crsctl request - request a DHCP lease or an action entry point
crsctl setperm - set entity permissions
crsctl set - set an entity value
crsctl start - start a resource, server or other entity
crsctl status - get status of a resource or other entity
crsctl stop - stop a resource, server or other entity
crsctl unpin - make the leases of previously pinned nodes mutable
crsctl unset - unset an entity value, restoring its default

新增一个eval命令,用于评估该命令,但不实际执行。

3 eval支持的操作

crsctl eval activate policy
crsctl eval add resource
crsctl eval add server
crsctl eval add serverpool
crsctl eval delete server
crsctl eval delete serverpool
crsctl eval fail resource
crsctl eval modify resource
crsctl eval modify serverpool
crsctl eval relocate resource
crsctl eval relocate server
crsctl eval start resource
crsctl eval stop resource

注意:CRSCTL can only evaluate third-party resources. Resources with the .ora prefix, such as ora.orcl.db, must be evaluated using SRVCTL commands. --从12.1开始,Oracle禁止使用CRSCTL评估ora.资源的操作,统一使用SRVCTL命令。实际上从12c开始,crsctl的功能已经被弱化了。大大强化了SRVCTL命令的功能。

报错:
CRS-4995: The command ‘stop resource’ is invalid in crsctl. Use srvctl for this command

3.1 crsctl eval -help可查看更为详细的帮助信息

例如:

Usage:
crsctl eval start resource {|-w }[-n server] [-f]
Evaluate start of specified resources

where
resname Name of a resource
-w Resource filter
-n Server Name
-f Evaluate as with force option

crsctl eval stop resource {|-w } [-f]
Evaluate stop of specified resources
where
resname Name of a resource
-w Resource filter
-f Evaluate as with force option

4 例子-CRSCTL

4.1 添加一个resource

—添加一个TYPE

crsctl add type cndba -basetype cluster_resource  -attr "ATTRIBUTE=FOO,TYPE=integer,DEFAULT_VALUE=0"

–添加资源,type名称错误

[Expect-le@www.cndba.cn~]$ crsctl eval add resource test_resource -type cndbaa
Stage Group 1:
-------------------------------------------------------------------------------
Stage Number Required Action
--------------------------------------------------------------------------------
1 N Error code [220] for entity [test_resource].

Message is [CRS-0175: Resource type 'cndbaa'
either doesn't exist or cannot be accessed.].

–TYPE名称正确,则没有提示

[Expect-le@www.cndba.cn~]$ crsctl eval add resource test_resource -type cndba
[Expect-le@www.cndba.cn~]$

5 例子-SRVCTL

5.1 支持的命令

srvctl add database
srvctl add service
srvctl add srvpool
srvctl modify database
srvctl modify service
srvctl modify srvpool
srvctl relocate server
srvctl relocate service
srvctl remove srvpool
srvctl start database
srvctl start service
srvctl stop database
srvctl stop service

5.2 停止数据库

[Expect-le@www.cndba.cn~]$ srvctl stop database -db cndba -stopoption NORMAL -eval

PRKO-2712 : Administrator-managed database cndba is not supported with -eval option

这里报了个错,说Administrator-managed管理的数据库不支持eval选项。

官网解释:administrator-managed database:

A database that you specifically define on which servers it can run, and where services can run within the database.

–查看数据库配置信息

[Expect-le@www.cndba.cn~]$ srvctl config database -db cndba
Database unique name: cndba
Database name: cndba
Oracle home: /u01/app/oracle/12.2.0/db_1
Oracle user: oracle
Spfile: +DATA/CNDBA/PARAMETERFILE/spfile.276.951664119
Password file: +DATA/CNDBA/PASSWORD/pwdcndba.256.951662701
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: cndba1,cndba2
Configured nodes: rac1,rac2
Database is administrator managed
[Expect-le@www.cndba.cn~]$ srvctl config service -db cndba
[Expect-le@www.cndba.cn~]$

将 Administrator-Managed Database 转换为 Policy-Managed Database:

​http://www.cndba.cn/Expect-le/article/2138​

5.2.1 再次评估关闭数据库

[Expect-le@www.cndba.cn~]$ srvctl stop database -db cndba -stopoption NORMAL -eval

Database cndba will be stopped on node rac1

可以看到Oracle提示数据库会在节点rac1上被关闭。

5.3 查看数据库状态

[Expect-le@www.cndba.cn~]$ srvctl status database -db cndba
Instance cndba_1 is running on node rac1

数据库正常运行。

更多详细信息,参考官方文档:
​​​http://docs.oracle.com/database/121/NEWFT/chapter12101.htm#NEWFT373​​​​https://docs.oracle.com/database/121/RACAD/GUID-803F603E-8638-4946-84D4-CB24D21C893C.htm#RACAD7906​