Oracle 11g RAC中crs_stat命令较之前的版本多出了很多新的不同的资源类型,缺省情况下,使用crs_stat -t来查看资源是密密麻麻一大片,看起来着实费力。作者Paul Elbow, Enkitec为我们提供了一个crsstat脚本以更清晰的格式来展现Oracle 11g RAC下的所有资源类型,见本文下面的描述。
1、安装crsstat
通常情况下,建议使用root用户或者oracle用户来安装到 /usr/local/bin 目录
当脚本首次运行时,会在安装目录产生一个 crsstat.env 文件,该文件用于描述crs的位置信息
安装crsstat前,应启动crs,其次对于crsstat脚本所在的安装路径应当具有写的权限
源文件下载: http://blog.enkitec.com/wp-content/uploads/2012/07/crsstat.v1.2.2.zip
下面是安装步骤
# cd /usr/local/bin
# unzip crsstat.v1.2.1.zip
# mv crsstat.v1.2.2 crsstat
# chmod 755 crsstat
# ./crsstat
# chmod 644 crsstat.env
校验crsstat.env文件配置是否正确
# more crsstat.env
GRID_HOME=/u01/app/11.2.0/grid
GRID_VER=11.2
2、演示用法
crsstat用法比较简单,直接在提示符下执行crsstat命令即可,也可以使用crsstat -h 输出crsstat的帮助信息
a、crsstat的帮助信息
[grid@linux1 ~]$ crsstat -h
Usage: crsstat [-h] [-c] [search term]
-h => print this message
-c => output the resources by cluster or local
Examples:
crsstat # show all resources
crsstat listener # only show listener resources
crsstat database # only show database resources
crsstat -c listener # only show database resources sorted by cluster/local
Output Contains the following fields:
Resource Name
Resource Type, which includes an identifier C-Cluster and L-Local
Target State
Current State
Current Node (11gR2: or the last node in paraenthesis if the resource is Offline)
Failure Count (11gR2 only)
Restart Count (11gR2 only)
State Details (11gR2 only)
b、使用crsstat查看集群资源
#显示所有的资源
[oracle@linux1 bin]$ crsstat
Resource Name Resource Type Target State Node FC RC State Details
---------------------------------------- ---------------- ---------- ------------ --------------- -- -- ---------------
ora.ASM_DATA.dg diskgroup L ONLINE ONLINE linux1 0
ora.ASM_DATA.dg diskgroup L ONLINE ONLINE linux2 0
ora.FRA_DATA.dg diskgroup L ONLINE ONLINE linux1 0
ora.FRA_DATA.dg diskgroup L ONLINE ONLINE linux2 0
ora.LISTENER.lsnr Listener L ONLINE ONLINE linux1 0
ora.LISTENER.lsnr Listener L ONLINE ONLINE linux2 0
ora.LISTENER_SCAN1.lsnr SCAN Listener C ONLINE ONLINE linux1 0
ora.LISTENER_SCAN2.lsnr SCAN Listener C ONLINE ONLINE linux2 0
ora.OCR_VOTE.dg diskgroup L ONLINE ONLINE linux1 0
ora.OCR_VOTE.dg diskgroup L ONLINE ONLINE linux2 0
ora.asm ASM L ONLINE ONLINE linux1 0 Started
ora.asm ASM L ONLINE ONLINE linux2 0 Started
ora.eons eons L ONLINE ONLINE linux1 0
ora.eons eons L ONLINE ONLINE linux2 0
ora.gsd Gbl Svc Daemon L OFFLINE OFFLINE (linux1) 0
ora.gsd Gbl Svc Daemon L OFFLINE OFFLINE (linux2) 0
ora.linux1.vip Cluster VIP C ONLINE ONLINE linux1 0
ora.linux2.vip Cluster VIP C ONLINE ONLINE linux2 0
ora.mmbo.db database C ONLINE ONLINE linux1 0 Open
ora.mmbo.db database C ONLINE ONLINE linux2 0 Open
ora.mmbo11g.db database C ONLINE ONLINE linux1 0 Open
ora.net1.network Network (VIP) L ONLINE ONLINE linux1 0
ora.net1.network Network (VIP) L ONLINE ONLINE linux2 0
ora.oc4j OC4J C OFFLINE OFFLINE () 0
ora.ons Ora Notif Svc L ONLINE ONLINE linux1 0
ora.ons Ora Notif Svc L ONLINE ONLINE linux2 0
ora.registry.acfs registry L ONLINE ONLINE linux1 0
ora.registry.acfs registry L ONLINE ONLINE linux2 0
ora.scan1.vip SCAN VIP C ONLINE ONLINE linux1 0
ora.scan2.vip SCAN VIP C ONLINE ONLINE linux2 0
c、其它用法
#显示service相关的信息,由于当前rac环境没有配置service,所以无任何显示
# Author : Robinson
# Blog : http://blog.csdn.net/robinson_0612
[oracle@linux1 bin]$ crsstat service
Resource Name Resource Type Target State Node FC RC State Details
---------------------------------------- ---------------- ---------- ------------ --------------- -- -- ---------------
#显示集群中已注册数据库的信息
[oracle@linux1 bin]$ crsstat database
Resource Name Resource Type Target State Node FC RC State Details
---------------------------------------- ---------------- ---------- ------------ --------------- -- -- ---------------
ora.mmbo.db database C ONLINE ONLINE linux1 0 Open
ora.mmbo.db database C ONLINE ONLINE linux2 0 Open
ora.mmbo11g.db database C ONLINE ONLINE linux1 0 Open
#显示集群中监听器的信息
[oracle@linux1 bin]$ crsstat lsnr
Resource Name Resource Type Target State Node FC RC State Details
---------------------------------------- ---------------- ---------- ------------ --------------- -- -- ---------------
ora.LISTENER.lsnr Listener L ONLINE ONLINE linux1 0
ora.LISTENER.lsnr Listener L ONLINE ONLINE linux2 0
ora.LISTENER_SCAN1.lsnr SCAN Listener C ONLINE ONLINE linux1 0
ora.LISTENER_SCAN2.lsnr SCAN Listener C ONLINE ONLINE linux2 0
#也可以结合grep命令来过滤
[oracle@linux1 bin]$ crsstat | grep -i offline
ora.gsd Gbl Svc Daemon L OFFLINE OFFLINE (linux1) 0
ora.gsd Gbl Svc Daemon L OFFLINE OFFLINE (linux2) 0
ora.oc4j OC4J C OFFLINE OFFLINE () 0
[grid@linux1 ~]$ crsstat -c listener
Resource Name Resource Type Target State Node FC RC State Details
---------------------------------------- ---------------- ---------- ------------ --------------- -- -- ---------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr Listener L ONLINE ONLINE linux1 0
ora.LISTENER.lsnr Listener L ONLINE ONLINE linux2 0
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr SCAN Listener C ONLINE ONLINE linux1 0
ora.LISTENER_SCAN2.lsnr SCAN Listener C ONLINE ONLINE linux2 0
3、更多参考
My crsstat script: Improved Formatting of crs_stat on 10g and 11g
DML Error Logging 特性
PL/SQL --> 游标
PL/SQL --> 隐式游标(SQL%FOUND)
批量SQL之 FORALL 语句
批量SQL之 BULK COLLECT 子句
PL/SQL 集合的初始化与赋值
PL/SQL 联合数组与嵌套表
PL/SQL 变长数组
PL/SQL --> PL/SQL记录
SQL tuning 步骤
高效SQL语句必杀技
父游标、子游标及共享游标
绑定变量及其优缺点
dbms_xplan之display_cursor函数的使用
dbms_xplan之display函数的使用
执行计划中各字段各模块描述
使用 EXPLAIN PLAN 获取SQL语句执行计划