1. 首页 > Linux教程 > 正文

Linux教程FG313-pcs property集群属性配置

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

本文档详细介绍pcs property

风哥提示:

命令的使用方法,包括集群属性的查看、设置和管理。

Part01-查看集群属性

1.1 查看所有属性

# 查看所有集群属性
[root@ha-node1 ~]# pcs property list
Cluster Properties:
cluster-infrastructure: corosync
cluster-name: mycluster
dc-version: 2.1.6-1.el9
have-watchdog: false
last-lrm-refresh: 1712203200

# 查看所有属性(包括默认值)
[root@ha-node1 ~]# pcs property list –all
Cluster Properties:
batch-limit: 0
cluster-delay: 60s
cluster-infrastructure: corosync
cluster-ip-timeout: 60s
cluster-name: mycluster
cluster-recheck-interval: 15min
concurrent-fencing: true
dc-deadtime: 20s
dc-version: 2.1.6-1.el9
election-timeout: 2min
enable-acl: false
enable-startup-probes: true
have-watchdog: false
last-lrm-refresh: 1712203200
maintenance-mode: false
migration-limit: -1
no-quorum-policy: stop
node-action-limit: 0
node-health-base: 0
node-health-green: 0
node-health-red: -INFINITY
node-health-strategy: none
node-health-yellow: 0
pe-error-series-max: -1
pe-input-series-max: 4000
pe-warn-series-max: 5000
placement-strategy: default
priority-fencing-delay: 0
shutdown-escalation: 20min
start-failure-is-fatal: true
stonith-action: reboot
stonith-enabled: false
stonith-max-attempts: 10
stonith-timeout: 60s
stonith-watchdog-timeout: 0
stop-all-resources: false
stop-orphan-actions: true
stop-orphan-resources: true
symmetric-cluster: true

Part02-设置集群属性

2.1 设置stonith属性

# 启用stonith(fence设备)
[root@ha-node1 ~]# pcs property set stonith-enabled=true

# 验证设置
[root@ha-node1 ~]# pcs property list stonith-enabled
stonith-enabled: true

# 设置stonith超时时间
[root@ha-node1 ~]# pcs property set stonith-timeout=90s

# 设置stonith动作
[root@ha-node1 ~]# pcs property set stonith-action=off

# 查看stonith相关属性
[root@ha-node1 ~]# pcs property list | grep stonith
stonith-action: off
stonith-enabled: true
stonith-max-attempts: 10
stonith-timeout: 90s
stonith-watchdog-timeout: 0

2.2 设置仲裁策略

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

# 查看当前设置
[root@ha-node1 ~]# pcs property list no-quorum-policy
no-quorum-policy: ignore

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

# 验证设置
[root@ha-node1 ~]# pcs property list
Cluster Properties:
cluster-infrastructure: corosync
cluster-name: mycluster
学习交流加群风哥QQ113257174 dc-version: 2.1.6-1.el9
have-watchdog: false
no-quorum-policy: ignore
stonith-enabled: true

2.3 设置集群延迟

# 设置集群延迟
[root@ha-node1 ~]# pcs property set cluster-delay=30s

# 设置DC死锁时间
[root@ha-node1 ~]# pcs property set dc-deadtime=30s

# 设置选举超时
[root@ha-node1 ~]# pcs property set election-timeout=3min

# 设置集群重新检查间隔
[root@ha-node1 ~]# pcs property set cluster-recheck-interval=10min

# 查看时间相关属性
[root@ha-node1 ~]# pcs property list | grep -E “timeout|delay|time”
cluster-delay: 30s
cluster-ip-timeout: 60s
cluster-recheck-interval: 10min
dc-deadtime: 30s
election-timeout: 3min
stonith-timeout: 90s
stonith-watchdog-timeout: 0

Part03-维护模式

3.1 设置维护模式

# 启用维护模式
[root@ha-node1 ~]# pcs property set maintenance-mode=true

# 验证维护模式
[root@ha-node1 ~]# pcs property list maintenance-mode
maintenance-mode: true

# 查看集群状态
[root@ha-node1 ~]# pcs status
Cluster name: mycluster
Cluster Summary:
* Stack: corosync
* Current DC: ha-node1 (version 2.1.6-1.el9)
* Last updated: Fri Apr 4 10:40:00 2026
* Last change: Fri Apr 4 10:39:00 2026
* 2 nodes configured
* 2 resource instances configured

Node List:
* Online: [ ha-node1 ha-node2 ]

Full List of Resources:
* vip (ocf::heartbeat:IPaddr2): Started (disabled)

Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled

# 取消维护模式
[root@ha-node1 ~]# pcs property set maintenance-mode=false

# 验证取消
[root@ha-node1 ~]# pcs property list maintenance-mode
maintenance-mode: false

Part04-默认粘性

4.1 设置资源粘性

# 设置默认资源粘性
[root@ha-node1 ~]# pcs resource defaults resource-stickiness=100

# 查看默认值
[root@ha-node1 ~]# pcs resource defaults
resource-stickiness: 100

# 设置迁移阈值
[root@ha-node1 ~]# pcs resource defaults migration-threshold=3

# 查看所有默认值
[root@ha-node1 ~]# pcs resource defaults
migration-threshold: 3
resource-stickiness: 100

# 清除默认值
[root@ha-node1 ~]# pcs resource defaults update resource-stickiness=

# 验证清除
[root@ha-node1 ~]# pcs resource defaults
migration-threshold: 3

Part05-属性管理

5.更多视频教程www.fgedu.net.cn1 删除属性

# 删除单个属性
[root@ha-node1 ~]# pcs property unset no-quorum-policy

# 验证删除
[root@ha-node1 ~]# pcs property list no-quorum-policy
no-quorum-policy: stop

# 恢复默认值
[root@ha-node1 ~]# pcs property set no-quorum-policy=stop

# 批量设置属性
[root@ha-node1 ~]# pcs property set \
stonith-enabled=true \
no-quorum-policy=ignore \
cluster-delay=30s

# 验证批量设置
[root@ha-node1 ~]# pcs property list
Cluster Properties:
cluster-delay: 30s
cluster-infrastructure: corosync
cluster-name: mycluster
dc-version: 2.1.6-1.el9
have-watchdog: false
no-quorum-policy: ignore
stonith-enabled: true

风哥针对pcs property命令建议:

  • 生产环境必须启用stonith
  • 双节点集群建议设置no-quorum-policy=ignore
  • 维护时启用maintenance-mode
  • 设置合理的resource-stickiness
  • 定期检查属性配置

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

联系我们

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

微信号:itpux-com

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