暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 史上最全的RAC集群管理命令

原创 人不忘本 2020-05-06
3561

集群管理命令:

  1. CRSCTL命令:
查看集群中所有资源状态
crsctl status res -t 
守护进程状态:
crsctl status res -t -init 
启动/关闭 集群服务:
crsctl start/stop crs
关闭OHASD:
crsctl stop ohas -f
独占模式启动集群:
crsctl start crs -excl -nocrs
检查集群服务状态:
crsctl check crs 
集群自启动:
crsctl enable/disable crs

	
关闭启动指定资源:
crsctl start/stop res res_name //有的无法单独关闭,因为存在资源依赖关系
查看资源属性:
crsctl status res res_name -f
修改资源属性 :
crsctl modify resource res_name -attr 
从12c开始crsctl start/stop resource 与 crsctl modify resource 不再支持
但是可以添加-unsupported使用
crsctl modify resource res_name -attr <> -unsupported 
crsctl start/stop res res_name -unsupported 

关闭集群后台进程:
[root@rac2 ~]# /oracle/grid/crs_1/bin/crsctl stop res ora.cluster_interconnect.haip -init
CRS-2673: Attempting to stop 'ora.cluster_interconnect.haip' on 'rac2'
CRS-2677: Stop of 'ora.cluster_interconnect.haip' on 'rac2' succeeded

启动指定后台进程:
[root@rac2 ~]# /oracle/grid/crs_1/bin/crsctl start res ora.crsd -init
CRS-2672: Attempting to start 'ora.asm' on 'rac2'
CRS-2676: Start of 'ora.asm' on 'rac2' succeeded
CRS-2672: Attempting to start 'ora.crsd' on 'rac2'
CRS-2676: Start of 'ora.crsd' on 'rac2' succeeded


crsctl start cluster 
可以对集群的所有节点资源进行操作。(前提是目标节点OHASD进程必须已经启动)
crsctl start crs   
对当前节点的资源进行操作,包含OHAS。

[grid@node1 ~]$ crsctl check cluster
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online

[grid@node1 ~]$ 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
复制
  1. SRVCTL命令:
查询所有实例的状态
srvctl status database -d racdb

查询单节点实例的状态
srvctl status instance -d racdb -i racdb1 

关闭所有节点的实例
srvctl stop database -d racdb 

关闭单节点的实例
srvctl stop instance -d racdb -i racdb2 

查看数据库配置
srvctl config database -d racdb

使用srvctl资源控制命令:
srvctl config network 
srvctl config vip 
srvctl status vip 
srvctl config scan
srvctl status scan
srvctl config listener
srvctl status listener
srvctl start/stop listener
srvctl config scan_listener
srvctl status scan_listener
srvctl config asm 
srvctl status asm
srvctl status diskgroup -g data
srvctl remove database -d orcl    删除数据库资源
srvctl config nodeapps -a 查看集群VIP
oifcfg getif 查看集群网卡
oifcfg delif 删除集群网卡
oifcfg setif 重新配置集群网卡

手动漂移SCAN到另外节点
SCAN漂移:
[grid@hzzxdb1 ~]$ srvctl relocate scan_listener -i 1 -n hzzxdb1
[grid@hzzxdb1 ~]$ srvctl relocate scan_listener -i 1 -n hzzxdb2

olsnodes命令:
[grid@rac11gn2 ~]$ olsnodes -h
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

复制
  1. ASM管理命令:
创建磁盘组:
create diskgroup FLASH_DISK external redundancy disk '/dev/oracleasm/disks/ASMDISK1' ;

查看磁盘组状态:
select name,state from v$asm_diskgroup;

磁盘组挂载与卸载:
alter diskgroup FLASH_DISK mount/dismount;

查看磁盘名与设备的关系:
select name,path from v$asm_disk_stat;

查看每个磁盘组可用大小:
select name,allocation_unit_size,free_mb,total_mb from v$asm_diskgroup;

向磁盘组中增加一个磁盘:
ALTER DISKGROUP ARCH_DISK ADD DISK '/dev/oracleasm/disks/ASMDISK3' (name ARCHDISK2);

从磁盘组中删除一个磁盘:
ALTER DISKGROUP ARCH_DISK DROP DISK ARCHDISK2;

删除一个磁盘组:(确保该磁盘被所有实例所卸载dismount)
drop diskgroup FLASH_DISK;

删除一个有内容的磁盘组:
drop diskgroup ocr2 including contents; 

手动重新平衡磁盘组:
ALTER DISKGROUP data2 REBALANCE    
ALTER DISKGROUP data2 REBALANCE   power 5
如果不指定power,以初始化参数值ASM_POWER_LIMIT为默认值

对于ASM磁盘组兼容性设定为11.2.0.2或更高,值的操作范围是0到1024用于重新平衡能力。
对于ASM磁盘组兼容性设定为小于11.2.0.2,该值的操作范围是0到11。如果ASM_POWER_LIMIT大于11,则使用11.

关闭ASM:
(需要与crs一起关闭) srvctl stop crs 
复制
  1. OCR管理命令:
ocrcheck
ocrconfig -add +data2
ocrconfig -delete +data2
ocrconfig -manualbackup
ocrconfig -showbackup
ocrconfig -export file_name
ocrconfig -import file_name
复制
  1. OLR管理命令:
ocrconfig -local   -manualbackup
ocrconfig -local   -showbackup
ocrconfig -local  -export file_name
ocrconfig -local  -import file_name
复制
  1. Voting file管理命令:
crsctl replace votedisk diskgroup_name
crsctl query css votedisk

v$asm_disk             -->   voting file
v$asm_diskgroup --> voting files

select name,path,voting_file from v$asm_disk;
复制
最后修改时间:2021-01-18 23:44:04
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论