zoukankan      html  css  js  c++  java
  • Oracle-----RAC重启步骤 RAC管理(crs_stat、crsctl、srvctl)

    查询当前数据名
    方法一:select name from v$database;
    方法二:show parameter db
    方法三:查看参数文件。

    查询当前数据库实例名
    方法一:select instance_name from v$instance;
    方法二:show parameter instance
    方法三:在参数文件中查询。

    oracle中:
    1、查询数据库名:select name,dbid from v$database;或者show parameter db_name;


    2、查询实例名:select instance_name from v$instance;或者show parameter instance_name;


    3、查询数据库域名:select value from v$parameter where name='db_domain';或者show parameter domain;


    4、查询数据库服务器:select value from v$parameter where name='service_name';或者show parameter service;或者show parameter names;


    5、数据库服务名:此参数是数据库标识类参数,用service_name表示。数据库如果有域,则数据库服务名就是全局数据库名;如果没有,则数据库服务名就是数据库名。查询:show parameter service_name;

    Oracle Clusterware的命令集可以分为以下4种:

     
    节点层:osnodes 


    网络层:oifcfg 


    集群层:crsctl, ocrcheck,ocrdump,ocrconfig 


    应用层:srvctl,onsctl,crs_stat 


    下面分别来介绍这些命令。

    1、节点层

    olsnodes,这个命令用来显示集群点列表,可用的参数如下:

    $olsnodes -h

    用法: olsnodes [-n] [-p][-i] [<node> | -l] [-g] [-v] 


    -n打印节点编号和节点名 
    -p打印专用互联名和节点名 
    -i打印虚拟IP名和节点名 
    <node>打印指定节点的信息 
    -l打印本地节点的信息 
    -g启用事件记录 
    -v在详细模式下运行

    这些参数可以混合使用。 
    [root@rac1 bin]#$olsnodes

    racnode1

    racnode2 
    [root@rac1 bin]#olsnodes-n

    racnode11

    racnode22

    注:若命令不能运行,添加path,或直接进入命令所在目录运行。本例位于:

    /u01/crs/oracle/product/11.1.0/crs/bin

    RAC:RealApplicationCluster(真正应用集群),应用越来越广泛了。RAC技术作为oracle数据库集群环境,它的管理有自己的一整套知识,我在此来演示一下rac的重启过程。

     

    oracle常用管理命令:

    1、crs打头的命令,主要用户集群底层结构的管理,位于$oracle_crs_home/bin下,一般在系统安装完毕后只用到“crs_stat-t”就够了。

     

    2、srvctl打头的命令,用于管理和构造集群配置信息。它用于修改配置属性、集群服务停启、高可用服务的添加和删除、激活各种服务等,它用的最广泛。

     

    命令格式:srvctl  command  object【options】

    command有start、stop、remove;object有database、instance;options为命令属性。通常-i指定实例,-n指定节点。

     

    3、sql*plus命令,他用于集群的内部一级的管理,如实例级别的启动、关闭和数据库操作等。

     

    srvctl  status  database  -d  数据库名     //查看节点信息

     

    Crs_stat//查看节点状态

     

     

    可以看到数据节点它由两个实例组成一个数据库,分别运行不同的节点,且状态ok

    2.首先关闭数据库

    Srvctl  stop   database  -d  数据库名

     

    3、分别关闭连个节点

    分别登陆相应的服务器,输入下面的命令关闭节点

    Srvctl   stop  nodeapps  -n  节点1/节点2

    4、重启数据库

    完成数据的一些操作后,通过srvctl  start  database  -d  数据库名  开启

     

    正常情况下,此时每个节点会自动起来,我们检查一下如果没有自动起来我们手工重启。

    Crs_stat-t查看状态

     

     

    RAC维护常用命令汇总

      

    $crs_start  -all--启动所有的crs服务

    $crs_stop  -all--停止所有的crs服务

    $crsctl   start  crs--启动crs服务

    $crsctl  stop  crs--停止crs服务

    $srvctl  start  listener  –n  db1–-启动某节点监听

    $srvctl  stop  listener  –n  db1–-停止某节点监听

    $srvctl  start instance  –d db  -i  db1–-启动某节点实例

    $srvctl stop  instance  –d db  -i  db1–-停止某节点实例

    $srvctl  start  database  –d  db--启动数据库

    $srvctl  stop  database  –d db--停止数据库

     

     

     

     

    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  




    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命令是一个服务级别命令,可以对单一服务资源进行统一启动、停止等管理操作

  • 相关阅读:
    OpenCV在MFC图像控件内显示图像
    Android APK反编译具体解释(附图)
    Android下用Properties保存程序配置
    王灏:光音网络致力打造Wi-Fi大生态圈
    解决ccSvcHst.exe CPU占用超50%的问题,及其缘由
    配置管理工具比較
    应用程序无法正常启动0xc0150002 解决方式
    现有一些开源ESB总线的比較
    使用GridView自带分页的代码
    Hadoop 2.4.0新特性介绍
  • 原文地址:https://www.cnblogs.com/chengxuyonghu/p/15225398.html
Copyright © 2011-2022 走看看