1. 首页 > Linux教程 > 正文

Linux教程FG322-集群仲裁配置

内容简介:本文风哥教程参考Linux官方文档、Red Hat Enterprise Linux官方文档、Ansible Automation Platform官方文档、Docker官方文档、Kubernetes官方文档和Podman官方文档等内容,详细介绍了相关技术的配置和使用方法。

本文档详细介

风哥提示:

绍集群仲裁(Quorum)的配置和管理方法。

Part01-仲裁基础

1.1 查看仲裁状态

# 查看仲裁状态
[root@ha-node1 ~]# pcs quorum status
Quorum information
——————
Date: Fri Apr 4 11:30:00 2026
Quorum provider: corosync_votequorum
Nodes: 2
Node ID: 1
Quorate: Yes

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

Membership information
———————-
Nodeid Votes Name
1 1 ha-node1 (local)
2 1 ha-node2

# 查看仲裁配置
[root@ha-node1 ~]# pcs quorum config
quorum {
provider: corosync_votequorum
two_node: 1
}

Part02-仲裁设备配置

2.1 配置仲裁设备

# 安装仲裁设备软件包
[root@qdevice ~]# dnf install -y corosync-qnetd
Updating Subscription Management repositories.
Last metadata expiration check: 0:05:23 ago on Fri Apr 4 11:25:00 2026.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
corosync-qnetd x86_64 3.1.7-1.el9 appstream 50 k

Transaction Summary
================================================================================
Install 1 Package

Total download size: 50 k
Installed size: 100 k
Downloading Packages:
corosync-qnetd-3.1.7-1.更多视频教程www.fgedu.net.cnel9.x86_64.rpm 1.0 MB/s | 50 kB 00:00
——————————————————————————–
Total 1.0 MB/s | 50 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : corosync-qnetd-3.1.7-1.el9.x86_64 1/1
Running scriptlet: corosync-qnetd-3.1.7-1.el9.x86_64 1/1
Verifying : corosync-qnetd-3.1.7-1.el9.x86_64 1/1

Installed:
corosync-qnetd-3.1.7-1.el9.x86_64

Complete!

# 启动仲裁设备服务
[root@qdevice ~]# systemctl enable –now corosync-qnetd
Created symlink /etc/systemd/system/multi-user.target.wants/corosync-qnetd.service → /usr/lib/systemd/system/corosync-qnetd.service.

# 验证服务状态
[root@qdevice ~]# systemctl status corosync-qnetd
● corosync-qnetd.service – Corosync Qnetd
Loaded: loaded (/usr/lib/systemd/system/corosync-qnetd.service; enabled; preset: disabled)
Active: active (running) since Fri 2026-04-04 11:30:00 CST; 5s ago
Main PID: 12345 (corosync-qnetd)
Tasks: 1 (limit: 11232)
Memory: 1.2M
CGroup: /system.slice/corosync-qnetd.service
└─12345 /usr/sbin/corosync-qnetd -f

Apr 04 11:30:00 qdevice systemd[1]: Started Corosync Qnetd.

2.2 添加仲裁设备到集群

# 在集群节点安装qdevice软件包
[root@ha-node1 ~]# dnf install -y corosync-qdevice
Updating Subscription Management repositories.
Last metadata expiration check: 0:05:23 ago on Fri Apr 4 11:30:00 2026.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
corosync-qdevice x86_64 3.1.7-1.el9 appstream 60 k

Transaction Summary
================================================================================
Install 1 Package

Total download size: 60 k
Installed size: 120 k
Downloading Packages:
corosync-qdevice-3.1.7-1.el9.x86_64.rpm 1.0 MB/s | 60 kB 00:00
——————————————————————————–
Total 1.0 MB/s | 60 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : corosync-qdevice-3.1.7-1.el9.x86_64 1/1
Running scriptlet: corosync-qdevice-3.1.7-1.el9.x86_64 1/1
Verifying : corosync-qdevice-3.1.7-1.el9.x86_64 1/1

Installed:
corosync-qdevice-3.1.7-1.el9.x86_64

Complete!

# 添加仲裁设备到集群
[root@ha-node1 ~]# pcs quorum device add model net host=qdevice.fgedu.net.cn algorithm=lms
Setting up qdevice qnetd…
qdevice.fgedu.net.cn: Setting up corosync-qnetd…
qdevice.fgedu.net.cn: Created directory /etc/corosync/qnetd/nssdb
qdevice.fgedu.net.cn: Generating NSS datab学习交流加群风哥微信: itpux-comase
qdevice.fgedu.net.cn: Certificate database initialization succeeded
qdevice.fgedu.net.cn: Starting corosync-qnetd…
qdevice.fgedu.net.cn: corosync-qnetd started
Sending cluster configuration to all nodes…
ha-node1: Succeeded
ha-node2: Succeeded

