[20190507]crs_stat與crsctl.txt
[20190507]crs_stat與crsctl.txt
--//管理rac,遇到問題一般首先透過crs_stat與crsctl檢視資源的狀況.
--//10g下一般使用crs_stat ,我記憶裡面好像沒有crsctl命令,這個是11g才有的命令,用來取代crs_stat.
--//實際上11g命令crs_stat還是存在的.
--//一般加入-t命令執行如下:
$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.DATA.dg ora....up.type ONLINE ONLINE xxyyy1
ora....ER.lsnr ora....er.type ONLINE ONLINE xxyyy1
ora....N1.lsnr ora....er.type ONLINE ONLINE xxyyy2
ora....N2.lsnr ora....er.type ONLINE ONLINE xxyyy1
ora....N3.lsnr ora....er.type ONLINE ONLINE xxyyy1
ora.OCR.dg ora....up.type ONLINE ONLINE xxyyy1
ora.asm ora.asm.type ONLINE ONLINE xxyyy1
ora.cvu ora.cvu.type ONLINE ONLINE xxyyy1
ora.xxyyy.db ora....se.type ONLINE ONLINE xxyyy1
ora....rcl.svc ora....ce.type ONLINE ONLINE xxyyy1
ora....SM1.asm application ONLINE ONLINE xxyyy1
ora....S1.lsnr application ONLINE ONLINE xxyyy1
ora.xxyyy1.gsd application OFFLINE OFFLINE
ora.xxyyy1.ons application ONLINE ONLINE xxyyy1
ora.xxyyy1.vip ora....t1.type ONLINE ONLINE xxyyy1
ora....SM2.asm application ONLINE ONLINE xxyyy2
ora....S2.lsnr application ONLINE ONLINE xxyyy2
ora.xxyyy2.gsd application OFFLINE OFFLINE
ora.xxyyy2.ons application ONLINE ONLINE xxyyy2
ora.xxyyy2.vip ora....t1.type ONLINE ONLINE xxyyy2
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE xxyyy1
ora.oc4j ora.oc4j.type ONLINE ONLINE xxyyy1
ora.ons ora.ons.type ONLINE ONLINE xxyyy1
ora....ry.acfs ora....fs.type ONLINE ONLINE xxyyy1
ora.scan1.vip ora....ip.type ONLINE ONLINE xxyyy2
ora.scan2.vip ora....ip.type ONLINE ONLINE xxyyy1
ora.scan3.vip ora....ip.type ONLINE ONLINE xxyyy1
--//加入-t引數缺點是看到的name顯示不全.為此網上有許多blog透過awk過濾更好的顯示,我記錄的指令碼如下:
$ cat dba_crs
#!/bin/bash
#
# Sample 10g CRS resource status query script
#
# Description:
# - Returns formatted version of crs_stat -t, in tabular
# format, with the complete rsc names and filtering keywords
# - The argument, $RSC_KEY, is optional and if passed to the script, will
# limit the output to HA resources whose names match $RSC_KEY.
# Requirements:
# - $ORA_CRS_HOME should be set in your environment
RSC_KEY=$1
#export ORA_CRS_HOME=/orahomes/CRS
#export ORA_CRS_HOME=/u01/app/oracle/product/10.2.0/crs
export ORA_CRS_HOME=/u01/app/11.2.0.4/grid
QSTAT=-u
AWK=/bin/awk # if not available use /usr/bin/awk
# Table header:echo ""
$AWK \
'BEGIN {printf "%-45s %-10s %-18s\n", "HA Resource", "Target", "State";
printf "%-45s %-10s %-18s\n", "--------------------------------------------", "-------", "-----------------";}'
# Table body:
$ORACLE_HOME/bin/crs_stat $QSTAT | $AWK \
'BEGIN { FS="="; state = 0; }
$1~/NAME/ && $2~/'$RSC_KEY'/ {appname = $2; state=1};
state == 0 {next;}
$1~/TARGET/ && state == 1 {apptarget = $2; state=2;}
$1~/STATE/ && state == 2 {appstate = $2; state=3;}
state == 3 {printf "%-45s %-10s %-18s\n", appname, apptarget, appstate; state=0;}'
--//執行例子如下:
$ ./dba_crs
HA Resource Target State
-------------------------------------------- ------- -----------------
ora.DATA.dg ONLINE ONLINE on xxyyy1
ora.LISTENER.lsnr ONLINE ONLINE on xxyyy1
ora.LISTENER_SCAN1.lsnr ONLINE ONLINE on xxyyy2
ora.LISTENER_SCAN2.lsnr ONLINE ONLINE on xxyyy1
ora.LISTENER_SCAN3.lsnr ONLINE ONLINE on xxyyy1
ora.OCR.dg ONLINE ONLINE on xxyyy1
ora.asm ONLINE ONLINE on xxyyy1
ora.cvu ONLINE ONLINE on xxyyy1
ora.xxyyy.db ONLINE ONLINE on xxyyy1
ora.xxyyy.orcl.svc ONLINE ONLINE on xxyyy1
ora.xxyyy1.ASM1.asm ONLINE ONLINE on xxyyy1
ora.xxyyy1.LISTENER_xxyyy1.lsnr ONLINE ONLINE on xxyyy1
ora.xxyyy1.gsd OFFLINE OFFLINE
ora.xxyyy1.ons ONLINE ONLINE on xxyyy1
ora.xxyyy1.vip ONLINE ONLINE on xxyyy1
ora.xxyyy2.ASM2.asm ONLINE ONLINE on xxyyy2
ora.xxyyy2.LISTENER_xxyyy2.lsnr ONLINE ONLINE on xxyyy2
ora.xxyyy2.gsd OFFLINE OFFLINE
ora.xxyyy2.ons ONLINE ONLINE on xxyyy2
ora.xxyyy2.vip ONLINE ONLINE on xxyyy2
ora.gsd OFFLINE OFFLINE
ora.net1.network ONLINE ONLINE on xxyyy1
ora.oc4j ONLINE ONLINE on xxyyy1
ora.ons ONLINE ONLINE on xxyyy1
ora.registry.acfs ONLINE ONLINE on xxyyy1
ora.scan1.vip ONLINE ONLINE on xxyyy2
ora.scan2.vip ONLINE ONLINE on xxyyy1
ora.scan3.vip ONLINE ONLINE on xxyyy1
$ ./dba_crs ora.LISTENER_SCAN
HA Resource Target State
-------------------------------------------- ------- -----------------
ora.LISTENER_SCAN1.lsnr ONLINE ONLINE on xxyyy2
ora.LISTENER_SCAN2.lsnr ONLINE ONLINE on xxyyy1
ora.LISTENER_SCAN3.lsnr ONLINE ONLINE on xxyyy1
$ ./dba_crs | egrep "HA Resource |OFFLINE|^---"
HA Resource Target State
-------------------------------------------- ------- -----------------
ora.xxyyy1.gsd OFFLINE OFFLINE
ora.xxyyy2.gsd OFFLINE OFFLINE
ora.gsd OFFLINE OFFLINE
--//我的機器還有一個perl的指令碼:
$ cat dba_crs.pl
#!/usr/bin/perl
$s=".";
if($#ARGV>=0){$s=$ARGV[0];chomp$s;}
printf("%-45s%-18s%-12s%-18s\n","HA Resource","TYPE","Target","State");
printf("%-45s%-18s%-12s%-18s\n","-----------","-----","------","-----");
open(CRS_STAT,"crs_stat -u|");
while($line=<CRS_STAT>)
{
if($line =~ m/=/)
{
chomp$line;
($n,$v)=split(/=/,$line);
if($n eq "NAME"){$name=$v;}
elsif($n eq "TYPE"){$type=$v;}
elsif($n eq "TARGET"){$target=$v;}
elsif($n eq "STATE")
{
$state=$v;
if($name=~ m/$s/)
{
printf("%-45s%-18s%-12s%-18s\n",$name,$type,$target,$state);
}
}
}
}
--//這樣顯示更加清晰.不過從11g開始已經使用crsctl取代crs_stat這個命令.
$ crsctl status resource -t
$ crsctl status res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE xxyyy1
ONLINE ONLINE xxyyy2
ora.LISTENER.lsnr
ONLINE ONLINE xxyyy1
ONLINE ONLINE xxyyy2
ora.OCR.dg
ONLINE ONLINE xxyyy1
ONLINE ONLINE xxyyy2
ora.asm
ONLINE ONLINE xxyyy1 Started
ONLINE ONLINE xxyyy2 Started
ora.gsd
OFFLINE OFFLINE xxyyy1
OFFLINE OFFLINE xxyyy2
ora.net1.network
ONLINE ONLINE xxyyy1
ONLINE ONLINE xxyyy2
ora.ons
ONLINE ONLINE xxyyy1
ONLINE ONLINE xxyyy2
ora.registry.acfs
ONLINE ONLINE xxyyy1
ONLINE ONLINE xxyyy2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE xxyyy2
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE xxyyy1
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE xxyyy1
ora.cvu
1 ONLINE ONLINE xxyyy1
ora.xxyyy.db
1 ONLINE ONLINE xxyyy1 Open
2 ONLINE ONLINE xxyyy2 Open
ora.xxyyy.orcl.svc
1 ONLINE ONLINE xxyyy1
ora.xxyyy1.vip
1 ONLINE ONLINE xxyyy1
ora.xxyyy2.vip
1 ONLINE ONLINE xxyyy2
ora.oc4j
1 ONLINE ONLINE xxyyy1
ora.scan1.vip
1 ONLINE ONLINE xxyyy2
ora.scan2.vip
1 ONLINE ONLINE xxyyy1
ora.scan3.vip
1 ONLINE ONLINE xxyyy1
--//oracle的crsctl區分開Local Resources以及Cluster Resources,name單獨顯示一行,解決這個問題.
--//感覺oracle設計這個命令按照80列顯示寬度來設計的.
--//另外crsctl status resource還增加-w引數過濾,這樣可以更快看到那些資源OFFLINE.
$ crsctl status resource -h
Usage:
crsctl status resource [<resName>[...]|-w <filter>] [<-p|-v> [-e]] | [[-f|-l|-g]] | [[-k <cid>|-n <server>] [-d <did>]] | [-s -k <cid> [-d <did>]]
Check status of designated resources
crsctl status resource [<resName>[...]|-w <filter>] -t
Print status of resources in tabular format
crsctl status resource [<resName>[...]] -dependency [-stop | -pullup]
Print resource dependencies
where
resName [...] One or more blank-separated resource names
-w Resource filter (e.g., "TYPE = ora.database.type")
-p Print static configuration
-v Print runtime configuration
-e Evaluate a resource instance's special values
-f Print full configuration
-l Print all cardinal and degree members
-g Check if resources are registered
-k Cardinality ID
-d Degree ID
-n Server name
-s Get target servers for relocation
-t Tabular display
-dependency Display resource dependencies, default is start dependencies
-stop Display resource stop dependencies
-pullup Display resource pullup dependencies
$ crsctl stat res -t -w "((TARGET != ONLINE) or (STATE != ONLINE)) "
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.gsd
OFFLINE OFFLINE xxyyy1
OFFLINE OFFLINE xxyyy2
$ crsctl stat res -t -w "((TARGET != ONLINE) or (STATE != ONLINE)) and (TYPE != ora.gsd.type)"
--//注意一點TARGET,STATE,TYPE大寫.
$ crsctl stat res -t -w "name = ora.gsd"
--//沒有輸出.
$ crsctl stat res -t -w "NAME = ora.gsd"
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.gsd
OFFLINE OFFLINE xxyyy1
OFFLINE OFFLINE xxyyy2
$ crsctl stat res -t -w "TARGET = offline"
--//沒有輸出.
$ crsctl stat res -t -w "TARGET = OFFLINE"
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.gsd
OFFLINE OFFLINE xxyyy1
OFFLINE OFFLINE xxyyy2
--//還有注意 = 兩邊留空.
$ crsctl stat res -t -w "TARGET=OFFLINE"
CRS-2594: Filter specification 'TARGET=OFFLINE' is invalid
Sample filters:
1. TYPE = type1
2. ((TYPE = type1) AND (CHECK_INTERVAL > 50))
3. (TYPE = type1) AND ((CHECK_INTERVAL > 30) OR (AUTO_START co never))
Filter Operators: =, >, <, !=, co, st, en
Sample command: crsctl status res -w "TYPE = type1"
CRS-4000: Command Status failed, or completed with errors.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2643598/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RAC 管理(crs_stat、crsctl、srvctl)
- [20190507]sga_target=0注意修改_kghdsidx_count設定.txt
- [20210804]oracle rac執行命令crs_stat -t -v緩慢的分析.txtOracle
- undefined與null與?. ??UndefinedNull
- Promise與async/await與GeneratorPromiseAI
- for of 與 for in
- 程式與執行緒、同步與非同步、阻塞與非阻塞、併發與並行執行緒非同步並行
- forms元件補充與ModelForm簡單使用與cookie與sessionORM元件CookieSession
- Python學習筆記 5.0 元組 與 字典 與 集合 與 公共操作 與 推導式Python筆記
- 進與穩,時代與技術,新基建與華為雲
- jQuery與JavaScript與ajax三者的區別與聯絡jQueryJavaScript
- 聊聊執行緒與程式 & 阻塞與非阻塞 & 同步與非同步執行緒非同步
- Iterator與Iterable(迭代器與可迭代)
- 漏型與源型、PNP與NPN
- GRPC與 ProtoBuf 的理解與總結RPC
- PySpark與GraphFrames的安裝與使用Spark
- Process與Socket,Select與Accept關係
- PHP 與 Swoole 淺析與學習PHP
- rpm與yum,at與crontab,sed命令使用
- css(二):高度與文件流,line-box與box,寬度,position與CSS
- A與B
- js == 與 ===JS
- Docker與containerd的關係與區別DockerAI
- JRE與JDK的區別與聯絡JDK
- Excutors 與 ThreadPoolExcutor 的關係與區別thread
- 《山海旅人》與它的詩與遠方
- Java:運用while()與do....while與for()JavaWhile
- cookie與session的自己思考與解釋CookieSession
- cookie與session的區別與聯絡CookieSession
- Tensor與tensor深入分析與異同
- 陣列與字串方法與相互轉換陣列字串
- python加密與解密,加簽與驗籤Python加密解密
- Session與Cookie的區別與聯絡SessionCookie
- 【Linux】mysql下載與安裝與重置密碼與建立資料庫LinuxMySql密碼資料庫
- 10 建立SSL與RSA證書與金鑰
- Scala與Java差異(五)之Map與TupleJava
- 程式碼與質量的思考與隨筆
- 核心與裝置樹編譯與燒寫編譯