ORACLE 12C RAC 之02-常用管理命令

一、查詢命令

1. RAC查询

1.1 查询节点

[grid@xag02 grid]$ olsnodes -s
xag02   Active
xag01   Active

#查看群集的名称
[grid@xag02 grid]$ cemutlo -n
xag-cluster

1.2 查询群集状态

[grid@xag02 grid]$ crsctl check cluster  
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

[grid@xag02 grid]$ crsctl check cluster  -all
**************************************************************
xag01:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
xag02:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************

#檢查CRS狀態
[grid@xag01 ~]$ crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

1.3 检查集群中资源的状态

[grid@xag02 grid]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr
               ONLINE  ONLINE       xag01                    STABLE
               ONLINE  ONLINE       xag02                    STABLE
ora.DATA.dg
               ONLINE  ONLINE       xag01                    STABLE
               ONLINE  ONLINE       xag02                    STABLE
ora.FRA.dg
               ONLINE  ONLINE       xag01                    STABLE
               ONLINE  ONLINE       xag02                    STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       xag01                    STABLE
               ONLINE  ONLINE       xag02                    STABLE
ora.MGMT.dg
               ONLINE  ONLINE       xag01                    STABLE
               ONLINE  ONLINE       xag02                    STABLE
ora.OCR.dg
               ONLINE  ONLINE       xag01                    STABLE
               ONLINE  ONLINE       xag02                    STABLE
ora.chad
               ONLINE  ONLINE       xag01                    STABLE
               ONLINE  ONLINE       xag02                    STABLE
ora.net1.network
               ONLINE  ONLINE       xag01                    STABLE
               ONLINE  ONLINE       xag02                    STABLE
ora.ons
               ONLINE  ONLINE       xag01                    STABLE
               ONLINE  ONLINE       xag02                    STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       xag01                    STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       xag02                    STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       xag02                    STABLE
ora.MGMTLSNR
      1        ONLINE  ONLINE       xag02                    169.254.65.33 10.1.0
                                                             .117 10.2.0.117,STAB
                                                             LE
ora.asm
      1        ONLINE  ONLINE       xag02                    Started,STABLE
      2        ONLINE  ONLINE       xag01                    Started,STABLE
      3        OFFLINE OFFLINE                               STABLE
ora.cvu
      1        ONLINE  ONLINE       xag02                    STABLE
ora.mgmtdb
      1        ONLINE  ONLINE       xag02                    Open,STABLE
ora.myrac1.db
      1        ONLINE  ONLINE       xag02                    Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db_1,STABLE
      2        ONLINE  ONLINE       xag01                    Open,HOME=/u01/app/o
                                                             racle/product/12.2.0
                                                             /db_1,STABLE
ora.qosmserver
      1        ONLINE  ONLINE       xag02                    STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       xag01                    STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       xag02                    STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       xag02                    STABLE
ora.xag01.vip
      1        ONLINE  ONLINE       xag01                    STABLE
ora.xag02.vip
      1        ONLINE  ONLINE       xag02                    STABLE
--------------------------------------------------------------------------------

1.4 节点应用程序状态

[grid@xag02 grid]$ srvctl status nodeapps
VIP 10.0.28.116 is enabled
VIP 10.0.28.116 is running on node: xag01
VIP 10.0.28.118 is enabled
VIP 10.0.28.118 is running on node: xag02
Network is enabled
Network is running on node: xag02
Network is running on node: xag01
ONS is enabled
ONS daemon is running on node: xag02
ONS daemon is running on node: xag01

2. ASM查询

2.1 状态查看

[grid@xag02 grid]$ srvctl status asm
ASM is running on xag01,xag02

ASM instance +ASM1 is running on node xag02
Number of connected clients: 3
Client names: -MGMTDB:_mgmtdb:xag-cluster MYRAC11:MYRAC1:xag-cluster xag02.mp.com:_OCR:xag-cluster
ASM instance +ASM2 is running on node xag01
Number of connected clients: 2
Client names: MYRAC12:MYRAC1:xag-cluster xag01.mp.com:_OCR:xag-cluster

