Oracle 11g RAC集群日常运维命令总结

2024年 7月 31日 102.2k 0

一、高频集群管理命令

在日常运维工作中,我们可以利用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集群几个主要进程:

  1. [oracle@rac1:/home/oracle]$ ps -ef|grep lmd

  2. grid 4458 1 0 22:43 ? 00:00:00 asm_lmd0_+ASM1

  3. oracle 4909 1 0 22:44 ? 00:00:01 ora_lmd0_orcl1

  4. oracle 5609 5554 0 22:48 pts/2 00:00:00 grep --color=auto lmd

  5. [oracle@rac1:/home/oracle]$ ps -ef|grep lck

  6. grid 4485 1 0 22:43 ? 00:00:00 asm_lck0_+ASM1

  7. oracle 4956 1 0 22:44 ? 00:00:00 ora_lck0_orcl1

  8. oracle 5686 5554 0 22:49 pts/2 00:00:00 grep --color=auto lck

  9. [oracle@rac1:/home/oracle]$ ps -ef|grep lmon

  10. grid 4456 1 0 22:43 ? 00:00:00 asm_lmon_+ASM1

  11. oracle 4907 1 0 22:44 ? 00:00:00 ora_lmon_orcl1

  12. oracle 5713 5554 0 22:49 pts/2 00:00:00 grep --color=auto lmon

  13. [oracle@rac1:/home/oracle]$ ps -ef|grep lms

  14. grid 4460 1 0 22:43 ? 00:00:01 asm_lms0_+ASM1

  15. oracle 4911 1 0 22:44 ? 00:00:01 ora_lms0_orcl1

  16. oracle 4915 1 0 22:44 ? 00:00:01 ora_lms1_orcl1

  17. oracle 5751 5554 0 22:50 pts/2 00:00:00 grep --color=auto lms

  18. [oracle@rac1:/home/oracle]$ ps -ef|grep diag

  19. grid 4450 1 0 22:43 ? 00:00:00 asm_diag_+ASM1

  20. oracle 4897 1 0 22:44 ? 00:00:00 ora_diag_orcl1

  21. oracle 5791 5554 0 22:50 pts/2 00:00:00 grep --color=auto diag

  22. [oracle@rac1:/home/oracle]$ ps -ef|grep rbal

  23. grid 4476 1 0 22:43 ? 00:00:00 asm_rbal_+ASM1

  24. oracle 4935 1 0 22:44 ? 00:00:00 ora_rbal_orcl1

  25. oracle 5828 5554 0 22:51 pts/2 00:00:00 grep --color=auto rbal

  26. [oracle@rac1:/home/oracle]$ ps -ef|grep asmb

  27. grid 4520 1 0 22:43 ? 00:00:00 asm_asmb_+ASM1

  28. grid 4522 1 0 22:43 ? 00:00:00 oracle+ASM1_asmb_+asm1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

  29. oracle 4937 1 0 22:44 ? 00:00:00 ora_asmb_orcl1

  30. grid 4941 1 0 22:44 ? 00:00:00 oracle+ASM1_asmb_orcl1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

  31. oracle 5852 5554 0 22:51 pts/2 00:00:00 grep --color=auto asmb

  32. [oracle@rac1:/home/oracle]$ ps -ef|grep ping

  33. root 2928 2503 0 22:42 ? 00:00:00 /usr/libexec/gsd-housekeeping

  34. grid 4452 1 0 22:43 ? 00:00:00 asm_ping_+ASM1

  35. oracle 4901 1 0 22:44 ? 00:00:00 ora_ping_orcl1

  36. oracle 5888 5554 0 22:52 pts/2 00:00:00 grep --color=auto ping

  37. [oracle@rac1:/home/oracle]$ ps -ef|grep lmhb

  38. grid 4464 1 0 22:43 ? 00:00:00 asm_lmhb_+ASM1

  39. oracle 4921 1 0 22:44 ? 00:00:00 ora_lmhb_orcl1

  40. oracle 5917 5554 0 22:52 pts/2 00:00:00 grep --color=auto lmhb

  41. [oracle@rac1:/home/oracle]$ ps -ef|grep rms

  42. oracle 4919 1 0 22:44 ? 00:00:00 ora_rms0_orcl1

  43. oracle 5937 5554 0 22:52 pts/2 00:00:00 grep --color=auto rms

  44. [oracle@rac1:/home/oracle]$ ps -ef|grep rsm

  45. oracle 4958 1 0 22:44 ? 00:00:00 ora_rsmn_orcl1

  46. oracle 5970 5554 0 22:53 pts/2 00:00:00 grep --color=auto rsm

  47. [oracle@rac1:/home/oracle]$ ps -ef|grep gtx

  48. oracle 5001 1 0 22:44 ? 00:00:00 ora_gtx0_orcl1

  49. oracle 6000 5554 0 22:53 pts/2 00:00:00 grep --color=auto gtx

  50. [oracle@rac1:/home/oracle]$ ps -ef|grep rcbg

  51. oracle 5003 1 0 22:44 ? 00:00:00 ora_rcbg_orcl1

  52. oracle 6033 5554 0 22:54 pts/2 00:00:00 grep --color=auto rcbg

  53. [oracle@rac1:/home/oracle]$ ps -ef|grep acms

  54. oracle 4903 1 0 22:44 ? 00:00:00 ora_acms_orcl1

  55. oracle 6063 5554 0 22:54 pts/2 00:00:00 grep --color=auto acms

  56. [oracle@rac1:/home/oracle]$ ps -ef|grep css

  57. root 2380 1 0 16:33 ? 00:00:03 /u01/app/11.2.0/grid/bin/cssdmonitor

  58. root 2392 1 0 16:33 ? 00:00:04 /u01/app/11.2.0/grid/bin/cssdagent

  59. grid 2415 1 0 16:33 ? 00:00:24 /u01/app/11.2.0/grid/bin/ocssd.bin

  60. oracle 13263 13218 0 18:20 pts/1 00:00:00 grep --color=auto css

  61. [oracle@rac1:/home/oracle]$ ps -ef|grep crs

  62. root 2722 1 1 16:34 ? 00:01:08 /u01/app/11.2.0/grid/bin/crsd.bin reboot

  63. oracle 13278 13218 0 18:20 pts/1 00:00:00 grep --color=auto crs

  64. [oracle@rac1:/home/oracle]$ ps -ef|grep evm

  65. grid 2608 1 0 16:34 ? 00:00:31 /u01/app/11.2.0/grid/bin/evmd.bin

  66. 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

  67. oracle 13291 13218 0 18:20 pts/1 00:00:00 grep --color=auto evm

  68. [grid@rac1:/home/grid]$ ps -ef|grep asm

  69. grid 4409 1 0 22:43 ? 00:00:00 asm_pmon_+ASM1

  70. grid 4411 1 0 22:43 ? 00:00:00 asm_psp0_+ASM1

  71. grid 4444 1 0 22:43 ? 00:00:01 asm_vktm_+ASM1

  72. grid 4448 1 0 22:43 ? 00:00:00 asm_gen0_+ASM1

  73. grid 4450 1 0 22:43 ? 00:00:02 asm_diag_+ASM1

  74. grid 4452 1 0 22:43 ? 00:00:00 asm_ping_+ASM1

  75. grid 4454 1 0 22:43 ? 00:00:05 asm_dia0_+ASM1

  76. grid 4456 1 0 22:43 ? 00:00:04 asm_lmon_+ASM1

  77. grid 4458 1 0 22:43 ? 00:00:04 asm_lmd0_+ASM1

  78. grid 4460 1 0 22:43 ? 00:00:07 asm_lms0_+ASM1

  79. grid 4464 1 0 22:43 ? 00:00:00 asm_lmhb_+ASM1

  80. grid 4466 1 0 22:43 ? 00:00:00 asm_mman_+ASM1

  81. grid 4468 1 0 22:43 ? 00:00:00 asm_dbw0_+ASM1

  82. grid 4470 1 0 22:43 ? 00:00:00 asm_lgwr_+ASM1

  83. grid 4472 1 0 22:43 ? 00:00:00 asm_ckpt_+ASM1

  84. grid 4474 1 0 22:43 ? 00:00:00 asm_smon_+ASM1

  85. grid 4476 1 0 22:43 ? 00:00:00 asm_rbal_+ASM1

  86. grid 4478 1 0 22:43 ? 00:00:00 asm_gmon_+ASM1

  87. grid 4480 1 0 22:43 ? 00:00:00 asm_mmon_+ASM1

  88. grid 4482 1 0 22:43 ? 00:00:00 asm_mmnl_+ASM1

  89. grid 4485 1 0 22:43 ? 00:00:00 asm_lck0_+ASM1

  90. grid 4520 1 0 22:43 ? 00:00:00 asm_asmb_+ASM1

  91. grid 4522 1 0 22:43 ? 00:00:00 oracle+ASM1_asmb_+asm1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

  92. oracle 4937 1 0 22:44 ? 00:00:00 ora_asmb_orcl1

  93. grid 4941 1 0 22:44 ? 00:00:00 oracle+ASM1_asmb_orcl1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

  94. grid 9289 6360 0 23:33 pts/3 00:00:00 grep --color=auto asm

