您的位置:首页 > 数据库 > Oracle

Oracle RAC常用维护工具和命令

2018-03-24 17:16 295 查看

Oracle 的管理可以通过OEM或者命令行接口。 Oracle Clusterware的命令集可以分为以下4种:
节点层:olsnodes
网络层:oifcfg
集群层:crsctl, ocrcheck,ocrdump,ocrconfig
应用层:srvctl,onsctl,crs_stat

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

一. 节点层

只有一个命令: olsnodes, 这个命令用来显示集群点列表,可用的参数如下,这些参数可以混合使用。

[root@rac1 ~]# olsnodes -help

Usage: olsnodes [ [-n] [-i] [-s] [-t] [<node> | -l [-p]] | [-c] ] [-g] [-v]
where
-n print node number with the node name
-p print private interconnect address for the local node
-i print virtual IP address with the node name
<node> print information for the specified node
-l print information for the local node
-s print node status - active or inactive
-t print node type - pinned or unpinned
-g turn on logging
-v Run in debug mode; use at direction of Oracle Support only.
-c print clusterware name

[root@rac1 ~]# olsnodes -n -i -s -t

rac1 1 rac1-vip Active Unpinned
rac2 2 rac2-vip Active Unpinned

二. 网络层

网络层由各个节点的网络组件组成,包括2个物理网卡和3个IP 地址。 也只有一个命令:oifcfg.Oifctg 命令用来定义和修改Oracle 集群需要的网卡属性,这些属性包括网卡的网段地址,子网掩码,接口类型等。 要想正确的使用这个命令, 必须先知道Oracle 是如何定义网络接口的,Oracle的每个网络接口包括名称,网段地址,接口类型3个属性。
Oifcfg 命令的格式如下: interface_name/subnet:interface_type
这些属性中没有IP地址,但接口类型有两种,public和private,前者说明接口用于外部通信,用于Oracle Net和VIP 地址,而后者说明接口用于Interconnect。

接口的配置方式分为两类: global 和node-specific。 前者说明集群所有节点的配置信息相同,也就是说所有节点的配置是对称的;而后者意味着这个节点的配置和其他节点配置不同,是非对称的。
Iflist:显示网口列表
Getif: 获得单个网口信息
Setif:配置单个网口
Delif:删除网口

[root@rac1 ~]# oifcfg -help

Name:
oifcfg - Oracle Interface Configuration Tool.

Usage: oifcfg iflist [-p [-n]]
oifcfg setif {-node <nodename> | -global} {<if_name>/<subnet>:<if_type>}...
oifcfg getif [-node <nodename> | -global] [ -if <if_name>[/<subnet>] [-type <if_type>] ]
oifcfg delif {{-node <nodename> | -global} [<if_name>[/<subnet>]] [-force] | -force}
oifcfg [-help]

<nodename> - name of the host, as known to a communications network
<if_name>  - name by which the interface is configured in the system
<subnet>   - subnet address of the interface
<if_type>  - type of the interface { cluster_interconnect | public }

[root@rac1 ~]# oifcfg Iflist
eth0 192.168.0.0
eth1 10.10.10.0
eth1 169.254.0.0

[root@rac1 ~]# oifcfg Getif
eth0 192.168.0.0 global public
eth1 10.10.10.0 global cluster_interconnect

查看public 类型的网卡
[root@rac1 ~]# oifcfg getif -type public
eth0 192.168.0.0 global public
删除接口配置
[root@raw1 bin]# ./oifcfg delif -global
添加接口配置
[root@raw1 bin]# ./oifcfg setif -global eth0/192.168.1.119:public
[root@raw1 bin]# ./oifcfg setif -global eth1/10.85.10.119:cluster_interconnect

三. 集群层

集群层是指由Clusterware组成的核心集群, 这一层负责维护集群内的共享设备,并为应用集群提供完整的集群状态视图,应用集群依据这个视图进行调整。 这一层共有4个命令: crsctl, ocrcheck,ocrdump,ocrconfig. 后三个是针对OCR 磁盘的。

