• oracle 11g rac集群重启顺序以及常用管理命令简介


    1、关闭数据库

    切换至oracle用户

    1.1 查看数据库实例状态

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

    1.2 停止所有节点上实例

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

    1.3 确认数据库实例状态

    
    [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用户操作

    2.1 查看节点集群状态

    切换至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
    
    

    2.2 停止has服务

    需要在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步

    2.3 停止crs服务

    需要在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

    2.4 停止节点集群服务

    停止节点集群服务,必须以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 启动集群

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

    3.1 单节点启动

    两个节点都要执行

    节点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
    
    

    3.2 所有节点启动

    单节点执行即可

    
    [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.
    
    

    3.3 检查集群状态

    
    [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的所有实例

    4.1 启动所有节点数据库实例

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

    4.2 查看多有节点数据库实例状态

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

    4.3.详细输出资源全名称并检查状态

    
    [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常用命令

    5.1 常用srvctl命令

    指定dbname上某个实例

    srvctl start|stop|status instance -d -i <instance_name>

    5.2 显示RAC下所有实例配置与状态

    srvctl status|config database -d

    5.3 显示所有节点的应用服务(VIP,GSD,listener,ONS)

    srvctl start|stop|status nodeapps -n<node_name>

    5.4 ASM进程服务管理

    srvctl start|stop|status|config asm -n [-i <asm_inst_name>] [-o<oracle_home>]

    srvctl config asm -a

    srvctl status asm -a

    5.5 获取所有的环境信息:

    srvctl getenv database -d [-i<instance_name>]

    5.6 设置全局环境和变量:

    srvctl setenv database -d -t LANG=en

    5.7 在OCR中删除已有的数据库信息

    srvctl remove database -d

    5.8 向OCR中添加一个数据库的实例:

    srvctl add instance -d -i<instance_name> -n

    srvctl add instance -d -i<instance_name> -n

    5.9 检查监听的状态

    srvctl status listener -l +实例名

    srvctl config listener -a

    5.10 SCAN配置信息

    srvctl config scan

    5.11 SCAN listener状态信息

    srvctl status scan

    小结:

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

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

  • 相关阅读:
    Selenium断言的使用,等待
    Selenium的鼠标事件,键盘事件
    json,HTTP协议
    HTML,js的基础知识
    Selenium3详解:元素定位方法
    Python操纵Excel,数据库
    Spring拦截器(权限的管理)
    完成登陆功能
    配置使用sitemesh
    Hibernate+pager-taglib实现分页功能
  • 原文地址:https://www.cnblogs.com/yj411511/p/12459533.html
Copyright © 2020-2023  润新知