2.2 查看asm配置

[grid@xag02 grid]$ srvctl config asm -a
ASM home: <CRS home>
Password file: +OCR/orapwASM
Backup of Password file: 
ASM listener: LISTENER
ASM is enabled.
ASM is individually enabled on nodes: 
ASM is individually disabled on nodes: 
ASM instance count: 3
Cluster ASM listener: ASMNET1LSNR_ASM

2.3 查看asm是不是Flex

[grid@xag02 grid]$ asmcmd showclustermode
ASM cluster : Flex mode enabled

3. 监听查看

3.1 查看监听状态

[grid@xag02 grid]$ srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): xag01,xag02

3.2查看监听配置

[grid@xag02 grid]$ srvctl config listener -a
Name: LISTENER
Type: Database Listener
Network: 1, Owner: grid
Home: <CRS home>
  /u01/app/12.2.0/grid on node(s) xag01,xag02
End points: TCP:1521
Listener is enabled.
Listener is individually enabled on nodes: 
Listener is individually disabled on nodes:

3.3 查看scan监听器的状态

[grid@xag02 grid]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node xag01
SCAN Listener LISTENER_SCAN2 is enabled
SCAN listener LISTENER_SCAN2 is running on node xag02
SCAN Listener LISTENER_SCAN3 is enabled
SCAN listener LISTENER_SCAN3 is running on node xag02

[grid@xag02 grid]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node xag01
SCAN VIP scan2 is enabled
SCAN VIP scan2 is running on node xag02
SCAN VIP scan3 is enabled
SCAN VIP scan3 is running on node xag02

3.4查看scan网络配置

[grid@xag02 grid]$ srvctl config scan
SCAN name: xag-scan, Network: 1
Subnet IPv4: 10.0.0.0/255.255.0.0/eno1, static
Subnet IPv6: 
SCAN 1 IPv4 VIP: 10.0.28.132
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes: 
SCAN VIP is individually disabled on nodes: 
SCAN 2 IPv4 VIP: 10.0.28.133
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes: 
SCAN VIP is individually disabled on nodes: 
SCAN 3 IPv4 VIP: 10.0.28.131
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes: 
SCAN VIP is individually disabled on nodes:

3.5 查看vip网络

[grid@xag02 grid]$ srvctl status vip -n xag01
VIP 10.0.28.116 is enabled
VIP 10.0.28.116 is running on node: xag01

[grid@xag02 grid]$ srvctl config vip -n xag01
VIP exists: network number 1, hosting node xag01
VIP Name: xag01-vip.mp.com
VIP IPv4 Address: 10.0.28.116
VIP IPv6 Address: 
VIP is enabled.
VIP is individually enabled on nodes: 
VIP is individually disabled on nodes:

3.6 节点应用程序配置(VIP、GSD、ONS、监听器)

[grid@xag02 grid]$ srvctl config nodeapps
Network 1 exists
Subnet IPv4: 10.0.0.0/255.255.0.0/eno1, static
Subnet IPv6: 
Ping Targets: 
Network is enabled
Network is individually enabled on nodes: 
Network is individually disabled on nodes: 
VIP exists: network number 1, hosting node xag01
VIP Name: xag01-vip.mp.com
VIP IPv4 Address: 10.0.28.116
VIP IPv6 Address: 
VIP is enabled.
VIP is individually enabled on nodes: 
VIP is individually disabled on nodes: 
VIP exists: network number 1, hosting node xag02
VIP Name: xag02-vip.mp.com
VIP IPv4 Address: 10.0.28.118
VIP IPv6 Address: 
VIP is enabled.
VIP is individually enabled on nodes: 
VIP is individually disabled on nodes: 
ONS exists: Local port 6100, remote port 6200, EM port 2016, Uses SSL true
ONS is enabled
ONS is individually enabled on nodes: 
ONS is individually disabled on nodes:

4. 数据库查看

4.1数据库状态

[grid@xag02 grid]$ srvctl config database
MYRAC1