(一)RAC集群配置查看

1、查看 scan ip 地址配置

  1. [grid@rac1:/home/grid]$ srvctl config scan

  2. [grid@rac1:/home/grid]$ srvctl status scan

Oracle 11g RAC集群日常运维命令总结-1
2、查看 SCAN 监听情况

  1. [grid@rac1:/home/grid]$ srvctl status scan_listener

Oracle 11g RAC集群日常运维命令总结-2
3、查询节点应用程序状态

  1. [grid@rac1:/home/grid]$ srvctl status nodeapps

Oracle 11g RAC集群日常运维命令总结-3
4、查看节点应用程序配置(VIP、GSD、ONS、监听器)

  1. [grid@rac1:/home/grid]$ srvctl config nodeapps

Oracle 11g RAC集群日常运维命令总结-4
5、查看TNS监听

  1. [grid@rac1:/home/grid]$ srvctl status listener

Oracle 11g RAC集群日常运维命令总结-5
查看监听配置

  1. [grid@rac1:/home/grid]$ srvctl config listener -a

Oracle 11g RAC集群日常运维命令总结-6
6、查看vip网络

  1. [grid@rac1:/home/grid]$ srvctl status vip -n rac1

Oracle 11g RAC集群日常运维命令总结-7

  1. [grid@rac1:/home/grid]$ srvctl config vip -n rac1

  2. [grid@rac1:/home/grid]$ srvctl config vip -n rac2