CRSCTL
Crsctl 命令可以用来检查CRS 进程栈,每个crs 进程状态,管理Votedisk,跟踪CRS进程功能。

[root@rac1 ~]# crsctl -help

Usage: crsctl add - add a resource, type or other entity
crsctl check - check a service, resource or other entity
crsctl config - output autostart configuration
crsctl debug - obtain or modify debug state
crsctl delete - delete a resource, type or other entity
crsctl disable - disable autostart
crsctl discover - discover DHCP server
crsctl enable - enable autostart
crsctl get - get an entity value
crsctl getperm - get entity permissions
crsctl lsmodules - list debug modules
crsctl modify - modify a resource, type or other entity
crsctl query - query service state
crsctl pin - pin the nodes in the node list
crsctl relocate - relocate a resource, server or other entity
crsctl replace - replaces the location of voting files
crsctl release - release a DHCP lease
crsctl request - request a DHCP lease
crsctl setperm - set entity permissions
crsctl set - set an entity value
crsctl start - start a resource, server or other entity
crsctl status - get status of a resource or other entity
crsctl stop - stop a resource, server or other entity
crsctl unpin - unpin the nodes in the node list
crsctl unset - unset an entity value, restoring its default

[root@rac1 ~]# crsctl check
Usage:
crsctl check crs
Check status of OHAS and CRS stack

crsctl check cluster [[-all]|[-n <server>[...]]]
Check status of CRS stack

crsctl check ctss
Check status of Cluster Time Synchronization Services

crsctl check resource {<resName> [...]|-w <filter>} [-n <server>] [-k <cid>] [-d <did>]
Check status of resources

crsctl check css
Check status of Cluster Synchronization Services

crsctl check evm
Check status of Event Manager

检查CRS 状态
[root@rac1 ~]# 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

检查单个状态
[root@rac1 ~]# crsctl check evm
CRS-4533: Event Manager is online

[root@rac1 ~]# crsctl check css
CRS-4529: Cluster Synchronization Services is online

配置CRS 栈是否自启动
CRS 进程栈默认随着操作系统的启动而自启动,有时出于维护目的需要关闭这个特性,可以用root 用户执行下面命令。
[root@rac1 ~]# crsctl disable crs
CRS-4621: Oracle High Availability Services autostart is disabled.
[root@rac1 ~]# crsctl enable crs
CRS-4622: Oracle High Availability Services autostart is enabled.
这个命令实际是修改了/etc/oracle/scls_scr/raw/root/crsstart 这个文件里的内容

启动停止CRS栈
Oracle 在10.1时,必须通过重新启动系统重启Clusterware,但是从Oracle 10.2 开始,可以通过命令来启动和停止CRS.
[root@rac1 ~]# crsctl start crs ---启动crs栈
[root@rac1 ~]# crsctl stop crs ---关闭crs栈

查看Votedisk 磁盘位置
[root@rac1 ~]# crsctl query css votedisk

STATE File Universal Id File Name Disk group

  1. ONLINE 0b850860ad964f67bfc4bf7d54645000 (ORCL:SUN_OCR1) [CRS]
  2. ONLINE 06213c75530d4f61bf6552fe840d8d47 (ORCL:SUN_OCR2) [CRS]
  3. ONLINE 51c60ce851024f7ebf0f722a6785e5cf (ORCL:SUN_OCR3) [CRS]
    Located 3 voting disk(s).

查看和修改CRS 参数
——查看参数:用get
[root@rac1 ~]# crsctl get css misscount
CRS-4678: Successful get misscount 30 for Cluster Synchronization Services.

——修改参数:用set,但是这个功能要慎用
[root@rac1 ~]# crsctl set css miscount 60