[grid@xag02 grid]$ srvctl status database -d MYRAC1
Instance MYRAC11 is running on node xag02
Instance MYRAC12 is running on node xag01

4.2 查看数据库配置

[grid@xag02 grid]$ srvctl config database -d MYRAC1 -a
Database unique name: MYRAC1
Database name: MYRAC1
Oracle home: /u01/app/oracle/product/12.2.0/db_1
Oracle user: oracle
Spfile: +DATA/MYRAC1/PARAMETERFILE/spfile.272.1005064573
Password file: +DATA/MYRAC1/PASSWORD/pwdmyrac1.256.1005064115
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: 
Disk Groups: FRA,DATA
Mount point paths: 
Services: 
Type: RAC
Start concurrency: 
Stop concurrency: 
Database is enabled
Database is individually enabled on nodes: 
Database is individually disabled on nodes: 
OSDBA group: dba
OSOPER group: oper
Database instances: MYRAC11,MYRAC12
Configured nodes: xag02,xag01
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services: 
Database is administrator managed

4.3 检查数据库的状态

[grid@xag02 grid]$ srvctl status database -d MYRAC1
Instance MYRAC11 is running on node xag02
Instance MYRAC12 is running on node xag01

 # 检查指定实例的状态
[grid@xag02 grid]$ srvctl status instance -d MYRAC1 -i MYRAC11
Instance MYRAC11 is running on node xag02

二. 管理命令

1. RAC群集管理命令

1.1 crs_start命令起停rac环境

#查看
[grid@xag02 grid]$ crsctl stat res -t
...
#启动 (?)
[grid@swnode1 ~]$ crs_start -all                  
#关闭 (?)
[grid@swnode1 ~]$ crs_stop -all      

1.2 crsctl起停单节点RAC

#停止/启动节点集群服务,须要以root用户
[root@swnode1 ]# crsctl stop cluster -all -----停止所有节点集群服务
[root@swnode1 ]# crsctl stop cluster    -------停止本节点集群服务

从OCR中删除已有的数据库:
srvctl remove database -d orcl

向OCR中添加一个数据库的实例:
srvctl add instance -d -i -n
srvctl add instance -d -i -n

1.3 通过srvctl 命令管理一个节点的rac

srvctl start|stop|status nodeapps -n rac_node
[grid@xag02 grid]$ srvctl status nodeapps -n xag02
VIP 10.0.28.118 is enabled
VIP 10.0.28.118 is running on node: xag02
Network is enabled
Network is running on node: xag02
ONS is enabled
ONS daemon is running on node: xag02

2. ORACLE数据库管理命令

2.1 通过SRVCTL命令来start/stop/check所有的实例:

srvctl start|stop|status database -d  db_name
[grid@xag02 grid]$ srvctl status database -d MYRAC1
Instance MYRAC11 is running on node xag02
Instance MYRAC12 is running on node xag01

2.2 通过SRVCTL命令来start/stop/check管理指定(單個)实例

srvctl start|stop|status instance -d -i 
[grid@xag02 grid]$ srvctl status instance -d MYRAC1 -i MYRAC11
Instance MYRAC11 is running on node xag02

#查看数据库实例状态:
[grid@xag01 ~]$ srvctl status database -d MYRAC1  -f -v
Instance MYRAC11 is running on node xag02. Instance status: Open.
Instance MYRAC12 is running on node xag01. Instance status: Open.
#关闭数据库实例
[grid@xag01 ~]$ srvctl stop instance -d MYRAC1  -n xag01

#再次查看数据库实例状态
[grid@xag01 ~]$ srvctl status database -d MYRAC1  -f -v
Instance MYRAC11 is running on node xag02. Instance status: Open.
Instance MYRAC12 is not running on node xag01

#启动实例
[grid@xag01 ~]$ srvctl start instance -d MYRAC1 -n xag01
#再次查看数据库实例状态
[grid@xag01 ~]$ srvctl status database -d MYRAC1  -f -v
Instance MYRAC11 is running on node xag02. Instance status: Open.
Instance MYRAC12 is running on node xag01. Instance status: Open.

