RAC操作命令大全

节点层:olsnodes 
网络层:oifcfg 
集群层:crsctl(平时使用最多的两个命令之一), ocrcheck,ocrdump,ocrconfig 
应用层:srvctl(平时使用最多的两个命令之一),onsctl,crs_XX(crs_start、crs_stat、crs_stop这些命令在11G中已经废弃不推荐使用了,但是crs_stat -t看集群资源状态比较方便,显示格式比crsctl stat res -t要好很多
这些命令都可以通过加-h后缀来查看到具体应该匹配的commands和objects

Rac每个节点,有单独的DATABASE实例、监听、ASM实例,每个节点下面的监听包含数据库和ASM的实例信息,一套ASM可以对应多套DB
Asmca只在grid的bin下面
Dbca只在oracle的bin下面
Netca在grid和oracle的bin下面都有,建议使用grid操作netca
lsnrctl在grid和oracle目录下都有,oracle用户下没有权限执行lsnrctl启动和关闭命令,只能查看lsnrctl status
Srvctl在grid和oracle目录下都有,目前了解grid和oracle下的srvctl都可以执行srvctl start/stop/config/enable/disable/status/add/remove database/listener的操作,但是建议使用oracle操作数据库,grid操作监听和ASM
Crsctl命令只在grid目录中有,但是只能使用root用户执行crsctl start/stop crs、crsctl config crs、crsctl enable/disable crs等操作


RAC启动操作(ASM、监听、DB都会启动,当然前提是DB会随着集群的启动而自动启动)
root>crsctl start crs (must be run on each node)
Oracle>srvctl status database -d db_name
grid>srvctl status  listener_name
数据库是否自动启动,srvctl config database -d orcl -a显示的结果必须是Management policy: AUTOMATIC和Database is enabled

RAC关闭操作(ASM、监听、DB都会关闭)
root> crsctl stop crs       (must be run on each node)
Oracle>srvctl status database -d db_name
grid>srvctl status  listener_name

单独启动关闭数据库操作(推荐使用oracle用户,虽然grid、oracle用户都可以)
Oracle>srvctl start/stop database -d db_name

单独启动关闭某个实例操作(推荐使用oracle用户,虽然grid、oracle用户都可以, -n其实就是节点名称就是服务器名称了)
Oracle>srvctl start/stop instance -d db_name -i instance_name

Oracle>srvctl start/stop instance -d db_name -n node_name
 
单独启动监听操作(推荐使用grid用户,虽然grid、oracle用户都可以,-n其实就是节点名称就是服务器名称了)
grid>srvctl start/stop  listener_name -n node_name



节点层olsnodes 
The olsnodes command provides the list of nodes and other information for all nodes participating in the cluster.
This command utility is located in the $ORA_CRS_HOME/bin directory. You can only use this command if the CRS daemon is started.
You can run this command as either the root user, the user that installed Oracle Clusterware, or the user that installed Oracle Database.
olsnodes命令显示集群内所有节点列表信息。olsnodes只在grid的bin下面,root、grid、oracle用户都可以执行
[root@node1 ~]# olsnodes
node1
node2
[root@node1 ~]# olsnodes -c
node-scan
[root@node1 ~]# olsnodes -n -i -s -t
node1   1       node1-vip       Active  Unpinned
node2   2       node2-vip       Active  Unpinned



网络层oifcfg
The Oracle Interface Configuration Tool (OIFCFG) command-line interface helps you to define and administer network interfaces. You can use OIFCFG commands Oracle Clusterware environments to:
Allocate and deallocate network interfaces to components
Direct components to use specific network interfaces
Retrieve component configuration information
OIFCFG命令可以定义和管理网络接口:分配和释放网络接口到组件、直接组件使用特定的网络接口、检索组件配置信息
OIFCFG主要显示一些网段信息,只存放在grid的bin下面,较少使用,root、grid、oracle用户都可以执行
[root@node1 ~]# oifcfg iflist
eth0  192.168.92.0
eth1  191.2.10.0
eth1  169.254.0.0
eth2  191.2.11.0
eth2  169.254.128.0
[root@node1 ~]# oifcfg iflist -p -n
eth0  192.168.92.0  PRIVATE  255.255.255.0
eth1  191.2.10.0  UNKNOWN  255.255.255.0
eth1  169.254.0.0  UNKNOWN  255.255.128.0
eth2  191.2.11.0  UNKNOWN  255.255.255.0
eth2  169.254.128.0  UNKNOWN  255.255.128.0



集群层crsctl
CRSCTL is an interface between you and Oracle Clusterware, parsing and calling Oracle Clusterware APIs for Oracle Clusterware objects.
CRSCTL是您与Oracle Clusterware之间的接口,用于解析和调用Oracle Clusterware对象的Oracle Clusterware API
Crsctl只在grid的bin下面,用于管理集群件,使用root账号操作
检查集群件各个组件状态
crsctl stat res -t
配置集群自动启动
crsctl config crs
crsctl disable crs  --取消集群自动启动
crsctl enable crs   --设置集群自动启动
针对当前节点启、停、检查集群件(crs只能是当前节点,加-all会报错),下面的命令会启停ohasd进程。
crsctl start crs
crsctl stop crs
crsctl check crs
针对整个集群里所有节点启、停、检查集群件(不加-all表示只是当前节点),下面的命令不会启停ohasd进程。
crsctl start cluster -all
crsctl stop cluster -all
crsctl check cluster -all
检查当前节点的时间同步
crsctl check ctss
检查、新增、替换votedisk信息
crsctl query css votedisk
crsctl add css votedisk /sharednfs/vote2
crsctl replace votedisk +DATA
查看grid版本
crsctl query crs activeversion
crsctl query crs releaseversion
crsctl query crs softwareversion
修改心跳超时
crsctl set css misscount 60
查看server信息
crsctl status server -f
查看serverpool信息
crsctl status serverpool
添加一个serverpool
crsctl add serverpool serverpoolname(crsctl创建的serverpool不能给数据库使用,只能给第三方的应用使用)


crs_start -all和crsctl start crs的区别
crs_stop -all和crsctl stop crs的区别
必须先启动了crsctl start crs才能执行crs_start -all、crs_stop -all、crs_stat -t、crsctl check crs
如果执行了crsctl stop crs,则不能再执行crs_start –all、crs_stop –all、crs_stat –t、crsctl check crs

crsctl check cssd被crsctl check css取代了
[root@node1 ~]# crsctl check cssd
CRS-272: This command remains for backward compatibility only
Cluster Synchronization Services is online

crsctl check crsd被crsctl check crs取代了
[root@node1 grid]# crsctl check crsd
CRS-272: This command remains for backward compatibility only
Cluster Ready Services is online

[root@node1 grid]# 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@node1 grid]# crsctl check cluster
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

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

crsctl start CRS不单单启动CRSD了,等于启动OHASD、CRSD、CSSD三者了
crsctl start css只启动了CSSD



集群层ocrcheck、ocrdump、ocrconfig(三者都只存放在grid的bin下面,操作的话建议使用root用户)
Oracle Clusterware includes two important components that manage configuration and node membership: Oracle Cluster Registry (OCR), which also includes the local component Oracle Local Registry (OLR), and voting disks.
Oracle Clusterware包括管理配置和节点成员资格的两个重要组件:OCR和voting disks,其中OCR包含OLR

Oracle Cluster Registry (OCR)
The Oracle RAC configuration information repository that manages information about the cluster node list and instance-to-node mapping information. OCR also manages information about Oracle Clusterware resource profiles for customized applications.
OCR contains information about all Oracle resources in the cluster.
OCR manages Oracle Clusterware and Oracle RAC database configuration information
Oracle RAC配置信息存储库,用于管理有关群集节点列表和实例到节点映射信息的信息。 OCR还管理有关用于定制应用程序的Oracle Clusterware资源配置文件的信息。
OCR包含有关集群中所有Oracle资源的信息。
OCR管理Oracle Clusterware和Oracle RAC数据库配置信息

Oracle Local Registry (OLR)
OLR is a registry similar to OCR located on each node in a cluster, but contains information specific to each node. It contains manageability information about Oracle Clusterware, including dependencies between various services. Oracle High Availability Services uses this information. OLR is located on local storage on each node in a cluster. Its default location is in the path Grid_home/cdata/host_name.olr, where Grid_home is the Oracle Grid Infrastructure home, and host_name is the host name of the node.
OLR resides on every node in the cluster and manages Oracle Clusterware configuration information for each particular node
OLR是类似于OCR的注册表,位于集群中的每个节点上,但包含每个节点特有的信息。 它包含有关Oracle Clusterware的可管理性信息,包括各种服务之间的依赖关系。 Oracle高可用**使用此信息。 OLR位于集群中每个节点上的本地存储上。 其默认位置在Grid_home/cdata/host_name.olr路径中,其中Grid_home是Oracle Grid Infrastructure home,host_name是节点的主机名。
OLR驻留在集群中的每个节点上,并管理每个特定节点的Oracle Clusterware配置信息

Voting disks
Voting disks manage information about node membership. Each voting disk must be accessible by all nodes in the cluster for nodes to be members of the cluster
投票磁盘管理有关节点成员资格的信息。 每个投票磁盘必须可以由集群中的所有节点访问,以使节点成为集群的成员

OCRCHECK
The OCRCHECK utility displays the version of the OCR's block format, total space available and used space, OCRID, and the OCR locations that you have configured. OCRCHECK performs a block-by-block checksum operation for all of the blocks in all of the OCRs that you have configured. It also returns an individual status for each file and a result for the overall OCR integrity check.
OCRCHECK实用程序显示OCR的块格式版本,可用空间总数和使用空间,OCRID和您配置的OCR位置。
ocrcheck
ocrcheck -config
ocrcheck -local
ocrcheck -config -local
如下显示存放在本地的OCR,其实就是OLR了
[root@node1 ~]# ocrcheck -config -local
Oracle Local Registry configuration is :
         Device/File Name         : /u01/app/11.2.0/grid/cdata/node1.olr

OCRCONFIG
Use the ocrconfig command to manage OCR. Using this utility you can import, export, add, delete, restore, overwrite, backup, repair, replace, move, upgrade, or downgrade OCR.
使用ocrconfig命令来管理OCR。 使用此实用程序,您可以导入,导出,添加,删除,恢复,覆盖,备份,修复,替换,移动,升级或降级OCR。
手工备份OCR
ocrconfig -manualbackup
配置OCR备份路径
ocrconfig -backuploc /nfsfolder/
查看OCR的手工备份
ocrconfig -showbackup manual
查看OCR的自动备份
ocrconfig -showbackup auto
逻辑备份OCR
ocrconfig -export /home/oracle/ocr.dump
逻辑备份OLR
ocrconfig -local -export /home/oracle/olr.dump

添加一个新的ocr文件到磁盘组
ocrconfig -add +DATA
从磁盘组里删除一个OCR文件
ocrconfig -delete +DATA

OCRDUMP
The OCRDUMP utility enables you to view OCR and OLR contents by writing the content to a file or stdout in a readable format.
OCRDUMP实用程序使您能够将内容写入可读取格式的文件或stdout来查看OCR和OLR内容。
ocrconfig -export逻辑导出的dump打开是乱码,所以如果要查看OCR的内容,只能使用ocrdump
将OCR文件内容写入/home/grid/FILE1文件
ocrdump /home/grid/FILE1



应用层SRVCTL
Use SRVCTL to manage configuration information. You can use SRVCTL commands to add, remove, start, stop, modify, enable, and disable a number of entities, such as databases, instances, listeners, SCAN listeners, services, grid naming service (GNS), and Oracle ASM.
使用SRVCTL来管理配置信息。 您可以使用SRVCTL命令添加,删除,启动,停止,修改,启用和禁用许多实体,如数据库,实例,侦听器,SCAN侦听器,服务,网格命名服务(GNS)和Oracle ASM。
SRVCTL管理集群上的各个资源,启停各个应用,注册各个应用,在oracle和grid的bin下面都有这个命令

查看nodeapps节点配置(含VIP、GSD、ONS)
srvctl config nodeapps
查看nodeapps节点状态(含VIP、GSD、ONS)
srvctl status nodeapps

查看DB配置

srvctl config database(查看在集群中注册的所有数据库)
srvctl config database -d db_name
srvctl config database -d db_name -a(加了-a可以看到DB是否随集群自动启动)
查看DB状态
srvctl status database -d db_name

查看listener配置、状态
srvctl config listener
srvctl status listener
查看scan_listener配置、状态(不能通过lsnrctl来看scan的监听,所以只能以下两者结合srvctl config scan)
srvctl config scan_listener
srvctl status scan_listener

查看asm配置、状态
srvctl config asm
srvctl status asm
查看SCAN IP配置(IP地址具体是多少)
srvctl config scan
查看SCAN IP状态(具体落在哪个节点)
srvctl status scan

查看VIP的配置、状态
srvctl config vip -n node_name
srvctl config nodeapps -a
srvctl status vip -n node_name
srvctl status nodeapps
DB注册到集群
srvctl add database -d db_name -o $ORACLE_HOME
或加上-p固化参数文件
srvctl add database -d db_name -o $ORACLE_HOME -p +XX/spfilevm72.ora
DB从集群中取消
srvctl remove database -d db_name
添加一个serverpool
srvctl add srvpool -g serverpoolname -n "node1, node2"(srvctl创建的serverpool只能给数据库使用,不能给第三方的应用使用)


配置DB是否随集群启动而自动启动(必须同时Management policy: AUTOMATIC和Database is enabled)
srvctl modify database -d db_name -y AUTOMATIC  
srvctl enable database -d db_name  
srvctl modify database -d db_name -y MANUAL --只要设置则数据库不自动启动
srvctl disable database -d db_name --只要设置则数据库不自动启动
srvctl enable instance -d db_name –i instance_name --某个实例自动启动
srvctl disable instance -d db_name –i instance_name --某个实例不自动启动
srvctl config database -d db_name -a(加了-a可以看到DB是否随集群自动启动)

Management policy
SRVCTL只有database和service才有-y Management policy的选项
Management policy for the database. If AUTOMATIC (the default), the database is automatically restored to its previous running condition (started or stopped) upon restart of the database host computer. If MANUAL, the database is never automatically restarted upon restart of the database host computer. 
The management policy for a service controls whether the service starts automatically when the database is restarted. If the management policy for a service is set to AUTOMATIC, then it restarts automatically. If the management policy for a service is set to MANUAL, then it must be started manually.

Enable
The srvctl enable command reenables the specified disabled component so that:
Oracle Restart can automatically restart it.
It can be automatically started through a dependency.



应用层ONSCTL
Oracle Notification Service (ONS). ONS (ons.jar) is included as part of the Oracle Client software. ONS can be configured using either remote configuration or client-side ONS daemon configuration. Remote configuration is the preferred configuration for standalone client applications.
ONS(ons.jar)作为Oracle Client软件的一部分。可以使用远程配置或客户端ONS守护程序配置来配置ONS。
[root@node1 ~]# onsctl -h
onsctl: unknown command: -h
usage: onsctl [verbose] []
The verbose option enables debug tracing and logging (for the server start).
Permitted / combinations are:
command   options
-------   ---------
start                       - Start ons
shutdown                    - Shutdown ons
reload                      - Trigger ons to reread its configuration file
debug     [= ..] - Display ons server debug information
set       [= ..] - Set ons log parameters
query     [=]    - Query ons log parameters
ping      []     - Ping local ons
help                        - Print brief usage description (this)
usage     []       - Print detailed usage description
[root@node1 ~]# onsctl start
CRS-5702: Resource 'ora.ons' is already running on 'node1'
CRS-4000: Command Start failed, or completed with errors.
[root@node1 ~]# onsctl ping
ons is running ...

 

srvctl操作监听或实例时不论startstopcrs中会自动onlineoffline

lsnrctl操作监听时startcrs不一定online,但是stop时,crs一定会offline

sqlplus 操作实例时startcrs不一定online,但是stop时,crs一定会offline

如下系列图1-2张在mdsdb02中,监听是通过lsnrctl start启动,可以看到在srvctl的命令中看不到节点mdsdb02的信息,只有mdsdb01

 

一套ASM可以对应多套DB

20160811,把db_namedb521102异地恢复到原来db_namedbracRAC服务器上,发现在同一套ASM下原来db_namedbrac也可以启动,说明一套ASM可以对应多套DB,把原来的db_namedbrac通过srvctl remove database -d dbrac取消后就可以了,如下系列3-5














来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30126024/viewspace-2123397/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30126024/viewspace-2123397/

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值