misscount和disktimeout参数
Oracle clusterware 使用两种心跳设备来验证成员的状态,保证集群的完整性;一是对voting disk的心跳,ocssd进程每秒向votedisk写入一条心跳信息;二是节点间的私有以太网的心跳,两种心跳机制都有一个对应的超时时间,分别叫做 misscount和disktimeout:
misscount 用于定义节点间心跳通信的超时,单位为秒;
disktimeout ,默认200秒,定义css进程与vote disk连接的超时时间;
reboottime ,发生裂脑并且一个节点被踢出后,这个节点将在reboottime的时间内重启;默认是3秒;
其中misscount默认值见下表

用下面的命令查看上述参数的实际值:

  1. crsctl get css misscount

    1. grep misscount $CRS_HOME/log/hostname/cssd/ocssd.log

  • [CSSD]2008-11-27 22:29:42.397 [1] >TRACE: clssnmInitNMInfo: misscount set to 600
    在下面两种情况发生时,css会踢出节点来保证数据的完整,:
    (1) Private Network IO time > misscount,会发生split brain即裂脑现象,产生多个“子集群”(subcluster) ,这些子集群进行投票来选择哪个存活,踢出节点的原则按照下面的原则:
    节点数目不一致的,节点数多的subcluster存活;节点数相同的,node ID小的节点存活。
    (2) Vote Disk IO Time > disktimeout ,踢出节点原则如下:失去半数以上vote disk连接的节点将在reboottime的时间内重启;例如有5个vote disk,当由于网络或者存储原因某个节点与其中>=3个vote disk连接超时时,该节点就会重启。当一个或者两个vote disk损坏时则不会影响集群的运行。
    可以手工修改这三个参数的值,单位都是秒:(谨慎使用)
  • $CRS_HOME/bin/crsctl set css misscount
  • $CRS_HOME/bin/crsctl set css reboottime [-force]
  • $CRS_HOME/bin/crsctl set css disktimeout [-force]
  • 或者重新设置成默认值:crsctl unset css misscount
  • 跟踪CRS 模块,提供辅助功能
    CRS由CRS,CSS,EVM 三个服务组成,每个服务又是由一系列module组成,crsctl 允许对每个module进行跟踪,并把跟踪内容记录到日志中。
    [root@rac1 ~]# crsctl lsmodules css

    List CSSD Debug Module: CLSF
    List CSSD Debug Module: CSSD
    List CSSD Debug Module: GIPCCM
    List CSSD Debug Module: GIPCGM
    List CSSD Debug Module: GIPCNM
    List CSSD Debug Module: GPNP
    List CSSD Debug Module: OLR
    List CSSD Debug Module: SKGFD

    [root@rac1 ~]# crsctl lsmodules crs

    List CRSD Debug Module: AGENT
    List CRSD Debug Module: AGFW
    List CRSD Debug Module: CLSFRAME
    List CRSD Debug Module: CLSVER
    List CRSD Debug Module: CLUCLS
    List CRSD Debug Module: COMMCRS
    List CRSD Debug Module: COMMNS
    List CRSD Debug Module: CRSAPP
    List CRSD Debug Module: CRSCCL
    List CRSD Debug Module: CRSCEVT
    List CRSD Debug Module: CRSCOMM
    List CRSD Debug Module: CRSD
    List CRSD Debug Module: CRSEVT
    List CRSD Debug Module: CRSMAIN
    List CRSD Debug Module: CRSOCR
    List CRSD Debug Module: CRSPE
    List CRSD Debug Module: CRSPLACE
    List CRSD Debug Module: CRSRES
    List CRSD Debug Module: CRSRPT
    List CRSD Debug Module: CRSRTI
    List CRSD Debug Module: CRSSE
    List CRSD Debug Module: CRSSEC
    List CRSD Debug Module: CRSTIMER
    List CRSD Debug Module: CRSUI
    List CRSD Debug Module: CSSCLNT
    List CRSD Debug Module: OCRAPI
    List CRSD Debug Module: OCRASM
    List CRSD Debug Module: OCRCAC
    List CRSD Debug Module: OCRCLI
    List CRSD Debug Module: OCRMAS
    List CRSD Debug Module: OCRMSG
    List CRSD Debug Module: OCROSD
    List CRSD Debug Module: OCRRAW
    List CRSD Debug Module: OCRSRV
    List CRSD Debug Module: OCRUTL
    List CRSD Debug Module: SuiteTes
    List CRSD Debug Module: UiServer

    [root@rac1 ~]# crsctl lsmodules evm

    List EVMD Debug Module: CLSVER
    List EVMD Debug Module: CLUCLS
    List EVMD Debug Module: COMMCRS
    List EVMD Debug Module: COMMNS
    List EVMD Debug Module: CRSCCL
    List EVMD Debug Module: CRSOCR
    List EVMD Debug Module: CSSCLNT
    List EVMD Debug Module: EVMAGENT
    List EVMD Debug Module: EVMAPP
    List EVMD Debug Module: EVMCOMM
    List EVMD Debug Module: EVMD
    List EVMD Debug Module: EVMDMAIN
    List EVMD Debug Module: EVMEVT
    List EVMD Debug Module: OCRAPI
    List EVMD Debug Module: OCRCLI
    List EVMD Debug Module: OCRMSG

    跟踪CSSD模块,需要root 用户执行

    [root@rac1 ~]# crsctl debug log css "CSSD:1"
    CRS-4151: DEPRECATED: use crsctl set log {css|crs|evm}
    Set CSSD Module: CSSD Log Level: 1

    查看跟踪日志
    [root@rac1 cssd]# pwd
    /u01/grid/log/rac1/cssd
    [root@rac1 cssd]# more ocssd.log

    维护Votedisk(10g)

    以图新方式安装Clusterware的过程中,在配置Votedisk时,如果选择External Redundancy策略。则只能填写一个Votedisk。但是即使使用External Redundancy作为冗余策略,也可以添加多个Vodedisk,只是必须通过crsctl 命令来添加,添加多个Votedisk后,这些Votedisk 互为镜像,可以防止Votedisk的单点故障。
    需要注意的是,Votedisk使用的是一种“多数可用算法”,如果有多个Votedisk,,则必须一半以上的Votedisk同时使用,Clusterware才能正常使用。 比如配置了4个Votedisk,坏一个Votedisk,集群可以正常工作,如果坏了2个,则不能满足半数以上,集群会立即宕掉,所有节点立即重启,所以如果添加Votedisk,尽量不要只添加一个,而应该添加2个。这点和OCR 不一样。OCR 只需配置一个。

    添加和删除Votedisk的操作比较危险,必须停止数据库,停止ASM,停止CRS Stack后操作,并且操作时必须使用-force参数。
    1) 查看当前配置
    [root@raw1 bin]# ./crsctl query css votedisk
    2) 停止所有节点的CRS:
    [root@raw1 bin]# ./crsctl stop crs
    3) 添加Votedisk
    [root@raw1 bin]# ./crsctl add css votedisk /dev/raw/raw1 -force
    注意:即使在CRS 关闭后,也必须通过-force 参数来添加和删除Votedisk,并且-force 参数只有在CRS关闭的场合下使用才安全。 否则会报:Cluter is not a ready state for online disk addition.
    4) 确认添加后的情况:
    [root@raw1 bin]# ./crsctl query css votedisk
    5) 启动CRS
    [root@raw1 bin]# ./crsctl start crs

    OCR命令系列
    Oracle Clusterware把整个集群的配置信息放在共享存储上,这个存储就是OCR Disk. 在整个集群中,只有一个节点能对OCR Disk 进行读写操作,这个节点叫作Master Node,所有节点都会在内存中保留一份OCR的拷贝,同时有一个OCR Process 从这个内存中读取内容。 OCR 内容发生改变时,由Master Node的OCR Process负责同步到其他节点的OCR Process。
    因为OCR的内容如此重要,Oracle 每4个小时对其做一次备份,并且保留最后的3个备份,以及前一天,前一周的最后一个备份。 这个备份由Master Node CRSD进程完成,备份的默认位置是$CRS_HOME/crs/cdata/<cluster_name>目录下。 每次备份后,备份文件名自动更改,以反应备份时间顺序,最近一次的备份叫作backup00.ocr。这些备份文件除了保存在本地,DBA还应该在其他存储设备上保留一份,以防止意外的存储故障。

    ocrdump
    该命令能以ASCII的方式打印出OCR的内容,但是这个命令不能用作OCR的备份恢复,也就是说产生的文件只能用作阅读,而不能用于恢复。
    命令格式: ocrdump [-stdout] [filename] [-keyname name] [-xml]
    参数说明:
    -stdout: 把内容打印输出到屏幕上
    Filename:内容输出到文件中
    -keyname:只打印某个键及其子健内容
    -xml:以xml格式打印输出
    示例:把system.css键的内容以.xml格式打印输出到屏幕

    [root@rac1 ~]# ocrdump -stdout -keyname system.css -xml|more
    <OCRDUMP>

    <TIMESTAMP>01/11/2014 09:27:50</TIMESTAMP>
    <COMMAND>/u01/grid/bin/ocrdump.bin -stdout -keyname system.css -xml </COMMAND>

    </OCRDUMP>
    PROT-307: The specified key does not exist in cluster registry

    这个命令在执行过程中,会在$CRS_HOME/log/<nodename>/client 目录下产生日志文件,文件名ocrdump<pid>.log,如果命令执行出现问题,可以从这个日志查看问题原因。

    ocrcheck
    Ocrcheck 命令用于检查OCR内容的一致性,命令执行过程会在$CRS_HOME/log/nodename/client 目录下产生ocrcheck_pid.log 日志文件。 这个命令不需要参数。
    [root@rac1 ~]# ocrcheck

    Status of Oracle Cluster Registry is as follows :
    Version : 3
    Total space (kbytes) : 262120
    Used space (kbytes) : 2900
    Available space (kbytes) : 259220
    ID : 262428938
    Device/File Name : +crs
    Device/File integrity check succeeded

    Device/File not configured
    
    Device/File not configured
    
    Device/File not configured
    
    Device/File not configured
    
    Cluster registry integrity check succeeded
    
    Logical corruption check succeeded

    ocrconfig
    OCRCONFIG工具主要功能是备份、恢复ocr的。

    虽然用oracle用户可以直接运行ocrconfig,但是大部分命令还需要root用户才有权限执行:

    [root@rac1 ~]# ocrconfig -help
    名称:
    ocrconfig - Oracle 集群注册表的配置工具。
    概要:
    ocrconfig [option]
    option:
    -export <filename> [-s online] - 将集群注册表内容导出到文件
    -import <filename> - 从文件导入集群注册表内容
    -upgrade [<user> [<group>]] - 从早期版本升级集群注册表

    -downgrade [-version <version string>]  - 将集群注册表降级到指定版本
    
    -backuploc <dirname>                - 配置定期备份位置
    -showbackup                         - 显示备份信息
    -restore <filename>                 - 从物理备份中恢复
    -replace ocr|ocrmirror [<filename>] - 添加/替换/删除 OCR 设备/文件
    -overwrite                          - 覆盖磁盘上的 OCR 配置
    -repair ocr|ocrmirror <filename>    - 修复本地 OCR 配置
    -help                               - 打印此帮助信息

    注:
    将在
    $ORACLEHOME/log/<hostname>/client/ocrconfig<pid>.log 中创建日志文件。在
    运行此工具前, 请确保
    您具有在以上目录中创建文件的权限。

    查看自助备份
    [root@rac1 ~]# ocrconfig -showbackup

    rac1 2014/01/10 13:29:12 /u01/grid/cdata/rac-cluster/backup00.ocr

    rac1 2014/01/10 13:29:12 /u01/grid/cdata/rac-cluster/day.ocr

    rac1 2014/01/10 13:29:12 /u01/grid/cdata/rac-cluster/week.ocr

    rac1 2014/01/10 11:41:40 /u01/grid/cdata/rac-cluster/backup_20140110_114140.ocr

    在缺省情况下,OCR自动备份在$CRS_HOME/CDATA/cluster_name 目录下,可以通过ocrconfig -backuploc <directory_name> 命令修改到新的目录

    OCR备份和恢复

    1..找到物理备份:$ ocrconfig –showbackup

    1. 检查其内容:# ocrdump –backupfile file_name
    2. 停止所有节点上的Oracle Clusterware:# crsctl stop crs
    3. 还原OCR 物理备份:# ocrconfig –restore <CRS HOME>/cdata/jfv_clus/day.ocr
    4. 重新启动所有节点上的Oracle Clusterware:# crsctl start crs
    5. 检查OCR 完整性:$ cluvfy comp ocr -n all
      具体查看oracle11g rac 备份ocr和恢复ocr文档

    移动OCR 文件位置

    [grid@rac1 ~]$ ocrcheck
    Status of Oracle Cluster Registry is as follows :
    Version : 3
    Total space (kbytes) : 262120
    Used space (kbytes) : 2900
    Available space (kbytes) : 259220
    ID : 262428938
    Device/File Name : +crs
    Device/File integrity check succeeded

    Device/File not configured
    
    Device/File not configured
    
    Device/File not configured
    
    Device/File not configured
    
    Cluster registry integrity check succeeded
    
    Logical corruption check bypassed due to non-privileged user

    添加一个新的ocr磁盘组
    [root@rac1 ~]# ocrconfig -add +FAR

    添加完成以后,可以再+FAR中看到生成了ocr文件

    ASMCMD> pwd
    +far/rac-cluster/ocrfile
    ASMCMD> ls
    REGISTRY.255.836567659

    如果没有该ocr参数文件,那么迁移ocr
    [root @rac1 ~]$ ocrconfig -replace +CRS -replacement +FAR

    [root@rac1 ~]# ocrcheck
    Status of Oracle Cluster Registry is as follows :
    Version : 3
    Total space (kbytes) : 262120
    Used space (kbytes) : 2900
    Available space (kbytes) : 259220
    ID : 262428938
    Device/File Name : +crs
    Device/File integrity check succeeded
    Device/File Name : +FAR
    Device/File integrity check succeeded

    Device/File not configured
    
    Device/File not configured
    
    Device/File not configured
    
    Cluster registry integrity check succeeded
    
    Logical corruption check succeeded

    迁移votedisk

    [root@rac1 ~]# su - grid
    [grid@rac1 ~]$ crsctl replace votedisk +FAR
    Successful addition of voting disk 5638a2e558924f47bf9814ec085e47cb.
    Successful deletion of voting disk 0b850860ad964f67bfc4bf7d54645000.
    Successful deletion of voting disk 06213c75530d4f61bf6552fe840d8d47.
    Successful deletion of voting disk 51c60ce851024f7ebf0f722a6785e5cf.
    Successfully replaced voting disk group with +FAR.
    CRS-4266: Voting file(s) successfully replaced

    查看votedisk存放位置

    [grid@rac1 ~]$ crsctl query css votedisk;

    STATE File Universal Id File Name Disk group

    1. ONLINE 5638a2e558924f47bf9814ec085e47cb (ORCL:SUN_FAR) [FAR]
      Located 1 voting disk(s).

    查看资源状态

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

    登录asm查看asmdisk信息

    [grid@rac1 ~]$ sqlplus "/as sysasm"

    SQL> select group_number,name,state,type from V$asm_diskgroup;
    SQL> select group_number,name,path from v$asm_disk;

    查看asm的spfile参数文件,如果存放在原来的CRS中,那么需要重建spfile

    SQL> show parameter spfile;

    NAME TYPE VALUE

    spfile string +CRS/rac-cluster/asmparameterf
    ile/registry.253.836471453

    SQL> create pfile='/home/grid/asmpfile.ora' from spfile;

    SQL> create spfile='+FAR' from pfile='/home/grid/asmpfile.ora';

    重启crs(所有节点)

    [root@rac1 ~]#crsctl stop crs
    [root@rac1 ~]#crsctl start crs

    删除磁盘组

    [root@rac1 ~]# ocrconfig -delete +CRS

    [grid@rac1 ~]$ sqlplus "/as sysasm"

    SQL>alter diskgroup CRS dismount;
    SQL>drop diskgroup CRS including contents;

    四. 应用层

    应用层就是指RAC数据库了,这一层有若干资源组成,每个资源都是一个进程或者一组进程组成的完整服务,这一层的管理和维护都是围绕这些资源进行的。 有如下命令: srvctl, onsctl, crs_stat 三个命令。

    crs_stat
    Crs_stat 这个命令用于查看CRS维护的所有资源的运行状态,如果不带任何参数时,显示所有资源的概要信息。每个资源显示是各个属性:资源名称,类型,目录,资源运行状态等。
    [root@raw1 bin]# ./crs_stat
    NAME=ora.raw.db
    TYPE=application
    TARGET=ONLINE
    STATE=OFFLINE
    ......
    也可以指定资源名,查看指定资源的状态,并可以使用-V 和-P 选项,以查看详细信息,其中-p 参数显示的内容比-V 更详细。

    1) 查看制定资源状态
    [root@rac1 ~]# crs_stat ora.rac1.vip
    NAME=ora.rac1.vip
    TYPE=ora.cluster_vip_net1.type
    TARGET=ONLINE
    STATE=ONLINE on rac1

    2) 使用-v 选项,查看详细内容,这时输出多出4项内容,分别是允许重启次数,已执行重启次数,失败阀值,失败次数。
    [root@rac1 ~]# crs_stat -v ora.rac1.vip
    NAME=ora.rac1.vip
    TYPE=ora.cluster_vip_net1.type
    RESTART_ATTEMPTS=0
    RESTART_COUNT=0
    FAILURE_THRESHOLD=0
    FAILURE_COUNT=0
    TARGET=ONLINE
    STATE=ONLINE on rac1

    3) 使用-p 选项查看更详细内容、
    [root@rac1 ~]# crs_stat -p ora.rac1.vip
    NAME=ora.rac1.vip
    TYPE=ora.cluster_vip_net1.type
    ACTION_SCRIPT=
    ACTIVE_PLACEMENT=1
    AUTO_START=restore
    CHECK_INTERVAL=1
    DESCRIPTION=Oracle VIP resource
    FAILOVER_DELAY=0
    FAILURE_INTERVAL=0
    FAILURE_THRESHOLD=0
    HOSTING_MEMBERS=rac1
    PLACEMENT=favored
    RESTART_ATTEMPTS=0
    SCRIPT_TIMEOUT=60
    START_TIMEOUT=0
    STOP_TIMEOUT=0
    UPTIME_THRESHOLD=1h

    4) 使用-ls 选项,可以查看每个资源的权限定义,权限定义格式和Linux 一样。

    [root@rac1 ~]# crs_stat -ls

    Name Owner Primary PrivGrp Permission

    ora.CRS.dg grid oinstall rwxrwxr--
    ora.DATA.dg grid oinstall rwxrwxr--
    ora.FAR.dg grid oinstall rwxrwxr--
    ora....ER.lsnr grid oinstall rwxrwxr--
    ora....N1.lsnr grid oinstall rwxr-xr--
    ora.asm grid oinstall rwxrwxr--
    ora.cvu grid oinstall rwxrwxr--
    ora.gsd grid oinstall rwxr-xr--
    ora....network root root rwxr-xr--
    ora.oc4j grid oinstall rwxrwxr--
    ora.ons grid oinstall rwxr-xr--
    ora....SM1.asm grid oinstall rwxrwxr--
    ora....C1.lsnr grid oinstall rwxrwxr--
    ora.rac1.gsd grid oinstall rwxr-xr--
    ora.rac1.ons grid oinstall rwxr-xr--
    ora.rac1.vip root root rwxr-xr--
    ora....SM2.asm grid oinstall rwxrwxr--
    ora....C2.lsnr grid oinstall rwxrwxr--
    ora.rac2.gsd grid oinstall rwxr-xr--
    ora.rac2.ons grid oinstall rwxr-xr--
    ora.rac2.vip root root rwxr-xr--
    ora.racdb.db oracle oinstall rwxrwxr--
    ora.scan1.vip root root rwxr-xr--

    onsctl

    这个命令用于管理配置ONS(Oracle Notification Service). ONS 是Oracle Clusterware 实现FAN Event Push模型的基础。在传统模型中,客户端需要定期检查服务器来判断服务端状态,本质上是一个pull模型,Oracle 10g 引入了一个全新的PUSH 机制--FAN(Fast Application Notification),当服务端发生某些事件时,服务器会主动的通知客户端这种变化,这样客户端就能尽早得知服务端的变化。 而引入这种机制就是依赖ONS实现, 在使用onsctl命令之前,需要先配置ONS服务。

    ONS 配置内容
    在RAC 环境中,需要使用$CRS_HOME下的ONS,而不是$ORACLE_HOME下面的ONS, 这点需要注意。 配置文件在$CRS_HOME/opmn/conf/ons.config.

    [root@rac1 conf]# more ons.config
    usesharedinstall=true
    allowgroup=true
    localport=6100 # line added by Agent
    remoteport=6200 # line added by Agent
    nodes=rac1:6200,rac2:6200 # line added by Agent

    参数说明:
    Localport: 这个参数代表本地监听端口,这里本地特指:127.0.0.1 这个回环地址,用来和运行在本地的客户端进行通信
    Remoteport:这个参数代表的是远程监听端口,也就是除了127.0.0.1 以外的所有本地IP地址,用来和远程的客户端进行通信。
    Loglevel: Oracle 允许跟踪ONS进程的运行,并把日志记录到本地文件中,这个参数用来定义ONS进程要记录的日志级别,从1-9,缺省值是3.
    Logfile: 这个参数和loglevel参数一起使用,用于定义ONS进程日志文件的位置,缺省值是$CRS_HOME/opmn/logs/opmn.log
    nodes和useocr: 这两个参数共同决定饿了本地的ONS daemon要和哪些远程节点上的ONS daemon进行通信。Nodes 参数值格式如下:Hostname/IP:port[hostname/ip:port]
    如:useoce=off
    Nodes=rac1:6200,rac2:6200
    而useocr 参数值为on/off, 如果useocr 是ON, 说明信息保存在OCR中,如果是OFF,说明信息取nodes中的配置。对于单实例而言,要把useocr设置为off。

    配置ONS

    可以直接编译ONS的配置文件来修改配置,如果使用了OCR,则可以通过racgons命令进行配置,但必须以root用户来执行,如果用oracle 用户来执行,不会提示任何错误,但也不会更改任何配置。
    若要添加配置,可以使用下面命令:
    Racgons add_config rac1:6200 rac2:6200
    若要删除配置,可以用下面命令:
    Racgons remove_config rac1:6200 rac2:6200

    转自: https://www.geek-share.com/detail/2479067725.html

    内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
    标签:  ORACLE RAC