一、高频集群管理命令
在日常运维工作中,我们可以利用srvctl和crsctl命令进行RAC集群的管理。
SRVCTL(Server Control)是一个命令行工具,用于管理Oracle Cluster Registry (OCR)上的资源,包括节点应用(nodeapps)、Oracle Notification Service (ONS)、Global Services Daemon (GSD)等。它还可以管理数据库、实例、监听器、服务和应用程序。通过SRVCTL,可以启动或停止nodeapps、数据库、实例、监听器和服务,添加、删除或移除实例和服务,以及管理配置信息。
CRSCTL(Cluster Ready Services Control)是一个命令行工具,用于管理Oracle Clusterware守护进程,包括Cluster Synchronization Services (CSS)、Cluster-Ready Services (CRS)和Event Manager (EVM)。通过CRSCTL,可以启动或停止Oracle Cluster,并查看其当前状态。
RAC集群几个主要进程:
-
[oracle@rac1:/home/oracle]$ ps -ef|grep lmd
-
grid 4458 1 0 22:43 ? 00:00:00 asm_lmd0_+ASM1
-
oracle 4909 1 0 22:44 ? 00:00:01 ora_lmd0_orcl1
-
oracle 5609 5554 0 22:48 pts/2 00:00:00 grep --color=auto lmd
-
[oracle@rac1:/home/oracle]$ ps -ef|grep lck
-
grid 4485 1 0 22:43 ? 00:00:00 asm_lck0_+ASM1
-
oracle 4956 1 0 22:44 ? 00:00:00 ora_lck0_orcl1
-
oracle 5686 5554 0 22:49 pts/2 00:00:00 grep --color=auto lck
-
[oracle@rac1:/home/oracle]$ ps -ef|grep lmon
-
grid 4456 1 0 22:43 ? 00:00:00 asm_lmon_+ASM1
-
oracle 4907 1 0 22:44 ? 00:00:00 ora_lmon_orcl1
-
oracle 5713 5554 0 22:49 pts/2 00:00:00 grep --color=auto lmon
-
[oracle@rac1:/home/oracle]$ ps -ef|grep lms
-
grid 4460 1 0 22:43 ? 00:00:01 asm_lms0_+ASM1
-
oracle 4911 1 0 22:44 ? 00:00:01 ora_lms0_orcl1
-
oracle 4915 1 0 22:44 ? 00:00:01 ora_lms1_orcl1
-
oracle 5751 5554 0 22:50 pts/2 00:00:00 grep --color=auto lms
-
[oracle@rac1:/home/oracle]$ ps -ef|grep diag
-
grid 4450 1 0 22:43 ? 00:00:00 asm_diag_+ASM1
-
oracle 4897 1 0 22:44 ? 00:00:00 ora_diag_orcl1
-
oracle 5791 5554 0 22:50 pts/2 00:00:00 grep --color=auto diag
-
[oracle@rac1:/home/oracle]$ ps -ef|grep rbal
-
grid 4476 1 0 22:43 ? 00:00:00 asm_rbal_+ASM1
-
oracle 4935 1 0 22:44 ? 00:00:00 ora_rbal_orcl1
-
oracle 5828 5554 0 22:51 pts/2 00:00:00 grep --color=auto rbal
-
[oracle@rac1:/home/oracle]$ ps -ef|grep asmb
-
grid 4520 1 0 22:43 ? 00:00:00 asm_asmb_+ASM1
-
grid 4522 1 0 22:43 ? 00:00:00 oracle+ASM1_asmb_+asm1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
-
oracle 4937 1 0 22:44 ? 00:00:00 ora_asmb_orcl1
-
grid 4941 1 0 22:44 ? 00:00:00 oracle+ASM1_asmb_orcl1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
-
oracle 5852 5554 0 22:51 pts/2 00:00:00 grep --color=auto asmb
-
[oracle@rac1:/home/oracle]$ ps -ef|grep ping
-
root 2928 2503 0 22:42 ? 00:00:00 /usr/libexec/gsd-housekeeping
-
grid 4452 1 0 22:43 ? 00:00:00 asm_ping_+ASM1
-
oracle 4901 1 0 22:44 ? 00:00:00 ora_ping_orcl1
-
oracle 5888 5554 0 22:52 pts/2 00:00:00 grep --color=auto ping
-
[oracle@rac1:/home/oracle]$ ps -ef|grep lmhb
-
grid 4464 1 0 22:43 ? 00:00:00 asm_lmhb_+ASM1
-
oracle 4921 1 0 22:44 ? 00:00:00 ora_lmhb_orcl1
-
oracle 5917 5554 0 22:52 pts/2 00:00:00 grep --color=auto lmhb
-
[oracle@rac1:/home/oracle]$ ps -ef|grep rms
-
oracle 4919 1 0 22:44 ? 00:00:00 ora_rms0_orcl1
-
oracle 5937 5554 0 22:52 pts/2 00:00:00 grep --color=auto rms
-
[oracle@rac1:/home/oracle]$ ps -ef|grep rsm
-
oracle 4958 1 0 22:44 ? 00:00:00 ora_rsmn_orcl1
-
oracle 5970 5554 0 22:53 pts/2 00:00:00 grep --color=auto rsm
-
[oracle@rac1:/home/oracle]$ ps -ef|grep gtx
-
oracle 5001 1 0 22:44 ? 00:00:00 ora_gtx0_orcl1
-
oracle 6000 5554 0 22:53 pts/2 00:00:00 grep --color=auto gtx
-
[oracle@rac1:/home/oracle]$ ps -ef|grep rcbg
-
oracle 5003 1 0 22:44 ? 00:00:00 ora_rcbg_orcl1
-
oracle 6033 5554 0 22:54 pts/2 00:00:00 grep --color=auto rcbg
-
[oracle@rac1:/home/oracle]$ ps -ef|grep acms
-
oracle 4903 1 0 22:44 ? 00:00:00 ora_acms_orcl1
-
oracle 6063 5554 0 22:54 pts/2 00:00:00 grep --color=auto acms
-
[oracle@rac1:/home/oracle]$ ps -ef|grep css
-
root 2380 1 0 16:33 ? 00:00:03 /u01/app/11.2.0/grid/bin/cssdmonitor
-
root 2392 1 0 16:33 ? 00:00:04 /u01/app/11.2.0/grid/bin/cssdagent
-
grid 2415 1 0 16:33 ? 00:00:24 /u01/app/11.2.0/grid/bin/ocssd.bin
-
oracle 13263 13218 0 18:20 pts/1 00:00:00 grep --color=auto css
-
[oracle@rac1:/home/oracle]$ ps -ef|grep crs
-
root 2722 1 1 16:34 ? 00:01:08 /u01/app/11.2.0/grid/bin/crsd.bin reboot
-
oracle 13278 13218 0 18:20 pts/1 00:00:00 grep --color=auto crs
-
[oracle@rac1:/home/oracle]$ ps -ef|grep evm
-
grid 2608 1 0 16:34 ? 00:00:31 /u01/app/11.2.0/grid/bin/evmd.bin
-
grid 2842 2608 0 16:34 ? 00:00:00 /u01/app/11.2.0/grid/bin/evmlogger.bin -o /u01/app/11.2.0/grid/evm/log/evmlogger.info -l /u01/app/11.2.0/grid/evm/log/evmlogger.log
-
oracle 13291 13218 0 18:20 pts/1 00:00:00 grep --color=auto evm
-
[grid@rac1:/home/grid]$ ps -ef|grep asm
-
grid 4409 1 0 22:43 ? 00:00:00 asm_pmon_+ASM1
-
grid 4411 1 0 22:43 ? 00:00:00 asm_psp0_+ASM1
-
grid 4444 1 0 22:43 ? 00:00:01 asm_vktm_+ASM1
-
grid 4448 1 0 22:43 ? 00:00:00 asm_gen0_+ASM1
-
grid 4450 1 0 22:43 ? 00:00:02 asm_diag_+ASM1
-
grid 4452 1 0 22:43 ? 00:00:00 asm_ping_+ASM1
-
grid 4454 1 0 22:43 ? 00:00:05 asm_dia0_+ASM1
-
grid 4456 1 0 22:43 ? 00:00:04 asm_lmon_+ASM1
-
grid 4458 1 0 22:43 ? 00:00:04 asm_lmd0_+ASM1
-
grid 4460 1 0 22:43 ? 00:00:07 asm_lms0_+ASM1
-
grid 4464 1 0 22:43 ? 00:00:00 asm_lmhb_+ASM1
-
grid 4466 1 0 22:43 ? 00:00:00 asm_mman_+ASM1
-
grid 4468 1 0 22:43 ? 00:00:00 asm_dbw0_+ASM1
-
grid 4470 1 0 22:43 ? 00:00:00 asm_lgwr_+ASM1
-
grid 4472 1 0 22:43 ? 00:00:00 asm_ckpt_+ASM1
-
grid 4474 1 0 22:43 ? 00:00:00 asm_smon_+ASM1
-
grid 4476 1 0 22:43 ? 00:00:00 asm_rbal_+ASM1
-
grid 4478 1 0 22:43 ? 00:00:00 asm_gmon_+ASM1
-
grid 4480 1 0 22:43 ? 00:00:00 asm_mmon_+ASM1
-
grid 4482 1 0 22:43 ? 00:00:00 asm_mmnl_+ASM1
-
grid 4485 1 0 22:43 ? 00:00:00 asm_lck0_+ASM1
-
grid 4520 1 0 22:43 ? 00:00:00 asm_asmb_+ASM1
-
grid 4522 1 0 22:43 ? 00:00:00 oracle+ASM1_asmb_+asm1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
-
oracle 4937 1 0 22:44 ? 00:00:00 ora_asmb_orcl1
-
grid 4941 1 0 22:44 ? 00:00:00 oracle+ASM1_asmb_orcl1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
-
grid 9289 6360 0 23:33 pts/3 00:00:00 grep --color=auto asm
(一)RAC集群配置查看
1、查看 scan ip 地址配置
-
[grid@rac1:/home/grid]$ srvctl config scan
-
[grid@rac1:/home/grid]$ srvctl status scan
2、查看 SCAN 监听情况
-
[grid@rac1:/home/grid]$ srvctl status scan_listener
3、查询节点应用程序状态
-
[grid@rac1:/home/grid]$ srvctl status nodeapps
4、查看节点应用程序配置(VIP、GSD、ONS、监听器)
-
[grid@rac1:/home/grid]$ srvctl config nodeapps
5、查看TNS监听
-
[grid@rac1:/home/grid]$ srvctl status listener
查看监听配置
-
[grid@rac1:/home/grid]$ srvctl config listener -a
6、查看vip网络
-
[grid@rac1:/home/grid]$ srvctl status vip -n rac1
-
[grid@rac1:/home/grid]$ srvctl config vip -n rac1
-
[grid@rac1:/home/grid]$ srvctl config vip -n rac2
7、查看集群私网信息
-
[grid@rac1:/home/grid]$ oifcfg getif
8、查看ASM
-
[grid@rac1:/home/grid]$ srvctl status asm
-
[grid@rac1:/home/grid]$ srvctl config asm -a
9、验证所有集群节点间的时钟同步
-
[grid@rac1:/home/grid]$ cluvfy comp clocksync -verbose
(二)集群服务启停命令
1、查询当前集群软件版本和主机名
-
[grid@rac1:/home/grid]$ crsctl query crs softwareversion rac1
-
[grid@rac1:/home/grid]$ crsctl query crs activeversion
2、查看集群的名称
-
[grid@rac1:/home/grid]$ cemutlo -n
3、检查Cluster Ready Services(CRS)的状态
-
[grid@rac1:/home/grid]$ crsctl check crs
4、检查Cluster Synchronization Services Daemon(CSSD)的状态
-
[grid@rac1:/home/grid]$ crsctl check cssd
5、检查Cluster Ready Services Daemon(CRSD)的状态
-
[grid@rac1:/home/grid]$ crsctl check crsd
6、检查Event Manager Daemon(EVM)的状态
-
[grid@rac1:/home/grid]$ crsctl check evmd
7、查看voting disk位置
-
[grid@rac1:/home/grid]$ crsctl query css votedisk
8、查看集群的进程状态
-
[grid@rac1:/home/grid]$ crsctl check cluster
查看集群组件状态
-
[grid@rac1:/home/grid]$ crs_stat -t -v
9、一键启停所有节点上的css及资源
-
[grid@rac1:/home/grid]$ crsctl stop cluster -all
-
[grid@rac1:/home/grid]$ crsctl start cluster -all
10、检查并显示OCR(Oracle Cluster Registry)的位置
-
[grid@rac1:/home/grid]$ ocrcheck
11、查看数据库的状态
-
[grid@rac1:/home/grid]$ srvctl status database -d orcl
-
[grid@rac1:/home/grid]$ srvctl config database -d orcl -a
12、启动数据库
-
[grid@rac1:/home/grid]$ srvctl start database -d orcl
13、详细输出资源全名称并检查状态
-
[grid@rac1:/home/grid]$ crsctl status resource -t
14、查看ocr备份信息
-
[grid@rac1:/home/grid]$ ocrconfig -showbackup
(三)ASM磁盘组相关维护命令
1、查看磁盘状态
-
SQL> set lines 200 pages 200
-
SQL> select group_number,name,type,total_mb,free_mb from v$asm_diskgroup;
-
SQL> col name for a20
-
SQL> col path for a50
-
SQL> select NAME,PATH,total_mb,free_mb from v$asm_disk;
-
SQL> select name,state from v$asm_diskgroup;
2、asm 磁盘组删除
-
sql>drop diskgroup DATA;
3、asm磁盘组添加磁盘
-
sql> alter diskgroup data add disk '/dev/mapper/asm_data';
4、使用asmcmd增加删除磁盘、磁盘组、控制磁盘Rebalance
(1)增加磁盘:
-
使用asmcmd命令登录到ASM实例:asmcmd
-
使用lsdg命令列出所有磁盘组:lsdg
-
使用ls命令列出所有磁盘组中的磁盘:ls
-
使用cd命令切换到目标磁盘组:cd
-
使用mkdisk命令创建新磁盘:mkdisk
-
使用ls命令确认新磁盘已添加到磁盘组:ls
(2)删除磁盘:
-
使用asmcmd命令登录到ASM实例:asmcmd
-
使用lsdg命令列出所有磁盘组:lsdg
-
使用ls命令列出所有磁盘组中的磁盘:ls
-
使用cd命令切换到目标磁盘组:cd
-
使用rm命令删除指定磁盘:rm
-
使用ls命令确认磁盘已从磁盘组中删除:ls
(3)增加磁盘组:
-
使用asmcmd命令登录到ASM实例:asmcmd
-
使用lsdg命令列出所有磁盘组:lsdg
-
使用mkdg命令创建新磁盘组:mkdg
-
使用lsdg命令确认新磁盘组已创建成功:lsdg
(四)常用的几个SQL命令
1、查看数据库基础信息
-
SQL> set lines 200 pages 200
-
SQL> select name,log_mode,open_mode,platform_name,db_unique_name from v$database;
2、查看数据库版本
-
SQL> SELECT * FROM v$version;
3、查看数据库字符集
-
SQL> select * from nls_database_parameters where parameter like '%CHARACTERSET%';
4、查看实例的运行状态
-
SQL> SELECT instance_name, status FROM v$instance;
5、查看归档的状态
-
SQL> archive log list;
文中的概念来源于互联网,如有侵权,请联系我删除。
欢迎关注公众号:小周的数据库进阶之路,一起交流数据库、中间件和云计算等技术。欢迎觉得读完本文有收获,可以转发给其他朋友,大家一起学习进步!感兴趣的朋友可以加我微信,拉您进群与业界的大佬们一起交流学习。