一、查詢命令
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