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/

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/cjh81378066/article/details/100354610

智能推荐

java如何得到浏览器的Ip_java获取浏览器ip-程序员宅基地

文章浏览阅读1.7k次。java得到浏览器ip//获取请求IPString ip = request.getHeader ("x-forwarded-for");if (ip ==null || ip.length() ==0 || "unknown".equalsIgnoreCase (ip)) { ip = request.getHeader ("Proxy-Client-IP");}if (ip ==..._java获取浏览器ip

实景三维可视化管理平台助力提升景区运营管理水平_三维景区平台年度绩效目标-程序员宅基地

文章浏览阅读195次。利用数字孪生技术打造的实景三维可视化管理平台,对各个智能化系统进行集成及历史数据技术的挖掘和分析,提高了数据信息的应用能力和反馈能力,同时也提升了景区的运营管理水平和决策能力。_三维景区平台年度绩效目标

IBM服务器引导盘serverguide 下载_serverguide下载-程序员宅基地

文章浏览阅读2.4w次,点赞4次,收藏25次。ServerGuide 下载 1、ibm_utl_sguide_8.42_anyos_x86-64 http://pan.baidu.com/s/1hq43QSk 2、ibm_utl_sguide_9.22_x86-64 http://pan.baidu.com/s/1mgp2O_serverguide下载

信息学奥赛一本通 1100:金币(信奥1100)_清清将巧克力作为工资,发放给忠诚的奥赛选手。第一天,奥赛选手收到一枚巧克力;之-程序员宅基地

文章浏览阅读801次。信息学奥赛一本通 1100:金币国王将金币作为工资,发放给忠诚的骑士。第1天,骑士收到一枚金币;之后两天(第2天和第3天)里,每天收到两枚金币;之后三天(第4、5、6天)里,每天收到三枚金币;之后四天(第7、8、9、10天)里,每天收到四枚金币……这种工资发放模式会一直这样延续下去:当连续n天每天收到n枚金币后,骑士会在之后的连续n+1天里,每天收到n+1枚金币(n为任意正整数)。_清清将巧克力作为工资,发放给忠诚的奥赛选手。第一天,奥赛选手收到一枚巧克力;之

Kubeflow 快速入门-程序员宅基地

文章浏览阅读480次。2019独角兽企业重金招聘Python工程师标准>>> ..._kubeflow 入门到精通

2021-09-27-程序员宅基地

文章浏览阅读37次。一些名词解释1.JDK是 Java 语言的软件开发工具包,主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具。它是一种用于构建在 Java 平台上发布的应用程序、applet 和组件的开发环境。2.环境变量(environment variables)一般是指在操作系统中用来指定操作系统运行环境的一些参数,如:临时文件夹位置和系统文件夹位置等。环境变量是在操作系统中一个具有特定名字的对象,它包含了一个或

随便推点

oracle取字段部分内容,Oracle数据库取出部分字段的方法-程序员宅基地

文章浏览阅读1.8k次。Oracle数据库取出部分字段的方法发布时间:2020-06-16 13:39:51来源:亿速云阅读:102作者:鸽子如:表所有字段:背景色为要取出的字段unit表:num, bm, dw_name, dw_name_pre, dw_codework表: name, do, check, isdel, writetime, qy_code其中,unit表dw_code == work表qy_cod..._oracle中如果数据量太大如何取别的表的字段

java计算机毕业设计HTML5历史车轮—汴京网站源码+mysql数据库+系统+lw文档+部署-程序员宅基地

文章浏览阅读74次。java计算机毕业设计HTML5历史车轮—汴京网站源码+mysql数据库+系统+lw文档+部署。springcloud基于微服务架构的乐居租房网的设计与实现。ssm+sqlserver中小型连锁超市配送中心库存管理系统。springboot物流车辆规费管理系统的设计与实现。springboot在线问诊系统的设计与实现。ssm基于移动端的校园请假系统的设计与实现。ssm基于java的钢材出入库管理系统。

MySQL约束_怎么让数据库 不是null-程序员宅基地

文章浏览阅读927次,点赞2次,收藏3次。MySQL为了让我们的表结构里面的数据完整性一致性非常强,mysql是给我们提供强约束的,在建表的时候就要把约束建立好。_怎么让数据库 不是null

QT调用C#的Dll_qt调用c#dll-程序员宅基地

文章浏览阅读4.7k次,点赞12次,收藏41次。1:环境:VS2017 QT 5.12.4(1)说明:Qt是不能直接调用C#生成的dll,需要将C#的编写的dll通过CLR编译成lib(2)检查VS环境是否装好:看下图勾选部分是否安装,没有安装需及时安装_qt调用c#dll

java计算机毕业设计口红专卖网站源码+mysql数据库+系统+lw文档+部署-程序员宅基地

文章浏览阅读88次。java计算机毕业设计口红专卖网站源码+mysql数据库+系统+lw文档+部署。ssm基于SSM+VUE技术的小区车辆档案车位管理系统设计与实现。jsp网上花卉销售系统的设计与实现sqlserver。springboot烟草经销平台的设计与实现。jsp基于web的面向公众的食品安全知识系统。springboot智能推荐的卫生健康系统。ssn基于SSM宠物店管理系统的设计与实现。

超详细的Java入门到精通完整学习教程,学Java一定得收藏!_java教程-程序员宅基地

文章浏览阅读1.9k次。从 1995 年第一个版本发布到现在,Java 语言已经在跌宕起伏中走过了 26 年,最新的 Java 版本也已经迭代到 Java 16。java是有一个庞大的生态系统,它的覆盖范围非常广,而且已经连续十几年位居开发语言的榜首,所以java是相对于其他语言来说,非常稳定的。JAVA市场java有非常广泛的应用市场,它的生态系统几乎涵盖了目前市面上所有的软硬件,java几乎是万能的,你能想到的,java基本都能实现(虽然吹的有点大,但不可否认)。web开发:能做大型的互联网网站如,京东,.._java教程

推荐文章

热门文章

相关标签