# 验证仲裁设备
[root@ha-node1 ~]# pcs quorum device status
Qdevice information
——————-
Model: Net
Configuration: host=qdevice.fgedu.net.cn algorithm=lms
Runtime configuration: host=qdevice.fgedu.net.cn algorithm=lms

Part03-仲裁管理

3.1 查看仲裁设备状态

# 查看仲裁设备状态
[root@ha-node1 ~]# pcs quorum device status
Qdevice information
——————-
Model: Net
Configuration: host=qdevice.fgedu.net.cn algorithm=lms
Runtime configuration: host=qdevice.fgedu.net.cn algorithm=lms

Qnetd host information
———————-
Host: qdevice.fgedu.net.cn
Port: 5403
Algorithm: lms
Tie-breaker: lowest
Cluster name: mycluster
Cluster node id: 1
Cluster node votes: 1

# 查看完整仲裁状态
[root@ha-node1 ~]# pcs quorum status
Quorum information
——————
Date: Fri Apr 4 11:35:00 2026
Quorum provider: corosync_votequorum
Nodes: 2
Node ID: 1
Quorate: Yes

Votequorum information
———————-
Expected votes: 3
Highest expected: 3
Total votes: 3
Quorum: 2
Flags: Quorate Qdevice

Membership information
———————-
Nodeid Votes Name
1 1 ha-node1 (local)
2 1 ha-node2

Qdevice information
———————-
Qdevice ID: 3
Qdevice votes: 1
Qdevice status: Online

3.2 更新仲裁配置

# 更新仲裁算法
[root@ha-node1 ~]# pcs quorum device update model net algorithm=ffsplit
Sending cluster configuration to all nodes…
ha-node1: Succeeded
ha-node2: Succeeded

# 验证更新
[root@ha-node1 ~]# pcs quorum device status
Qdevice information
——————-
Model: Net
Configuration: host=qdevice.fgedu.net.cn algorithm=ff学习交流加群风哥QQ113257174split
Runtime configuration: host=qdevice.fgedu.net.cn algorithm=ffsplit

# 更新仲裁设备主机
[root@ha-node1 ~]# pcs quorum device update model net host=new-qdevice.fgedu.net.cn
Sending cluster configuration to all nodes…
ha-node1: Succeeded
ha-node2: Succeeded

# 验证更新
[root@ha-node1 ~]# pcs quorum device status
Qdevice information
——————-
Model: Net
Configuration: host=new-qdevice.fgedu.net.cn algorithm=ffsplit
Runtime configuration: host=new-qdevice.fgedu.net.cn algorithm=ffsplit

Part04-仲裁设备移除

4.1 移除仲裁设备

# 移除仲裁设备
[root@ha-node1 ~]# pcs quorum device remove
Removing qdevice…
ha-node1: Successfully removed qdevice
ha-node2: Successfully removed qdevice

# 验证移除
[root@ha-node1 ~]# pcs quorum device status
No quorum device configured

# 查看仲裁状态
[root@ha-node1 ~]# pcs quorum status
Quorum information
——————
Date: Fri Apr 4 11:40:00 2026
Quorum provider: corosync_votequorum
Nodes: 2
Node ID: 1
Quorate: Yes

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

Membership information
———————-
Nodeid Votes Name
1 1 ha-node1 (local)
2 1 ha-node2

4.2 仲裁策略配置

# 设置仲裁策略
[root@ha-node1 ~]# pcs property set no-quorum-policy=stop

# 查看仲裁策略
[root@ha-node1 ~]# pcs property list no-quorum-policy
no-quorum-policy: stop

# 仲裁策略选项:
# stop: 无仲裁时停止所有资源(默认)
# freeze: 无仲裁时冻结资源状态
# ignore: 无仲裁时继续运行(不推荐)
# suicide: 无仲裁时关闭所有节点

# 设置双节点仲裁
[root@ha-node1 ~]# pcs quorum update two_node=1

# 验证配置
[root@ha-node1 ~]# pcs quorum config
quorum {
provider: corosync_votequorum
two_node: 1
}

# 设置预期投票数
[root@ha-node1 ~]# pcs quorum update expected_votes=2

# 验证配置
[root@ha-node1 ~]# pcs quorum status
Votequorum information
———————-
Expected votes: 2
Highest expected: 2
Total votes: 2
Quorum: 2

风哥针对仲裁配置建议:

  • 双节点集群建议使用仲裁设备
  • 多节点集群可以不使用仲裁设备
  • 设置合理的仲裁策略
  • 监控仲裁状态
  • 定期测试仲裁功能

本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html

联系我们

在线咨询:点击这里给我发消息

微信号:itpux-com

工作日:9:30-18:30,节假日休息