ubuntu2004安装corosync和pacemaker并为集群添加浮动IP

简介: ubuntu2004安装corosync和pacemaker并为集群添加浮动IP

环境

节点

IP

storage01

10.141.161.11

storage02

10.141.161.12

安装包(两个节点都要安装)

apt install pacemaker corosync pcs

启用pcsd服务(两个节点都要执行)

systemctl enable --now pcsd

配置hacluster密码(两个节点都要执行)

root@storage01:~# passwd haclusterChanging password for user hacluster.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

组成cluster,仅在其中一个节点上执行即可,因为我是首次添加,增加–force选项,可以避免不少问题

pcs cluster setup cluster storage01 storage02 --force

开启服务,仅在其中一个节点上执行即可

pcs cluster start --all

启用服务,仅在其中一个节点上执行即可

pcs cluster enable --all

查看集群状态,假如跟下述一样,显示有某个节点offline,可以选择等待一下,我这两个节点花了一点时间才同步的

root@storage01:~# pcs cluster statusCluster Status:
 Cluster Summary:
   * Stack: corosync
   * Current DC: storage01 (version 2.0.3-4b1f869f0f) - partition WITHOUT quorum
   * Last updated: Tue Dec 2707:42:45 2022   * Last change:  Tue Dec 2707:40:34 2022 by hacluster via crmd on storage01
   * 2 nodes configured
   * 0 resource instances configured
 Node List:
   * Online: [ storage01 ]
   * OFFLINE: [ storage02 ]
PCSD Status:
  storage01: Online
  storage02: Online

等待一会后,再次查看状态

root@storage01:~# pcs cluster statusCluster Status:
 Cluster Summary:
   * Stack: corosync
   * Current DC: storage02eth (version 2.0.3-4b1f869f0f) - partition with quorum
   * Last updated: Wed Dec 2802:25:19 2022   * Last change:  Wed Dec 2802:25:12 2022 by root via cibadmin on storage01eth
   * 2 nodes configured
   * 1 resource instance configured
 Node List:
   * Online: [ storage01 storage02 ]
PCSD Status:
  storage01: Online
  storage02: Online

我们可以开始添加浮动IP了(网卡名和label加起来不能超过15个字符,否则会报错)

pcs resource create mgmtd_ip ocf:heartbeat:IPaddr2 ip=10.141.161.19 cidr_netmask=32nic=enp183s0f0 iflabel=mgm op monitor interval=30s

查看状态

root@storage01:~# pcs statusCluster name: ha_cluster
WARNINGS:
No stonith devices and stonith-enabled is not falseCluster Summary:
  * Stack: corosync
  * Current DC: storage02eth (version 2.0.3-4b1f869f0f) - partition with quorum
  * Last updated: Wed Dec 2802:24:18 2022  * Last change:  Wed Dec 2802:21:25 2022 by root via cibadmin on storage01eth
  * 2 nodes configured
  * 1 resource instance configured
Node List:
  * Online: [ storage01 storage02 ]
Full List of Resources:
  * mgmtd_ip    (ocf::heartbeat:IPaddr2):        FAILED (Monitoring) [ storage02 storage01 ]
Failed Resource Actions:
  * mgmtd_ip_monitor_0 on storage02eth 'not configured' (6): call=5, status='complete', exitreason='Interface label [enp183s0f0:fl-mgm] exceeds maximum character limit of 15', last-rc-change='2022-12-28 02:21:25Z', queued=0ms, exec=44ms
  * mgmtd_ip_monitor_30000 on storage02eth 'not configured' (6): call=6, status='complete', exitreason='Interface label [enp183s0f0:fl-mgm] exceeds maximum character limit of 15', last-rc-change='2022-12-28 02:21:25Z', queued=0ms, exec=42ms
  * mgmtd_ip_monitor_0 on storage01eth 'not configured' (6): call=5, status='complete', exitreason='Interface label [enp183s0f0:fl-mgm] exceeds maximum character limit of 15', last-rc-change='2022-12-28 02:21:25Z', queued=0ms, exec=40ms
Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled

可能会提示失败,还缺少这一步

pcs property setstonith-enabled=false

重新查看状态

root@storage01:~# pcs statusCluster name: ha_cluster
Cluster Summary:
  * Stack: corosync
  * Current DC: storage02eth (version 2.0.3-4b1f869f0f) - partition with quorum
  * Last updated: Wed Dec 2802:39:45 2022  * Last change:  Wed Dec 2802:39:23 2022 by root via cibadmin on storage01eth
  * 2 nodes configured
  * 1 resource instance configured
Node List:
  * Online: [ storage01 storage02 ]
Full List of Resources:
  * mgmtd_ip    (ocf::heartbeat:IPaddr2):        Started storage01
Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled

接下来查看ip,应该浮动ip就会存在了


目录
相关文章
|
1天前
|
资源调度 JavaScript Ubuntu
Yarn介绍及快速安装Debian/Ubuntu Linux
现在,你已经成功安装了Yarn,可以在你的JavaScript项目中使用它来管理依赖。
14 3
|
1天前
|
Ubuntu
Ubuntu20.04安装SNMP服务
至此,你已经成功在Ubuntu 20.04上安装了SNMP服务。你可以使用SNMP工具来监视和管理你的系统,或者将其集成到网络管理系统中。
8 3
|
5天前
|
Ubuntu 关系型数据库 MySQL
Ubuntu 20.04 + mysql8 安装以及配置大小写不敏感
Ubuntu 20.04 + mysql8 安装以及配置大小写不敏感
|
5天前
|
缓存 Ubuntu 数据库
ubuntu无法使用apt命令时怎么安装库
无论哪种方法,一旦成功安装了所需的库文件,你应该能够在Ubuntu系统上正常使用它们。如果问题仍然存在,可能需要进一步检查系统的包管理配置和依赖关系问题。
19 0
|
6天前
|
Ubuntu Shell 网络安全
【专栏】如何在 Ubuntu 22.04 上安装 KubeSphere?
【4月更文挑战第28天】在Ubuntu 22.04上安装KubeSphere的指南:确保系统至少有4GB内存和2核CPU,安装Docker和docker-compose。下载安装脚本`curl -sSL https://kubesphere.io/install.sh | bash`,根据提示选择安装选项,等待完成。安装后,通过访问控制台验证安装效果。解决可能出现的错误、网络问题和性能问题,利用KubeSphere提升容器管理效率。本文为顺利安装和使用提供参考。
|
8天前
|
Ubuntu Linux 网络安全
|
8天前
|
Ubuntu 关系型数据库 数据库
|
11天前
|
人工智能 Ubuntu Shell
【Ubuntu工具】安装教程:Ubuntu系统上源码编译安装QT5.15.13(有坑)
【Ubuntu工具】安装教程:Ubuntu系统上源码编译安装QT5.15.13(有坑)
30 0
|
11天前
|
人工智能 Ubuntu C语言
【Ubuntu工具】详细图文教程:Ubuntu系统上安装QT6.2
【Ubuntu工具】详细图文教程:Ubuntu系统上安装QT6.2
21 0
|
11天前
|
人工智能 Ubuntu
【Ubuntu工具】踩坑记录:Ubuntu18.04安装FlameShot截图工具及使用方法
【Ubuntu工具】踩坑记录:Ubuntu18.04安装FlameShot截图工具及使用方法
22 0