Oracle 11g RAC集群日常运维命令总结-8
7、查看集群私网信息

  1. [grid@rac1:/home/grid]$ oifcfg getif

Oracle 11g RAC集群日常运维命令总结-9
8、查看ASM

  1. [grid@rac1:/home/grid]$ srvctl status asm

Oracle 11g RAC集群日常运维命令总结-10

  1. [grid@rac1:/home/grid]$ srvctl config asm -a

Oracle 11g RAC集群日常运维命令总结-11
9、验证所有集群节点间的时钟同步

  1. [grid@rac1:/home/grid]$ cluvfy comp clocksync -verbose

Oracle 11g RAC集群日常运维命令总结-12

(二)集群服务启停命令

1、查询当前集群软件版本和主机名

  1. [grid@rac1:/home/grid]$ crsctl query crs softwareversion rac1

Oracle 11g RAC集群日常运维命令总结-13

  1. [grid@rac1:/home/grid]$ crsctl query crs activeversion

Oracle 11g RAC集群日常运维命令总结-14
2、查看集群的名称

  1. [grid@rac1:/home/grid]$ cemutlo -n

Oracle 11g RAC集群日常运维命令总结-15
3、检查Cluster Ready Services(CRS)的状态

  1. [grid@rac1:/home/grid]$ crsctl check crs

Oracle 11g RAC集群日常运维命令总结-16
4、检查Cluster Synchronization Services Daemon(CSSD)的状态

  1. [grid@rac1:/home/grid]$ crsctl check cssd

Oracle 11g RAC集群日常运维命令总结-17
5、检查Cluster Ready Services Daemon(CRSD)的状态

  1. [grid@rac1:/home/grid]$ crsctl check crsd

Oracle 11g RAC集群日常运维命令总结-18
6、检查Event Manager Daemon(EVM)的状态

  1. [grid@rac1:/home/grid]$ crsctl check evmd

Oracle 11g RAC集群日常运维命令总结-19
7、查看voting disk位置

  1. [grid@rac1:/home/grid]$ crsctl query css votedisk

Oracle 11g RAC集群日常运维命令总结-20
8、查看集群的进程状态

  1. [grid@rac1:/home/grid]$ crsctl check cluster

Oracle 11g RAC集群日常运维命令总结-21
查看集群组件状态

  1. [grid@rac1:/home/grid]$ crs_stat -t -v

