Oracle RAC单节点启停
由于单节点操作系统需要重启维护,版本为12C
确认集群的db_unique_name,本初的db_unique_name为orcl
SQL> show parameter name
SQL> select instance_name,status from gv$instance;
INSTANCE_NAME STATUS
---------------- ------------
orcl1 OPEN
orcl2 OPEN
#关闭node1监听,确保应用无法通过监听连接数据库
[grid@node1 ~]$ srvctl stop listener -n node1
#使用crs_stat -t -v命令或者使用srvctl status listener命令检查监听运行情况
[grid@oranode1 ~]$ srvctl status listener -n node1
Listener LISTENER is enabled on node(s): node1
Listener LISTENER is not running on node(s): node1
[grid@oranode2 ~]$ srvctl status listener -n node2
Listener LISTENER is enabled on node(s): node2
Listener LISTENER is running on node(s): node2
#确保关闭前实例上没有session在执行,如果有停机窗口的话建议杀一次local=no的会话
[oracle@oranode1 ~]$ ps -ef |grep -i local=no |wc -l
1
[oracle@oranode1 ~]$ ps -ef |grep -i local=no |cut -c 10-15|xargs kill -9
kill 7803: No such process
--关闭集群节点一上的数据库实例
[grid@oranode1 ~]$ srvctl stop instance -o immediate -d orcl -i orcl1
[oracle@oranode1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Thu Mar 16 12:41:30 2021
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.
#确保数据库实例已经被关闭
[grid@oranode1 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora....DISK.dg ora....up.type 0/5 0/ ONLINE ONLINE node1
ora.DATA.dg ora....up.type 0/5 0/ ONLINE ONLINE node1
ora....ER.lsnr ora....er.type 0/5 0/ ONLINE ONLINE node2
ora....N1.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE node2
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE node1
ora.cvu ora.cvu.type 0/5 0/0 ONLINE ONLINE node2
ora.gsd ora.gsd.type 0/5 0/ OFFLINE OFFLINE
ora....network ora....rk.type 0/5 0/ ONLINE ONLINE node1
ora.oc4j ora.oc4j.type 0/1 0/2 ONLINE ONLINE node2
ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE node1
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE node1
ora....E1.lsnr application 0/5 0/0 OFFLINE OFFLINE
ora....de1.gsd application 0/5 0/0 OFFLINE OFFLINE
ora....de1.ons application 0/3 0/0 ONLINE ONLINE node1
ora....de1.vip ora....t1.type 0/0 0/0 ONLINE ONLINE node1
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE node2
ora....E2.lsnr application 0/5 0/0 ONLINE ONLINE node2
ora....de2.gsd application 0/5 0/0 OFFLINE OFFLINE
ora....de2.ons application 0/3 0/0 ONLINE ONLINE node2
ora....de2.vip ora....t1.type 0/0 0/0 ONLINE ONLINE node2
ora.orcl.db ora....se.type 0/2 0/1 ONLINE ONLINE node2
ora....ry.acfs ora....fs.type 0/5 0/ ONLINE ONLINE node1
ora.scan1.vip ora....ip.type 0/0 0/0 ONLINE ONLINE node2
#可以看到,未关闭集群节点一上的实例前,ora.orcl.db的服务是在节点一上,关闭节点一的数据库实例后,ora.orcl.db已经飘在了节点二上了。
#或者使用srvctl status database 命令检查
[grid@node1 ~]$ srvctl status database -d orcl
Instance orcl1 is not running on node oranode1
Instance orcl2 is running on node oranode2
--关闭集群节点一的ASM服务
[grid@node1 ~]$ srvctl stop asm -n node1
PRCR-1014 : Failed to stop resource ora.asm
PRCR-1065 : Failed to stop resource ora.asm
CRS-2529: Unable to act on 'ora.asm' because that would require stopping or relocating 'ora.CLUSTER_DISK.dg', but the force option was not specified
#此处关闭asm实例在报错,由于ora.CLUSTER_DISK的存在,指明此需要强制指定参数-f才能关闭ASM.此处如果是执行-f参数的话将会已shutdown abort的方式强制关闭数据库,生产环境上执行此命令有风险
--#11Gr2下,ASM是cssd下管理的,需要把cssd关闭后,才能关闭ASM服务
--切换到root下执行crsctl stop crs的方式关闭整个集群节点一的CRS服务
[root@oranode1 ~]# find / -name crsctl
/u01/app/11.2.0/grid/bin/crsctl
[root@oranode1 ~]# /u01/app/11.2.0/grid/bin/crsctl stop crs
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'node1'
CRS-2673: Attempting to stop 'ora.crsd' on 'node1'
CRS-2790: Starting shutdown of Cluster Ready Services-managed resources on 'node1'
CRS-2673: Attempting to stop 'ora.CLUSTER_DISK.dg' on 'node1'
CRS-2673: Attempting to stop 'ora.registry.acfs' on 'node1'
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'node1'
CRS-2673: Attempting to stop 'ora.node1.vip' on 'node1'
CRS-2677: Stop of 'ora.oranode1.vip' on 'node1' succeeded
CRS-2672: Attempting to start 'ora.node1.vip' on 'node2'
CRS-2677: Stop of 'ora.registry.acfs' on 'node1' succeeded
CRS-2677: Stop of 'ora.DATA.dg' on 'node1' succeeded
CRS-2676: Start of 'ora.node1.vip' on 'node2' succeeded
CRS-2677: Stop of 'ora.CLUSTER_DISK.dg' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'node1'
CRS-2677: Stop of 'ora.asm' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.ons' on 'oranode1'
CRS-2677: Stop of 'ora.ons' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.net1.network' on 'node1'
CRS-2677: Stop of 'ora.net1.network' on 'node1' succeeded
CRS-2792: Shutdown of Cluster Ready Services-managed resources on 'node1' has completed
CRS-2677: Stop of 'ora.crsd' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.crf' on 'node1'
CRS-2673: Attempting to stop 'ora.ctssd' on 'node1'
CRS-2673: Attempting to stop 'ora.evmd' on 'node1'
CRS-2673: Attempting to stop 'ora.asm' on 'node1'
CRS-2673: Attempting to stop 'ora.drivers.acfs' on 'node1'
CRS-2673: Attempting to stop 'ora.mdnsd' on 'node1'
CRS-2677: Stop of 'ora.crf' on 'node1' succeeded
CRS-2677: Stop of 'ora.evmd' on 'node1' succeeded
CRS-2677: Stop of 'ora.mdnsd' on 'node1' succeeded
CRS-2677: Stop of 'ora.ctssd' on 'node1' succeeded
CRS-2677: Stop of 'ora.asm' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.cluster_interconnect.haip' on 'node1'
CRS-2677: Stop of 'ora.drivers.acfs' on 'node1' succeeded
CRS-2677: Stop of 'ora.cluster_interconnect.haip' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'node1'
CRS-2677: Stop of 'ora.cssd' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.gipcd' on 'node1'
CRS-2677: Stop of 'ora.gipcd' on 'node1' succeeded
CRS-2673: Attempting to stop 'ora.gpnpd' on 'node1'
CRS-2677: Stop of 'ora.gpnpd' on 'node1' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'node1' has completed
CRS-4133: Oracle High Availability Services has been stopped.
#可以看到,CRS命令执行输出,节点一的cluster服务已经完全飘在了节点二上。
[grid@oranode2 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora....DISK.dg ora....up.type 0/5 0/ ONLINE ONLINE node2
ora.DATA.dg ora....up.type 0/5 0/ ONLINE ONLINE node2
ora....ER.lsnr ora....er.type 0/5 0/ ONLINE ONLINE node2
ora....N1.lsnr ora....er.type 0/5 0/0 ONLINE ONLINE node2
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE node2
ora.cvu ora.cvu.type 0/5 0/0 ONLINE ONLINE node2
ora.gsd ora.gsd.type 0/5 0/ OFFLINE OFFLINE
ora....network ora....rk.type 0/5 0/ ONLINE ONLINE node2
ora.oc4j ora.oc4j.type 0/1 0/2 ONLINE ONLINE node2
ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE node2
ora....de1.vip ora....t1.type 0/0 0/0 ONLINE ONLINE node2
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE node2
ora....E2.lsnr application 0/5 0/0 ONLINE ONLINE node2
ora....de2.gsd application 0/5 0/0 OFFLINE OFFLINE
ora....de2.ons application 0/3 0/0 ONLINE ONLINE node2
ora....de2.vip ora....t1.type 0/0 0/0 ONLINE ONLINE node2
ora.orcl.db ora....se.type 0/2 0/1 ONLINE ONLINE node2
ora....ry.acfs ora....fs.type 0/5 0/ ONLINE ONLINE node2
ora.scan1.vip ora....ip.type 0/0 0/0 ONLINE ONLINE node2
--确保ASM服务已经关闭
[grid@oranode2 ~]$ srvctl status asm -n node1
ASM is not running on node1
[grid@oranode2 ~]$ srvctl status asm -n node2
ASM is running on node2
--验证集群节点一的oracle相关服务已经完全关闭
[grid@oranode1 ~]$ ps -ef |grep -i ora
root 1555 1 0 12:03 ? 00:00:10 /u01/app/11.2.0/grid/jdk/jre/bin/java -Xms64m -Xmx256m -classpath /u01/app/11.2.0/grid/tfa/node1/tfa_home/jar/RATFA.jar:/u01/app/11.2.0/grid/tfa/node1/tfa_home/jar/je-4.0.103.jar:/u01/app/11.2.0/grid/tfa/node1/tfa_home/jar/ojdbc6.jar oracle.rat.tfa.TFAMain /u01/app/11.2.0/grid/tfa/node1/tfa_home
root 1775 1704 0 12:03 ? 00:00:01 hald-addon-storage: polling /dev/sr0 (every 2 sec)
grid 11980 11916 0 13:14 pts/0 00:00:00 grep -i ora
[grid@oranode1 ~]$ ps -ef |grep -i asm
grid 11988 11916 0 13:14 pts/0 00:00:00 grep -i asm
--确保集群节点二可以正常访问
SQL> select instance_name,status from gv$instance;
INSTANCE_NAME STATUS
---------------- ------------
orcl2 OPEN
#在配合os补丁打完后需要开启节点一上ORACLE服务
开启步骤:
[root@oranode1 ~]# /u01/app/11.2.0/grid/bin/crsctl start crs
CRS-4123: Oracle High Availability Services has been started.
--确保节点一上CRS服务已经开启成功
[grid@oranode1 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....DISK.dg ora....up.type ONLINE ONLINE node1
ora.DATA.dg ora....up.type ONLINE ONLINE node1
ora....ER.lsnr ora....er.type ONLINE ONLINE node2
ora....N1.lsnr ora....er.type ONLINE ONLINE node2
ora.asm ora.asm.type ONLINE ONLINE node1
ora.cvu ora.cvu.type ONLINE ONLINE node2
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE node1
ora.oc4j ora.oc4j.type ONLINE ONLINE node2
ora.ons ora.ons.type ONLINE ONLINE node1
ora....SM1.asm application ONLINE ONLINE node1
ora....E1.lsnr application OFFLINE OFFLINE
ora....de1.gsd application OFFLINE OFFLINE
ora....de1.ons application ONLINE ONLINE node1
ora....de1.vip ora....t1.type ONLINE ONLINE node1
ora....SM2.asm application ONLINE ONLINE node2
ora....E2.lsnr application ONLINE ONLINE node2
ora....de2.gsd application OFFLINE OFFLINE
ora....de2.ons application ONLINE ONLINE node2
ora....de2.vip ora....t1.type ONLINE ONLINE node2
ora.orcl.db ora....se.type ONLINE ONLINE node2
ora....ry.acfs ora....fs.type ONLINE ONLINE node1
ora.scan1.vip ora....ip.type ONLINE ONLINE node2
--确保ASM服务已经运行在两个节点上
[grid@oranode1 ~]$ srvctl status asm
ASM is running on node2,node1
--开启集群节点一数据库实例
[grid@oranode1 ~]$ srvctl start instance -d orcl -i orcl1
--验证是否启动成功
[grid@oranode1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node node1
Instance orcl2 is running on node node2
--开启完成后集群服务校验,确保服务开启成功且各自运行在集群节点上
[grid@oranode1 ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....DISK.dg ora....up.type ONLINE ONLINE node1
ora.DATA.dg ora....up.type ONLINE ONLINE node1
ora....ER.lsnr ora....er.type ONLINE ONLINE node1
ora....N1.lsnr ora....er.type ONLINE ONLINE node2
ora.asm ora.asm.type ONLINE ONLINE node1
ora.cvu ora.cvu.type ONLINE ONLINE node2
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE node1
ora.oc4j ora.oc4j.type ONLINE ONLINE node2
ora.ons ora.ons.type ONLINE ONLINE node1
ora....SM1.asm application ONLINE ONLINE node1
ora....E1.lsnr application ONLINE ONLINE node1
ora....de1.gsd application OFFLINE OFFLINE
ora....de1.ons application ONLINE ONLINE node1
ora....de1.vip ora....t1.type ONLINE ONLINE node1
ora....SM2.asm application ONLINE ONLINE node2
ora....E2.lsnr application ONLINE ONLINE node2
ora....de2.gsd application OFFLINE OFFLINE
ora....de2.ons application ONLINE ONLINE node2
ora....de2.vip ora....t1.type ONLINE ONLINE node2
ora.orcl.db ora....se.type ONLINE ONLINE node1
ora....ry.acfs ora....fs.type ONLINE ONLINE node1
ora.scan1.vip ora....ip.type ONLINE ONLINE node2
[grid@node1 ~]$
--节点停机开启操作与节点一上操作顺序一致