3 ASM管理命令

3.1 启动ASM实例

[grid@xag02 ~]$ sqlplus / as sysasm
SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
+ASM1        STARTED

#如未啟動則如下命令啟動
SQL> startup

#进入ASM
[grid@xag02 ~]$ asmcmd -p 
ASMCMD [+] > ls
DATA/
FRA/
MGMT/
OCR/

三. 重启RAC数据库

正常关机的顺序应该为 关闭PDB(oracle),关闭数据库(oracle/grid),关闭集群( root 用户),关闭操作系统( root 用户) (如需存储下电,完成以上操作后关闭存储)

正常开机的顺序应该为 (如存储为关闭状态,先将存储开机)--未配置rac自動啟動情況.
开启操作系统( root 用户),开启集群( root 用户),开启数据库(oracle/grid),打開PDB(oracle)
or
重啟服務器(相關服務會自動啟動如已配置自動啟動)

1 關閉RAC

#檢查&關閉PDB
...

#查看数据库实例状态:
[grid@xag01 ~]$ srvctl status database -d MYRAC1  -f -v
Instance MYRAC11 is running on node xag02. Instance status: Open.
Instance MYRAC12 is running on node xag01. Instance status: Open.

#关闭database
[grid@xag01 ~]$ srvctl stop database -d MYRAC1
#再次查看数据库实例状态:
[grid@xag01 ~]$ srvctl status database -d MYRAC1  -f -v
Instance MYRAC11 is not running on node xag02
Instance MYRAC12 is not running on node xag01

#檢查集群狀態
[grid@xag01 ~]$ crsctl check cluster -all
**************************************************************
xag01:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
xag02:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************

#关闭rac,停止所有节点集群服务
[root@xag02 ~]# /u01/app/12.2.0/grid/bin/crsctl stop cluster -all

#再次檢查集群狀態
[grid@xag01 ~]$ crsctl check cluster -all
**************************************************************
xag01:
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4530: Communications failure contacting Cluster Synchronization Services daemon
CRS-4534: Cannot communicate with Event Manager
**************************************************************
xag02:
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4530: Communications failure contacting Cluster Synchronization Services daemon
CRS-4534: Cannot communicate with Event Manager
**************************************************************

2. 啟動RAC

#開啟rac,啟動所有节点集群服务
[root@xag02 ~]# /u01/app/12.2.0/grid/bin/crsctl start cluster -all
#檢查集群狀態
[grid@xag01 ~]$ crsctl check cluster -all
**************************************************************
xag01:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
xag02:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************

 #啟動database
[grid@xag01 ~]$ srvctl start database -d MYRAC1
#查看数据库实例状态:
[grid@xag01 ~]$ srvctl status database -d MYRAC1  -f -v
Instance MYRAC11 is running on node xag02. Instance status: Open.
Instance MYRAC12 is running on node xag01. Instance status: Open.

#最後啟動PDB
...

四. 實例查詢

1. 查詢當前實例名

[oracle@xag01 ~]$ sql / as sysdba
SQL> select instance_name,host_name,sys_context('USERENV', 'INSTANCE_NAME') as instance_name2 from v$instance;
INSTANCE_NAME    HOST_NAME                     instance_name2                                   
---------------- ----------------------------------------------------
MYRAC12                      xag01.mp.com                     MYRAC12          

五. 自啟動設置

[root@xag01 ~]# /u01/app/12.2.0/grid/bin/crsctl config crs
CRS-4622: Oracle High Availability Services autostart is enabled.
#如果上面检查出来的状态是disable,那么可以通过以下命令进行启用;
[root@xag01 ~]# /u01/app/12.2.0/grid/bin/crsctl enable crs
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,607评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,047评论 2 379
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,496评论 0 335
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,405评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,400评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,479评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,883评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,535评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,743评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,544评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,612评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,309评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,881评论 3 306
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,891评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,136评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,783评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,316评论 2 342

推荐阅读更多精彩内容