Oracle 11g RAC集群日常运维命令总结-22
9、一键启停所有节点上的css及资源

  1. [grid@rac1:/home/grid]$ crsctl stop cluster -all

  2. [grid@rac1:/home/grid]$ crsctl start cluster -all

10、检查并显示OCR(Oracle Cluster Registry)的位置

  1. [grid@rac1:/home/grid]$ ocrcheck

Oracle 11g RAC集群日常运维命令总结-23
11、查看数据库的状态

  1. [grid@rac1:/home/grid]$ srvctl status database -d orcl

Oracle 11g RAC集群日常运维命令总结-24

  1. [grid@rac1:/home/grid]$ srvctl config database -d orcl -a

Oracle 11g RAC集群日常运维命令总结-25
12、启动数据库

  1. [grid@rac1:/home/grid]$ srvctl start database -d orcl

Oracle 11g RAC集群日常运维命令总结-26

13、详细输出资源全名称并检查状态

  1. [grid@rac1:/home/grid]$ crsctl status resource -t

Oracle 11g RAC集群日常运维命令总结-27
14、查看ocr备份信息

  1. [grid@rac1:/home/grid]$ ocrconfig -showbackup

Oracle 11g RAC集群日常运维命令总结-28

(三)ASM磁盘组相关维护命令

1、查看磁盘状态

  1. SQL> set lines 200 pages 200

  2. SQL> select group_number,name,type,total_mb,free_mb from v$asm_diskgroup;

Oracle 11g RAC集群日常运维命令总结-29

  1. SQL> col name for a20

  2. SQL> col path for a50

  3. SQL> select NAME,PATH,total_mb,free_mb from v$asm_disk;

Oracle 11g RAC集群日常运维命令总结-30

  1. SQL> select name,state from v$asm_diskgroup;

Oracle 11g RAC集群日常运维命令总结-31
2、asm 磁盘组删除

  1. sql>drop diskgroup DATA;

3、asm磁盘组添加磁盘

  1. sql> alter diskgroup data add disk '/dev/mapper/asm_data';

4、使用asmcmd增加删除磁盘、磁盘组、控制磁盘Rebalance
(1)增加磁盘:

  1. 使用asmcmd命令登录到ASM实例:asmcmd

  2. 使用lsdg命令列出所有磁盘组:lsdg

  3. 使用ls命令列出所有磁盘组中的磁盘:ls

  4. 使用cd命令切换到目标磁盘组:cd

  5. 使用mkdisk命令创建新磁盘:mkdisk

  6. 使用ls命令确认新磁盘已添加到磁盘组:ls

(2)删除磁盘:

  1. 使用asmcmd命令登录到ASM实例:asmcmd

  2. 使用lsdg命令列出所有磁盘组:lsdg

  3. 使用ls命令列出所有磁盘组中的磁盘:ls

  4. 使用cd命令切换到目标磁盘组:cd

  5. 使用rm命令删除指定磁盘:rm

  6. 使用ls命令确认磁盘已从磁盘组中删除:ls

(3)增加磁盘组:

  1. 使用asmcmd命令登录到ASM实例:asmcmd

  2. 使用lsdg命令列出所有磁盘组:lsdg

  3. 使用mkdg命令创建新磁盘组:mkdg

  4. 使用lsdg命令确认新磁盘组已创建成功:lsdg

(四)常用的几个SQL命令

1、查看数据库基础信息

  1. SQL> set lines 200 pages 200

  2. SQL> select name,log_mode,open_mode,platform_name,db_unique_name from v$database;

Oracle 11g RAC集群日常运维命令总结-32
2、查看数据库版本

  1. SQL> SELECT * FROM v$version;

Oracle 11g RAC集群日常运维命令总结-33
3、查看数据库字符集

  1. SQL> select * from nls_database_parameters where parameter like '%CHARACTERSET%';

Oracle 11g RAC集群日常运维命令总结-34
4、查看实例的运行状态

  1. SQL> SELECT instance_name, status FROM v$instance;

Oracle 11g RAC集群日常运维命令总结-35
5、查看归档的状态

  1. SQL> archive log list;

文中的概念来源于互联网,如有侵权,请联系我删除。

欢迎关注公众号:小周的数据库进阶之路,一起交流数据库、中间件和云计算等技术。欢迎觉得读完本文有收获,可以转发给其他朋友,大家一起学习进步!感兴趣的朋友可以加我微信,拉您进群与业界的大佬们一起交流学习。

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论