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] [ | -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
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 | -global} {/:}...
oifcfg getif [-node | -global] [ -if [/] [-type ] ]
oifcfg delif {{-node | -global} [[/]] [-force] | -force}
oifcfg [-help]
- name of the host, as known to a communications network - name by which the interface is configured in the system
- subnet address of the interface
- 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> crsctl replace - replaces the location of voting files
crsctl> 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 [...]]]
Check status of CRS stack
crsctl check ctss
Check status of Cluster Time Synchronization Services
crsctl check resource { [...]|-w } [-n ] [-k ] [-d ]
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
PROT-307: The specified key does not exist in cluster registry
这个命令在执行过程中,会在$CRS_HOME/log//client 目录下产生日志文件,文件名ocrdump.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
检查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>
ONLINE 5638a2e558924f47bf9814ec085e47cb (ORCL:SUN_FAR) [FAR] Located 1 voting disk(s).