Oracle 11g R2的启动与关闭(原创)

概述

Oracle 11gR2 中对CRSD资源进行了重新分类: Local Resources 和 Cluster Resources。
[grid@rac2 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE       SERVER                  STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE      rac1
               ONLINE  ONLINE      rac2
ora.FRA.dg
               ONLINE  ONLINE      rac1
               ONLINE  ONLINE      rac2
ora.LISTENER.lsnr
               ONLINE  ONLINE      rac1
               ONLINE  ONLINE      rac2
ora.OCRVOTING.dg
               ONLINE  ONLINE      rac1
               ONLINE  ONLINE      rac2
ora.asm
               ONLINE  ONLINE      rac1                    Started
               ONLINE  ONLINE      rac2                    Started
ora.gsd
               OFFLINE OFFLINE      rac1
               OFFLINE OFFLINE      rac2
ora.net1.network
               ONLINE  ONLINE      rac1
               ONLINE  ONLINE      rac2
ora.ons
               ONLINE  ONLINE      rac1
               ONLINE  ONLINE      rac2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
     1        ONLINE  ONLINE      rac1
ora.cvu
     1        ONLINE  ONLINE      rac1
ora.oc4j
     1        ONLINE  ONLINE      rac1
ora.rac1.vip
     1        ONLINE  ONLINE      rac1
ora.rac2.vip
     1        ONLINE  ONLINE      rac2
ora.scan1.vip
     1        ONLINE  ONLINE      rac1
ora.sdd.db
     1        ONLINE  ONLINE      rac1                     Open
     2        ONLINE  ONLINE      rac2                     Open
Local Resources 属于应用层,
Cluster Resources 属于集群层。
我们这里要说的Oracle Restart 就是对Cluster Resource的一个管理。
在Oracle 10g RAC 安装时,在运行root.sh时,会在/etc/inittab文件的最后加入ora.crs,ora.cssd,ora.evmd 三个进程。 这样以后每次系统启动时,Clusterware 也会自动启动,其中EVMD和CRSD 两个进程如果出现异常,则系统会自动重启这两个进程,如果是CSSD 进程异常,系统会立即重启。
而在Oracle 11gR2中,只会将ohasd 写入/etc/inittab 文件。
官网对OHASD 的说明:
Oracle High Availability Services Daemon(OHASD) :This process anchors the lower part of the Oracle Clusterwarestack, which consists of processes that facilitate cluster operations.
可以使用如下命令查看OHASD管理的资源:
[grid@rac2 ~]$ crsctl stat res -init -t
[grid@rac2 ~]$ ps -ef|grep ohasd
root     1057     1  0 Dec21 ?        00:00:00 /bin/sh /etc/init.d/init.ohasdrun
root     2274     1  0 Dec21 ?        00:22:53/u01/app/grid/11.2.0/bin/ohasd.bin reboot
启动和停止集群
在Oracle 11gR2 下的RAC,架构发生了变化。CRS的信息也是放在ASM 实例里的,所以要关asm,必须关闭crs, 如果还使用了acfs的话,一关crs那么acfs里的信息也不能访问了,所以一般不重启机器,不轻易关crs, 其他的service可以根据自己的需要去stop/start。
注意:11g RAC 开启资源相对比较慢(即使命令后面显示的资源都start succeeded,通过crs_stat -t查看都不一定online), 需要耐心并查看log。
使用crsctl stop has/crsctl stopcrs
用root用户,在Oracle11gR2中停止和启动集群的命令如下:
#crsctl stop has [-f]
#crsctl start has
对于crsctl stop has 只有一个可选的参数就是-f,该命令只能停执行该命令服务器上的HAS.而不能停所有节点上的。所以要把RAC 全部停掉,需要在所有节点执行该命令。
注意:下面的2个命令:使用crs 和使用has并不完全一致
#crsctl stop crs [-f]          /*   关闭集群相关资源和服务,和crsctl stop has等效 */
#crsctl start crs              /*   开启集群相关资源和服务,但无法启动css服务与crsctl start has不一致, */
--停止HAS
[root@rac1 bin]# ./crsctl stop has
CRS-2791:Starting shutdown of Oracle High Availability Services-managed resources on'rac1'
CRS-2673:Attempting to stop 'ora.crsd' on 'rac1'
CRS-2790:Starting shutdown of Cluster Ready Services-managed resources on 'rac1'
CRS-2673:Attempting to stop 'ora.LISTENER_SCAN1.lsnr' on 'rac1'
CRS-2673:Attempting to stop 'ora.OCRVOTING.dg' on 'rac1'
CRS-2673:Attempting to stop 'ora.sdd.db' on 'rac1'
CRS-2673:Attempting to stop 'ora.LISTENER.lsnr' on 'rac1'
CRS-2673:Attempting to stop 'ora.oc4j' on 'rac1'
CRS-2673:Attempting to stop 'ora.cvu' on 'rac1'
CRS-2677: Stopof 'ora.LISTENER_SCAN1.lsnr' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.scan1.vip' on 'rac1'
CRS-2677: Stopof 'ora.LISTENER.lsnr' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.rac1.vip' on 'rac1'
CRS-2677: Stopof 'ora.rac1.vip' on 'rac1' succeeded
CRS-2672:Attempting to start 'ora.rac1.vip' on 'rac2'
CRS-2677: Stopof 'ora.scan1.vip' on 'rac1' succeeded
CRS-2672:Attempting to start 'ora.scan1.vip' on 'rac2'
CRS-2676:Start of 'ora.scan1.vip' on 'rac2' succeeded
CRS-2676:Start of 'ora.rac1.vip' on 'rac2' succeeded
CRS-2672:Attempting to start 'ora.LISTENER_SCAN1.lsnr' on 'rac2'
CRS-2677: Stopof 'ora.sdd.db' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.DATA.dg' on 'rac1'
CRS-2673:Attempting to stop 'ora.FRA.dg' on 'rac1'
CRS-2676:Start of 'ora.LISTENER_SCAN1.lsnr' on 'rac2' succeeded
CRS-2677: Stopof 'ora.FRA.dg' on 'rac1' succeeded
CRS-2677: Stopof 'ora.DATA.dg' on 'rac1' succeeded
CRS-2677: Stopof 'ora.oc4j' on 'rac1' succeeded
CRS-2672:Attempting to start 'ora.oc4j' on 'rac2'
CRS-2677: Stopof 'ora.cvu' on 'rac1' succeeded
CRS-2672:Attempting to start 'ora.cvu' on 'rac2'
CRS-2676:Start of 'ora.cvu' on 'rac2' succeeded
CRS-2677: Stopof 'ora.OCRVOTING.dg' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.asm' on 'rac1'
CRS-2677: Stopof 'ora.asm' on 'rac1' succeeded
CRS-2676:Start of 'ora.oc4j' on 'rac2' succeeded
CRS-2673:Attempting to stop 'ora.ons' on 'rac1'
CRS-2677: Stopof 'ora.ons' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.net1.network' on 'rac1'
CRS-2677: Stopof 'ora.net1.network' on 'rac1' succeeded
CRS-2792:Shutdown of Cluster Ready Services-managed resources on 'rac1' has completed
CRS-2677: Stopof 'ora.crsd' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.mdnsd' on 'rac1'
CRS-2673:Attempting to stop 'ora.ctssd' on 'rac1'
CRS-2673:Attempting to stop 'ora.evmd' on 'rac1'
CRS-2673:Attempting to stop 'ora.asm' on 'rac1'
CRS-2677: Stopof 'ora.evmd' on 'rac1' succeeded
CRS-2677: Stopof 'ora.mdnsd' on 'rac1' succeeded
CRS-2677: Stopof 'ora.ctssd' on 'rac1' succeeded
CRS-2677: Stopof 'ora.asm' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.cluster_interconnect.haip' on 'rac1'
CRS-2677: Stopof 'ora.cluster_interconnect.haip' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.cssd' on 'rac1'
CRS-2677: Stopof 'ora.cssd' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.crf' on 'rac1'
CRS-2677: Stopof 'ora.crf' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.gipcd' on 'rac1'
CRS-2677: Stopof 'ora.gipcd' on 'rac1' succeeded
CRS-2673:Attempting to stop 'ora.gpnpd' on 'rac1'
CRS-2677: Stopof 'ora.gpnpd' on 'rac1' succeeded
CRS-2793:Shutdown of Oracle High Availability Services-managed resources on 'rac1' has completed
CRS-4133:Oracle High Availability Services has been stopped.
注意:我这里测试的是Oracle11gR2的环境,我们在节点1上执行该命令,只把节点1上的进程停了,而把相关的资源转移到我们的节点2上了,因此也证实了我们上面的说的,该命令只争对当前服务器有效。
--启动HAS:
[root@rac1bin]# ./crsctl start has
CRS-4123:Oracle High Availability Services has been started.
从上面看只是启动了HAS。实际上后面会把Oracle Restart 管理的资源都会启动。这个可以使用crs_stat命令来进程验证,不过Oracle 11g的进程启动过程比较慢,需要耐心等待。
[root@rac1u01]# sh crs_stat.sh
Name                           Target     State     Host
---------------------------------------- ---------  -------
ora.DATA.dg                    ONLINE     ONLINE    rac1
ora.FRA.dg                     ONLINE     ONLINE    rac1
ora.LISTENER.lsnr              ONLINE     ONLINE    rac1
ora.LISTENER_SCAN1.lsnr        ONLINE     ONLINE    rac2
ora.OCRVOTING.dg               ONLINE     ONLINE    rac1
ora.asm                        ONLINE     ONLINE    rac1
ora.cvu                        ONLINE     ONLINE    rac2
ora.gsd                        OFFLINE    OFFLINE
ora.net1.network               ONLINE     ONLINE    rac1
ora.oc4j                       ONLINE     ONLINE    rac2
ora.ons                        ONLINE     ONLINE    rac1
ora.rac1.ASM1.asm              ONLINE     ONLINE    rac1
ora.rac1.LISTENER_RAC1.lsnr    ONLINE    ONLINE     rac1
ora.rac1.gsd                   OFFLINE    OFFLINE
ora.rac1.ons                   ONLINE     ONLINE    rac1
ora.rac1.vip                   ONLINE     ONLINE    rac1
ora.rac2.ASM2.asm              ONLINE     ONLINE    rac2
ora.rac2.LISTENER_RAC2.lsnr    ONLINE    ONLINE     rac2
ora.rac2.gsd                   OFFLINE    OFFLINE
ora.rac2.ons                   ONLINE     ONLINE    rac2
ora.rac2.vip                   ONLINE     ONLINE    rac2
ora.scan1.vip                  ONLINE     ONLINE    rac2
ora.sdd.db                     ONLINE     ONLINE    rac2
关闭和启动数据库流程
关闭时需先关闭DB再关闭ohas服务

以oracl用户执行srvctl命令:
[oracle@rac1 ~]$ srvctl stop database -d ORCL ---停止所有节点上的实例
然后查看状态:
[oracle@rac1 ~]$ srvctl status database -d orcl
Instance rac1 is not running on node rac1
Instance rac2 is not running on node rac2
2,在所有节点停止HAS(High Availability Services),必须以root用户
[root@rac1 oracle]# cd /u01/grid/11.2.0/grid/bin
[root@rac1 bin]# ./crsctl stop has -f

[root@rac2 oracle]# cd /u01/grid/11.2.0/grid/bin
[root@rac2 bin]# ./crsctl stop has -f
对于crsctl stop has 只有一个可选的参数就是-f,该命令只能停执行该命令服务器上的HAS而不能停所有节点上的。所以要把RAC全部停掉,需要在所有节点执行该命令。
启动RAC

在所有节点启动HAS

[root@rac1bin]# ./crsctl start has
CRS-4123:Oracle High Availability Services has been started.

[root@rac2 bin]# ./crsctl start has
CRS-4123:Oracle High Availability Services has been started.
如果DB或者所需服务没有被HAS启动,下面以启动DB为例

[oracle@rac1 ~]$ srvctl start database -d ORCL

 

参考至:http://blog.csdn.net/tianlesoftware/article/details/8435670

               http://blog.itpub.net/628922/viewspace-761999

               http://blog.csdn.net/tianlesoftware/article/details/8435772

如有错误,欢迎指正

邮箱:[email protected]

你可能感兴趣的:(oracle 11g)