oracle 11g rac集群重启顺序以及常用管理命令简介
阅读原文时间:2023年07月09日阅读:5

转至:https://www.cnblogs.com/yj411511/p/12459533.html

目录

1、关闭数据库

切换至oracle用户

[oracle@db1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node db1
Instance orcl2 is running on node db2

[oracle@db1 ~]$ srvctl stop database -d orcl

[oracle@db1 ~]$ srvctl status database -d orcl
Instance orcl1 is not running on node db1
Instance orcl2 is not running on node db2
[oracle@db2 ~]$ srvctl status database -d orcl
Instance orcl1 is not running on node db1
Instance orcl2 is not running on node db2

2、停止HAS(High Availability Services),必须以root用户操作

切换至grid用户,查看本节点集群进程状态

crsctl check crs

[grid@db1 ~]$ 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
[grid@db2 ~]$ 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

查看本节点集群状态

[grid@db1 ~]$ crs_stat -t -v

Name Type R/RA F/FT Target State Host

ora.DATA.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora.FRA.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora….ER.lsnr ora….er.type 0/5 0/ ONLINE ONLINE db1
ora….N1.lsnr ora….er.type 0/5 0/0 ONLINE ONLINE db2
ora.ORC.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora.REDO.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE db1
ora.cvu ora.cvu.type 0/5 0/0 ONLINE ONLINE db2
ora….SM1.asm application 0/5 0/0 ONLINE ONLINE db1
ora….B1.lsnr application 0/5 0/0 ONLINE ONLINE db1
ora.db1.gsd application 0/5 0/0 ONLINE OFFLINE
ora.db1.ons application 0/3 0/0 ONLINE ONLINE db1
ora.db1.vip ora….t1.type 0/0 0/0 ONLINE ONLINE db1
ora….SM2.asm application 0/5 0/0 ONLINE ONLINE db2
ora….B2.lsnr application 0/5 0/0 ONLINE ONLINE db2
ora.db2.gsd application 0/5 0/0 ONLINE OFFLINE
ora.db2.ons application 0/3 0/0 ONLINE ONLINE db2
ora.db2.vip ora….t1.type 0/0 0/0 ONLINE ONLINE db2
ora.gsd ora.gsd.type 0/5 0/ ONLINE OFFLINE
ora….network ora….rk.type 0/5 0/ ONLINE ONLINE db1
ora.oc4j ora.oc4j.type 0/1 0/2 ONLINE ONLINE db2
ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE db1
ora.orcl.db ora….se.type 0/2 0/1 ONLINE ONLINE db1
ora….ry.acfs ora….fs.type 0/5 0/ ONLINE ONLINE db1
ora.scan1.vip ora….ip.type 0/0 0/0 ONLINE ONLINE db2

[grid@db2 ~]$ crs_stat -t -v

Name Type R/RA F/FT Target State Host

ora.DATA.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora.FRA.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora….ER.lsnr ora….er.type 0/5 0/ ONLINE ONLINE db1
ora….N1.lsnr ora….er.type 0/5 0/0 ONLINE ONLINE db2
ora.ORC.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora.REDO.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE db1
ora.cvu ora.cvu.type 0/5 0/0 ONLINE ONLINE db2
ora….SM1.asm application 0/5 0/0 ONLINE ONLINE db1
ora….B1.lsnr application 0/5 0/0 ONLINE ONLINE db1
ora.db1.gsd application 0/5 0/0 ONLINE OFFLINE
ora.db1.ons application 0/3 0/0 ONLINE ONLINE db1
ora.db1.vip ora….t1.type 0/0 0/0 ONLINE ONLINE db1
ora….SM2.asm application 0/5 0/0 ONLINE ONLINE db2
ora….B2.lsnr application 0/5 0/0 ONLINE ONLINE db2
ora.db2.gsd application 0/5 0/0 ONLINE OFFLINE
ora.db2.ons application 0/3 0/0 ONLINE ONLINE db2
ora.db2.vip ora….t1.type 0/0 0/0 ONLINE ONLINE db2
ora.gsd ora.gsd.type 0/5 0/ ONLINE OFFLINE
ora….network ora….rk.type 0/5 0/ ONLINE ONLINE db1
ora.oc4j ora.oc4j.type 0/1 0/2 ONLINE ONLINE db2
ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE db1
ora.orcl.db ora….se.type 0/2 0/1 ONLINE ONLINE db1
ora….ry.acfs ora….fs.type 0/5 0/ ONLINE ONLINE db1
ora.scan1.vip ora….ip.type 0/0 0/0 ONLINE ONLINE db2

需要在RAC的所有节点上执行,启动也一样。has与crs等同

[root@db1 ~]# find / -name crsctl
/u01/app/grid/11.2.0/bin/crsctl
[root@db1 ~]# cd /u01/app/grid/11.2.0/bin/
[root@db1 bin]# ./crsctl stop has -f

[root@db2 ~]# find / -name crsctl
/u01/app/grid/11.2.0/bin/crsctl
[root@db2 ~]# cd /u01/app/grid/11.2.0/bin/
[root@db2 bin]# ./crsctl stop has -f

其实停止HAS服务以后集群已经关停,可以查看集群状态确认,无需下面3、4步

需要在RAC的所有节点上执行,启动也一样。has与crs等同
[root@db1 bin]# ./crsctl stop crs -f
CRS-4544: Unable to connect to OHAS
[root@db2 bin]# ./crsctl stop crs -f
CRS-4544: Unable to connect to OHAS

停止节点集群服务,必须以root用户:

[root@db1 oracle]# cd /u01/grid/11.2.0/grid/bin
[root@db1 bin]# ./crsctl stop cluster ----停止本节点集群服务
[root@db1 bin]# ./crsctl stop cluster -all ---停止所有节点服务
也可以如下控制所停节点:
[root@rac1 bin]# crsctl stop cluster -n rac1 rac2
CRS-2677: Stop of 'ora.cssd' on 'rac1' succeeded
CRS-2677: Stop of 'ora.cssd' on 'rac2' succeeded

3 启动集群

可以单节点启动也可以双节点同时启动,下面分别介绍

两个节点都要执行

节点1

[root@db1 bin]# ./crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[root@db1 bin]# ./crsctl start crs
CRS-4640: Oracle High Availability Services is already active
CRS-4000: Command Start failed, or completed with errors.
[root@db1 bin]# ./crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4529: Cluster Synchronization Services is online
CRS-4534: Cannot communicate with Event Manager

节点2

[root@db2 bin]# ./crsctl start has
CRS-4123: Oracle High Availability Services has been started.
[root@db2 bin]# ./crsctl start crs
CRS-4640: Oracle High Availability Services is already active
CRS-4000: Command Start failed, or completed with errors.
[root@db2 bin]# ./crsctl check crs
CRS-4638: Oracle High Availability Services is online
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4529: Cluster Synchronization Services is online
CRS-4534: Cannot communicate with Event Manager

单节点执行即可

[root@db2 bin]# ./crsctl start cluster -n db1 db2
CRS-4690: Oracle Clusterware is already running on 'db1'
CRS-4690: Oracle Clusterware is already running on 'db2'
CRS-4000: Command Start failed, or completed with errors.

或者

[root@db2 bin]# ./crsctl start cluster -all
CRS-4690: Oracle Clusterware is already running on 'db1'
CRS-4690: Oracle Clusterware is already running on 'db2'
CRS-4000: Command Start failed, or completed with errors.

[root@db1 bin]# ./crs_stat -t -v

Name Type R/RA F/FT Target State Host

ora.DATA.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora.FRA.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora….ER.lsnr ora….er.type 0/5 0/ ONLINE ONLINE db1
ora….N1.lsnr ora….er.type 0/5 0/0 ONLINE ONLINE db1
ora.ORC.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora.REDO.dg ora….up.type 0/5 0/ ONLINE ONLINE db1
ora.asm ora.asm.type 0/5 0/ ONLINE ONLINE db1
ora.cvu ora.cvu.type 0/5 0/0 ONLINE ONLINE db2
ora….SM1.asm application 0/5 0/0 ONLINE ONLINE db1
ora….B1.lsnr application 0/5 0/0 ONLINE ONLINE db1
ora.db1.gsd application 0/5 0/0 ONLINE OFFLINE
ora.db1.ons application 0/3 0/0 ONLINE ONLINE db1
ora.db1.vip ora….t1.type 0/0 0/0 ONLINE ONLINE db1
ora….SM2.asm application 0/5 0/0 ONLINE ONLINE db2
ora….B2.lsnr application 0/5 0/0 ONLINE ONLINE db2
ora.db2.gsd application 0/5 0/0 ONLINE OFFLINE
ora.db2.ons application 0/3 0/0 ONLINE ONLINE db2
ora.db2.vip ora….t1.type 0/0 0/0 ONLINE ONLINE db2
ora.gsd ora.gsd.type 0/5 0/ ONLINE OFFLINE
ora….network ora….rk.type 0/5 0/ ONLINE ONLINE db1
ora.oc4j ora.oc4j.type 0/1 0/2 ONLINE ONLINE db2
ora.ons ora.ons.type 0/3 0/ ONLINE ONLINE db1
ora.orcl.db ora….se.type 0/2 0/1 OFFLINE OFFLINE
ora….ry.acfs ora….fs.type 0/5 0/ ONLINE ONLINE db1
ora.scan1.vip ora….ip.type 0/0 0/0 ONLINE ONLINE db1

说明:

英文解释:

ora.gsd is OFFLINE by default ifthere is no 9i database in the cluster.
ora.oc4j is OFFLINE in 11.2.0.1 as DatabaseWorkload Management(DBWLM) is unavailable. these can be ignored in11gR2 RAC.

中文解释:

ora.gsd是集群服务中用于与9i数据库进行通信的一个进程,在当前版本中为了向后兼容才保存下来,状态为OFFLINE不影响CRS的正常运行与性能,我们忽略即可
ora.oc4j是在11.2.0.2以上版本中有效的服务进程,用于DBWLM的资源管理,因此在11.2.0.1以下版本并没有使用

4、启动数据库

oracl用户执行srvctl命令:
语法:srvctl start|stop|status database -d dbname [-o immediate]
作用:可以一次性启动dbname的所有实例

[oracle@db1 ~]$ srvctl start database -d orcl

[oracle@db1 ~]$ srvctl status database -d orcl
Instance orcl1 is running on node db1
Instance orcl2 is running on node db2

[grid@db1 ~]$ crsctl status resource -t

NAME TARGET STATE SERVER STATE_DETAILS

Local Resources

ora.DATA.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.FRA.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.LISTENER.lsnr
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.ORC.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.REDO.dg
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.asm
ONLINE ONLINE db1 Started
ONLINE ONLINE db2 Started
ora.gsd
ONLINE OFFLINE db1
ONLINE OFFLINE db2
ora.net1.network
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.ons
ONLINE ONLINE db1
ONLINE ONLINE db2
ora.registry.acfs
ONLINE ONLINE db1

ONLINE ONLINE db2

Cluster Resources

ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       db1
ora.cvu
      1        ONLINE  ONLINE       db2
ora.db1.vip
      1        ONLINE  ONLINE       db1
ora.db2.vip
      1        ONLINE  ONLINE       db2
ora.oc4j
      1        ONLINE  ONLINE       db2
ora.orcl.db
      1        ONLINE  ONLINE       db1                      Open
      2        ONLINE  ONLINE       db2                      Open
ora.scan1.vip
      1        ONLINE  ONLINE       db1   

[grid@db1 ~]$ crsctl status resource
NAME=ora.DATA.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.FRA.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.LISTENER.lsnr
TYPE=ora.listener.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.LISTENER_SCAN1.lsnr
TYPE=ora.scan_listener.type
TARGET=ONLINE
STATE=ONLINE on db1

NAME=ora.ORC.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.REDO.dg
TYPE=ora.diskgroup.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.asm
TYPE=ora.asm.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.cvu
TYPE=ora.cvu.type
TARGET=ONLINE
STATE=ONLINE on db2

NAME=ora.db1.vip
TYPE=ora.cluster_vip_net1.type
TARGET=ONLINE
STATE=ONLINE on db1

NAME=ora.db2.vip
TYPE=ora.cluster_vip_net1.type
TARGET=ONLINE
STATE=ONLINE on db2

NAME=ora.gsd
TYPE=ora.gsd.type
TARGET=ONLINE , ONLINE
STATE=OFFLINE, OFFLINE

NAME=ora.net1.network
TYPE=ora.network.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.oc4j
TYPE=ora.oc4j.type
TARGET=ONLINE
STATE=ONLINE on db2

NAME=ora.ons
TYPE=ora.ons.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.orcl.db
TYPE=ora.database.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.registry.acfs
TYPE=ora.registry.acfs.type
TARGET=ONLINE       , ONLINE
STATE=ONLINE on db1, ONLINE on db2

NAME=ora.scan1.vip
TYPE=ora.scan_vip.type
TARGET=ONLINE
STATE=ONLINE on db1

5、rac常用命令

指定dbname上某个实例

srvctl start|stop|status instance -d -i

srvctl status|config database -d

srvctl start|stop|status nodeapps -n

srvctl start|stop|status|config asm -n [-i ] [-o]

srvctl config asm -a

srvctl status asm -a

srvctl getenv database -d [-i]

srvctl setenv database -d -t LANG=en

srvctl remove database -d

srvctl add instance -d -i -n

srvctl add instance -d -i -n

srvctl status listener -l +实例名

srvctl config listener -a

srvctl config scan

srvctl status scan

小结:

crsctl命令是一个集群级别命令,可以对所有集群资源进行统一启动、停止等管理操作

srvctl命令是一个服务级别命令,可以对单一服务资源进行统一启动、停止等管理操作

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器