RAC常见命令检查状态
1.2.1 检查集群状态
[grid@rac1 ~]$ crsctl check cluster
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Servicesis online
CRS-4533: Event Manager is online
1.2.2 所有Oracle实例(数据库状态)
[grid@rac1 ~]$ srvctl status database -dsdd
Instance sdd1 is running on node rac1
Instance sdd2 is running on node rac2
1.2.3 检查单个实例状态
[grid@rac1 ~]$ srvctl status instance -dsdd -i sdd1
Instance sdd1 is running on node rac1
[grid@rac1 ~]$
1.2.4节点应用程序状态
[grid@rac1 ~]$ srvctl status nodeapps
VIP rac1-vip is enabled
VIP rac1-vip is running on node: rac1
VIP rac2-vip is enabled
VIP rac2-vip is running on node: rac2
Network is enabled
Network is running on node: rac1
Network is running on node: rac2
GSD is disabled
GSD is not running on node: rac1
GSD is not running on node: rac2
ONS is enabled
ONS daemon is running on node: rac1
ONS daemon is running on node: rac2
1.2.5 列出所有的配置数据库
[grid@rac1 ~]$ srvctl config database
sdd
1.2.6 数据库配置
[grid@rac1 ~]$ srvctl config database -dsdd -a
Database unique name: sdd
Database name: sdd
Oracle home: /u01/app/oracle/11.2.0/db_1
Oracle user: oracle
Spfile: +DATA/sdd/spfilesdd.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: sdd
Database instances: sdd1,sdd2
Disk Groups: DATA,FRA
Mount point paths:
Services:
Type: RAC
Database is enabled
Database is administrator managed
1.2.7 ASM状态以及ASM配置
[grid@rac1 ~]$ srvctl status asm
ASM is running on rac2,rac1
[grid@rac1 ~]$ srvctl status asm -a
ASM is running on rac2,rac1
ASM is enabled.
1.2.8 TNS监听器状态以及配置
[grid@rac1 ~]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s):rac2,rac1
[grid@rac1 ~]$ srvctl config listener -a
Name: LISTENER
Network: 1, Owner: grid
Home:
/u01/app/grid/11.2.0 on node(s) rac2,rac1
End points: TCP:1521
1.2.9 SCAN状态以及配置
[grid@rac1 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node rac1
[grid@rac1 ~]$ srvctl config scan
SCAN name: rac-scan, Network:1/192.168.16.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP:/rac-scan/192.168.16.207
1.2.10 VIP各个节点的状态以及配置
[grid@rac1 ~]$ srvctl status vip -n rac1
VIP rac1-vip is enabled
VIP rac1-vip is running on node: rac1
[grid@rac1 ~]$ srvctl status vip -n rac2
VIP rac2-vip is enabled
VIP rac2-vip is running on node: rac2
[grid@rac1 ~]$ srvctl config vip -n rac1
VIP exists: /rac1-vip/192.168.16.201/192.168.16.0/255.255.255.0/eth0,hosting node rac1
[grid@rac1 ~]$ srvctl config vip -n rac2
VIP exists:/rac2-vip/192.168.16.203/192.168.16.0/255.255.255.0/eth0, hosting node rac2
[grid@rac1 ~]$
1.2.11 节点应用程序配置(VIP、GSD、ONS、监听器)
[grid@rac1 ~]$ srvctl config nodeapps -a -g-s -l
Warning:-l option has been deprecated andwill be ignored.
Network exists:1/192.168.16.0/255.255.255.0/eth0, type static
VIP exists:/rac1-vip/192.168.16.201/192.168.16.0/255.255.255.0/eth0, hosting node rac1
VIP exists:/rac2-vip/192.168.16.203/192.168.16.0/255.255.255.0/eth0, hosting node rac2
GSD exists
ONS exists: Local port 6100, remote port6200, EM port 2016
Name: LISTENER
Network: 1, Owner: grid
Home:
/u01/app/grid/11.2.0 on node(s) rac2,rac1
End points: TCP:1521
1.3 语法简汇
1.3.1 数据库与实例
srvctl config database # 列出安装的数据库
srvctl config database -d rac -a # 检查数据库相关的信息
srvctlstatus database -d RAC # 检查数据库的状态
srvctl status instance -d RAC -i rac1 # 检查指定实例的状态
srvctl config asm -a # ASM配置
srvctl status asm # ASM的状态
srvctl start database -d rac # 启动数据库
srvctl stop database -d rac # 关闭数据库
srvctl start instance -d rac -i rac1 # 启动指定的实例
srvctl stop instance -d rac -i rac2 # 关闭指定实例
1.3.2 网络相关的命令
srvctl status listener # 检查TNS listener的状态
srvctl config scan # SCAN的配置
srvctl status scan # SCAN listener状态, 包含当前运行节点的信息
# 检查VIP的配置及状态
srvctl status vip -n rac1
srvctl config vip -n rac1
1.3.3 查看各资源状态(nodeapps节点应用程序,ASM实例,数据库等)
[root@db02 u01]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.DATA.dg ora....up.type ONLINE ONLINE db02
ora.FRA.dg ora....up.type ONLINE ONLINE db02
ora....ER.lsnr ora....er.type ONLINE ONLINE db02
ora....N1.lsnr ora....er.type ONLINE ONLINE db02
ora....N2.lsnr ora....er.type ONLINE ONLINE db02
ora....N3.lsnr ora....er.type ONLINE ONLINE db02
ora.OCR.dg ora....up.type ONLINE ONLINE db02
ora.asm ora.asm.type ONLINE ONLINE db02
ora....-01.vip ora....t1.type ONLINE ONLINE db02
ora....SM2.asm application ONLINE ONLINE db02
ora....02.lsnr application ONLINE ONLINE db02
ora....-02.gsd application OFFLINE OFFLINE
ora....-02.ons application ONLINE ONLINE db02
ora....-02.vip ora....t1.type ONLINE ONLINE db02
ora.cvu ora.cvu.type ONLINE ONLINE db02
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE db02
ora.oc4j ora.oc4j.type ONLINE ONLINE db02
ora.ons ora.ons.type ONLINE ONLINE db02
ora.orcl.db ora....se.type ONLINE ONLINE db02
ora....taf.svc ora....ce.type ONLINE ONLINE db02
ora.scan1.vip ora....ip.type ONLINE ONLINE db02
ora.scan2.vip ora....ip.type ONLINE ONLINE db02
ora.scan3.vip ora....ip.type ONLINE ONLINE db02
在11g R2中,默认 oc4j和gsd资源是 disable的;oc4j 是用于WLM 的一个资源, WLM在 11.2.0.2 才可用;gsd是 CRS 用于跟 9i RAC 进行通信的一个模块,是为了向后兼容才保留的,不影响性能;建议不要刪除, 也不要尝试开启他们, 忽略即可。
ora.gsd is OFFLINE by default ifthere is no 9i database in the cluster.
ora.oc4j is OFFLINE in 11.2.0.1 as DatabaseWorkload Management(DBWLM) is unavailable. these can be ignored in11gR2 RAC.
状态检查也可以使用如下命令:
crsctl stat resource –t
或者
crsctl stat resource
1.3.4 综合
1、通过SRVCTL命令来start/stop/check所有的实例:
srvctl start|stop|status database -d
2、start/stop指定的实例:
srvctl start|stop|statusinstance -d -i
3、列出当前RAC下所有的
srvctl config database -d
4、start/stop/check 所有的nodeapps,比如:VIP, GSD, listener, ONS:
srvctl start|stop|status nodeapps -n
5、如果你使用ASM,srvctl也可以start/stop ASM实例:
srvctl start|stop asm -n [-i ] [-o]
6、可以获取所有的环境信息:
srvctl getenv database -d [-i]
7、设置全局环境和变量:
srvctl setenv database -d -t LANG=en
8、从OCR中删除已有的数据库:
srvctl remove database -d
9、向OCR中添加一个数据库的实例:
srvctl add instance -d -i –n
查看一台机器的实例的状态
$ srvctl status instance -d orcl -i orcl1
特定节点上节点应用程序的状态
$ srvctl status nodeapps -n linux1
关闭整个rac db:
$ srvctl stop database –d orcl
$ srvctl stop database –d ams
$ srvctl stop nodeapps –n hdoadb1
$ srvctl stop nodeapps –n hdoadb2
用crs_stat命令来检查application service状态应该都为offline
HDOADB1: > crs_stat –t
开启整个rac db:
正常情况下当机器启动时oracle rac会自动启动的。
手动启动过程如下:
$ srvctl start nodeapps –n hdoadb1
$ srvctl start nodeapps –n hdoadb2
$ srvctl start database –d orcl
$ srvctl start database –d ams
只停一个节点的instance(node1)
$ srvctl stop instance –d orcl –I orcl1
$ srvctl stop instance –d ams –I ams1
Oracle Clusterware的关闭与启动:
#cd $ORACLE_CRS_HOME/bin
# crsctl start crs------>启动CRS,会自动把其它的resource也启动
# crsctl stop crs------->关闭CRS,会自动把其它的resource也关闭
Oracle RAC常用的日志文件:
1、db的alertlog文件:
$ORACLE_BASE/admin/orcl/bdump/
$ORACLE_BASE/admin/ams/bdump/
2、oracle crs日志文件:
$ORACLE_CRS_HOME/crs/log
$ORACLE_CRS_HOME/css/log
$ORACLE_CRS_HOME/evm/log
$ORACLE_CRS_HOME/srvm/log
CRS的管理
CRSCTL命令控制着本地节点的CRS服务(Oracle clusterware processes)
停止CRS:
$ crsctl stop crs
或者
$ /etc/init.d/init.crs stop
或者
$ crs_stop –all
启动CRS:
$ crsctl start crs
或者
$ /etc/init.d/init.crs start
禁止Clusterware在系统重启后自动启动的方法:
$ /etc/init.d/init.crs disable
启动Clusterware在系统重启后自动启动的方法:
$ /etc/init.d/init.crs enable
查看CRS服务状态
$ crsctl check crs
#############################################################
OCR的资源管理
OCR的资源,当RAC cluster启动并成功运行以后,你可以使用crs_stat工具
看到如下内容:
$ORA_CRS_HOME/bin/crs_stat
通常情况下,所有的资源的状态都应该是online。另外,OCR每4个小时会备份一次。有一些情况你可以通过恢复的OCR
的配置文件来恢复出现问题的OCR。
比如使用出现如下情况:
$ crs_stat -t
CRS-0184: Cannot communicate with the CRS daemon.
$ crsctl check boot
Failure 4 at procr_open_key with status 4.
PROC-4: The cluster registry key to be operated on does not exist.
$ crsctl check crs
Failure 1 contacting CSS daemon
Cannot communicate with CRS
Cannot communicate with EVM
引起这个错误的一种可能原因是OCR配置丢了。
这个我们可以利用这些备份来还原以前的配置。
# /etc/init.crs disable
# /etc/init.crs stop
先保证所有的crs进程全部停止。
# su – oracle
$ cd $ORA_CRS_HOME/bin
$./ocrconfig -restore /opt/app/oracle/crs/cdata/crs/week.ocr
然后切换到root用户下,重新enable CRS
# /etc/init.crs enable
最后reboot两个节点
##############################################################
SRVCTL命令介绍
SRVCTL命令可以控制RAC数据库中的instance,listener以及services。
通常SRVCTL在ORACLE用户下执行。下面我们来介绍srvctl命令。
1、通过SRVCTL命令来start/stop/check所有的实例:
$ srvctl start|stop|status database -d <db_name>
2、start/stop指定的实例:
$ srvctl start|stop|status instance -d <db_name> -i <instance_name>
3、列出当前RAC下所有的
$ srvctl config database -d <db_name>
4、start/stop/check所有的nodeapps,比如:VIP, GSD, listener, ONS:
$ srvctl start|stop|status nodeapps -n <node_name>
5、如果你使用ASM,srvctl也可以start/stop ASM实例:
$ srvctl start|stop asm -n <node_name> [-i <asm_inst_name>] [-o<oracle_home>]
6、可以获取所有的环境信息:
$ srvctl getenv database -d <db_name> [-i <instance_name>]
7、设置全局环境和变量:
$ srvctl setenv database -d <db_name> -t LANG=en
8、从OCR中删除已有的数据库:
$ srvctl remove database -d <db_name>
9、向OCR中添加一个数据库:
$ srvctl add database -d <db_name> -o <oracle_home>
[-m <domain_name>] [-p<spfile>] [-A <name|ip>/netmask] [-r {PRIMARY |
PHYSICAL_STANDBY |LOGICAL_STANDBY}] [-s <start_options>]
10、向OCR中添加一个数据库的实例:
$ srvctl add instance -d <db_name> -i <instance_name> -n <node1>
$ srvctl add instance -d <db_name> -i <instance_name> -n <node2>
11、向OCR中添加一个ASM实例:
$ srvctl add asm -n <node_name> -i <asm_inst_name> -o <oracle_home>
12、添加一个service
$ srvctl add service -d <db_name> -s <service_name> -r <preferred_list>[-a
<available_list>] [-P <TAF_policy>] [-u]
13、修改在其他节点上的service
$ srvctl modify service -d <db_name> -s <service_name> -I
<orig_instance_name> -t <target_instance_name>
14、relocate某个节点的service到其他节点
srvctl relocate service -d <db_name> -s <service_name> -I
CRS及相关服务的常用命令的演示
1、查看状态的命令
# su –oracle --先切换到oracle用户
$ crs_stat -t --查看crs及所有的service的状态
$ crsctl check crs --用crsctl命令,检查crs相关服务的状态
$ srvctl status nodeapps -n db01 (db02) --使用srvctl查看所有节点上的服务是否正常
$ srvctl status database -d db --使用srvctl查看数据库状态
启动和关闭相关服务的命令
# su – oracle
$ crs_start –all --启动所有的crs服务
$ crs_stop –all --停止所有的crs服务
$ crsctl start crs --启动crs服务
$ crsctl stop crs --停止crs服务
$ srvctl start nodeapps -n db01(db02) --启动某节点上所有的应用
$ srvctl stop nodeapps -n db01(db02) --停止某节点上所有的应用
$ srvctl start listener -n db01(db02) --启动某个节点的listener
$ srvctl stop listener -n db01(db02) --停止某个节点的listener
$ srvctl start instance –d db –i db01(db02) --启动某个instance
$ srvctl stop instance –d db –i db01(db02) --停止某个instance
$ srvctl start database –d db --启动数据库
$ srvctl stop database –d db --停止数据库