大网数据广告活动
服务器运维问答

Quickly find out if pacemaker/corosync has quorum/is quorate

· 52CE 我爱测

In a shell script, we currently call /usr/sbin/pcs status cluster and then grep -qE for 'Current DC:.*partition with quorum' to find out if the cluster is fine. I would like to know if there is a quicker way, because pcs status c…

问题原文

原帖链接 · MattBianco · CC BY-SA 3.0

In a shell script, we currently call /usr/sbin/pcs status cluster and then grep -qE for 'Current DC:.*partition with quorum' to find out if the cluster is fine.

I would like to know if there is a quicker way, because pcs status cluster makes it query all nodes for their PCSD status, which takes time, about a second and a half, and I want to do this check before doing certain operations which are to be done quite often.

Would pcs status nodes both and counting the number of online nodes be equally good for deciding if the cluster is functioning without issues?

This takes ~2 seconds: pcs status cluster 2>&1 | grep -qE 'Current DC:.*partition with quorum'

This takes ~0.2 seconds: pcs status nodes both | grep -cE 'Online: [a-z]+ [a-z]+ [a-z]+'

(The cluster has 5 nodes, hence the three node names in the regular expression).

EDIT:

This takes ~0.02 seconds: corosync-quorumtool 2>&1 | grep -q -E '^Quorate:.*Yes$'

Thank you Matt Kereczman!

已采纳解答

原帖链接 · Matt Kereczman · CC BY-SA 3.0

Assuming you're using Corosync, you can use corosync-quorumtool:

# corosync-quorumtool -s
  Quorum information
  ------------------
  Date:             Wed Sep 27 07:16:18 2017
  Quorum provider:  corosync_votequorum
  Nodes:            2
  Node ID:          1
  Ring ID:          76
  Quorate:          Yes

  Votequorum information
  ----------------------
  Expected votes:   2
  Highest expected: 2
  Total votes:      2
  Quorum:           1  
  Flags:            2Node Quorate WaitForAll 

  Membership information
  ----------------------
      Nodeid      Votes Name
           1          1 172.16.7.100 (local)
           2          1 172.16.7.101

EDIT: And then just check that Quorate reports Yes.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-09-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。