我是靠谱客的博主 长情毛衣,最近开发中收集的这篇文章主要介绍Pacemaker详解、pcs命令详解和参数说明、centos8或bclinux8.2离线安装pcs以及搭建pcs、pcs的使用说明【2】Pacemaker详解 & pcs命令详解和参数说明环境说明离线搭建集群pcs,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
文章目录
- Pacemaker详解 & pcs命令详解和参数说明
- 环境说明
- 离线搭建集群pcs
- 添加解析
- 添加免密登录
- 离线包准备【2个主机同步】
- 安装pcs并启动服务【2个主机同步】
- 创建集群用户和密码【2个主机同步操作】
- 验证pcs运行,两个节点的用户注册到集群
- 配置集群名称mycluster和启动集群
- 状态检查及验证
- 检查集群配置的有效性
- 检查集群报错(unpack_resources) error...处理
- 在node1恢复后,为防止node2资源迁回node01(迁来迁去对还是会对业务有一定影响)
- 设置资源超时时间
- 执行命令修改如下2个内核参数 (需要root权限)
- 验证,正常无回显
- 启用nonlocal 绑定内核参数【两台主机均需要操作】
- 绑定vip
- 绑定chronyd服务
- 验证vip和自动迁移
- vip验证
- 自动迁移验证
Pacemaker详解 & pcs命令详解和参数说明
- 内容太多,放一起太卡,所以Pacemaker详解 & pcs命令详解和参数说明放到下面这篇文章中
【下面参数或使用更多方法都可以见这篇文章】
Pacemaker详解、pcs命令详解和参数说明、centos8或bclinux8.2离线安装pcs以及搭建pcs、pcs的使用说明
环境说明
- 简单来说,pcs命令就是创建VIP集群用的。给2台主机绑定一个vip。
今天说的是离线安装,系统是bclinux8.2,【内核是4.19,理论centos8以上的系统通用这种方法】 - 主机1
[root@xz-sj-dmz-1 ~]# cat /etc/redhat-release
BigCloud Enterprise Linux release 8.2.2107 (Core)
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]# uname -a
Linux xz-sj-dmz-1.novalocal 4.19.0-240.23.11.el8_2.bclinux.x86_64 #1 SMP Wed Jun 2 16:11:31 CST 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]# ip a | grep 10.241.
inet 1.2.3.84/24 brd 1.2.3.255 scope global dynamic noprefixroute ens3
[root@xz-sj-dmz-1 ~]#
- 主机2
[root@xz-sj-dmz-2 ~]# cat /etc/redhat-release
BigCloud Enterprise Linux release 8.2.2107 (Core)
[root@xz-sj-dmz-2 ~]# uname -a
Linux xz-sj-dmz-2.novalocal 4.19.0-240.23.11.el8_2.bclinux.x86_64 #1 SMP Wed Jun 2 16:11:31 CST 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]# ip a | grep 10.241.
inet 1.2.3.87/24 brd 1.2.3.255 scope global dynamic noprefixroute ens3
[root@xz-sj-dmz-2 ~]#
离线搭建集群pcs
搭建不难pcs,难的是找包。
添加解析
- 添加2个主机的解析和vip的解析【vip的主机名是自定义的】
- 主机1
[root@xz-sj-dmz-1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
1.2.3.84 xz-sj-dmz-1
1.2.3.87 xz-sj-dmz-2
1.2.3.79 timevip
[root@xz-sj-dmz-1 ~]#
- 主机2
[root@xz-sj-dmz-2 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
1.2.3.84 xz-sj-dmz-1
1.2.3.87 xz-sj-dmz-2
1.2.3.79 timevip
[root@xz-sj-dmz-2 ~]#
添加免密登录
- 主机1和主机2之间是创建了免密登录的,已经操作过了,页面没了就不放命令过程了。
如果不会的翻下我笔记,有说如何创建ssh免密登录。【不做这个操作可能也行,只是下面操作的2台主机我做了免密登录】
离线包准备【2个主机同步】
-
包名,我下面已经放出来了,如果不想折腾的,可以直接下载我准备的包,下载地址如下:rpms-chrony-pcs-packages.rpm.rar
【下面其实就是在有外网的情况下汇总了corosync pacemaker pcs fence-agents resource-agents
这些包放在一个文件夹拷贝到内网环境,用dnf来安装的(centos7的版本也可以到有公网的机子上汇总拷贝到内网服务器上用rpm安装,下面用的是dnf,其实也可以用rpm来安装,注:如果用rpm安装,命令最好分开存放到文件夹,分别用rpm安装)】 -
主机1
[root@xz-sj-dmz-1 ~]# ls
Agent-Core-RedHat_EL8-20.0.0-1620.x86_64.rpm anaconda-ks.cfg chronyrpms resolv.conf
[root@xz-sj-dmz-1 ~]# cd chronyrpms/
[root@xz-sj-dmz-1 chronyrpms]# ls
Agent-Core-RedHat_EL8-20.0.0-1620.x86_64.rpm libknet1-1.10-6.el8_2.x86_64.rpm nss-3.53.1-12.an8_2.x86_64.rpm python3-lxml-4.2.3-1.el8.x86_64.rpm
avahi-libs-0.7-19.el8.x86_64.rpm libknet1-compress-bzip2-plugin-1.10-6.el8_2.x86_64.rpm nss-softokn-3.53.1-12.an8_2.x86_64.rpm python3-pyOpenSSL-18.0.0-1.el8.noarch.rpm
bclinux-logos-80.5-2.el8.bclinux.x86_64.rpm libknet1-compress-lz4-plugin-1.10-6.el8_2.x86_64.rpm nss-softokn-freebl-3.53.1-12.an8_2.x86_64.rpm python3-pycparser-2.14-14.el8.noarch.rpm
chrony-3.5-1.0.1.an8.x86_64.rpm libknet1-compress-lzma-plugin-1.10-6.el8_2.x86_64.rpm nss-sysinit-3.53.1-12.an8_2.x86_64.rpm python3-pycurl-7.43.0.2-4.el8.x86_64.rpm
cifs-utils-6.8-3.el8.x86_64.rpm libknet1-compress-lzo2-plugin-1.10-6.el8_2.x86_64.rpm nss-util-3.53.1-12.an8_2.x86_64.rpm repodata
clufter-bin-0.77.1-5.el8.x86_64.rpm libknet1-compress-plugins-all-1.10-6.el8_2.x86_64.rpm overpass-fonts-3.0.2-3.el8.noarch.rpm resource-agents-4.1.1-44.el8_2.bclinux.6.x86_64.rpm
clufter-common-0.77.1-5.el8.noarch.rpm libknet1-compress-zlib-plugin-1.10-6.el8_2.x86_64.rpm pacemaker-2.0.3-5.el8_2.bclinux.1.x86_64.rpm rpcbind-1.2.5-7.el8.x86_64.rpm
corosync-3.0.3-2.el8_2.bclinux.x86_64.rpm libknet1-crypto-nss-plugin-1.10-6.el8_2.x86_64.rpm pacemaker-cli-2.0.3-5.el8_2.bclinux.1.x86_64.rpm ruby-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64.rpm
corosynclib-3.0.3-2.el8_2.bclinux.x86_64.rpm libknet1-crypto-openssl-plugin-1.10-6.el8_2.x86_64.rpm pacemaker-cluster-libs-2.0.3-5.el8_2.bclinux.1.x86_64.rpm ruby-libs-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64.rpm
createrepo_c-0.15.1-2.el8.x86_64.rpm libknet1-crypto-plugins-all-1.10-6.el8_2.x86_64.rpm pacemaker-libs-2.0.3-5.el8_2.bclinux.1.x86_64.rpm rubygem-openssl-2.1.2-105.module+el8.2.0+10145+e54e5e18.x86_64.rpm
createrepo_c-libs-0.15.1-2.el8.x86_64.rpm libknet1-plugins-all-1.10-6.el8_2.x86_64.rpm pacemaker-schemas-2.0.3-5.el8_2.bclinux.1.noarch.rpm rubygem-psych-3.0.2-105.module+el8.2.0+10145+e54e5e18.x86_64.rpm
cups-libs-2.2.6-33.el8_2.1.x86_64.rpm libnozzle1-1.10-6.el8_2.x86_64.rpm pcs-0.10.4-6.el8_2.bclinux.1.x86_64.rpm rubygems-2.7.6.2-105.module+el8.2.0+10145+e54e5e18.noarch.rpm
drpm-0.4.1-1.el8.x86_64.rpm libqb-1.0.3-10.el8.x86_64.rpm perl-TimeDate-2.30-15.module+el8.2.0+10201+66fd290b.noarch.rpm samba-client-libs-4.11.2-15.an8.x86_64.rpm
fontpackages-filesystem-1.44-22.el8.noarch.rpm libverto-libevent-0.3.0-5.el8.x86_64.rpm psmisc-23.1-4.el8.x86_64.rpm samba-common-4.11.2-15.an8.noarch.rpm
gssproxy-0.8.0-15.el8.x86_64.rpm libwbclient-4.11.2-15.an8.x86_64.rpm python3-asn1crypto-0.24.0-3.el8.noarch.rpm samba-common-libs-4.11.2-15.an8.x86_64.rpm
haproxy-1.8.23-3.el8.x86_64.rpm libxslt-1.1.32-4.0.1.an8.x86_64.rpm python3-cffi-1.11.5-5.0.1.an8.x86_64.rpm telnet-0.17-73.el8.x86_64.rpm
keyutils-1.5.10-6.el8.x86_64.rpm net-snmp-libs-5.8-14.el8.3.x86_64.rpm python3-clufter-0.77.1-5.el8.noarch.rpm
liberation-fonts-common-2.00.3-7.el8.noarch.rpm nfs-utils-2.3.3-31.el8.x86_64.rpm python3-cryptography-2.3-3.el8.x86_64.rpm
liberation-sans-fonts-2.00.3-7.el8.noarch.rpm nspr-4.25.0-2.el8.x86_64.rpm python3-idna-2.5-5.el8.noarch.rpm
[root@xz-sj-dmz-1 chronyrpms]#
- 主机2
[root@xz-sj-dmz-2 ~]# ls
Agent-Core-RedHat_EL8-20.0.0-1620.x86_64.rpm anaconda-ks.cfg chronyrpms resolv.conf
[root@xz-sj-dmz-2 ~]# cd chronyrpms/
[root@xz-sj-dmz-2 chronyrpms]# ls
Agent-Core-RedHat_EL8-20.0.0-1620.x86_64.rpm libknet1-1.10-6.el8_2.x86_64.rpm nss-3.53.1-12.an8_2.x86_64.rpm python3-lxml-4.2.3-1.el8.x86_64.rpm
avahi-libs-0.7-19.el8.x86_64.rpm libknet1-compress-bzip2-plugin-1.10-6.el8_2.x86_64.rpm nss-softokn-3.53.1-12.an8_2.x86_64.rpm python3-pyOpenSSL-18.0.0-1.el8.noarch.rpm
bclinux-logos-80.5-2.el8.bclinux.x86_64.rpm libknet1-compress-lz4-plugin-1.10-6.el8_2.x86_64.rpm nss-softokn-freebl-3.53.1-12.an8_2.x86_64.rpm python3-pycparser-2.14-14.el8.noarch.rpm
chrony-3.5-1.0.1.an8.x86_64.rpm libknet1-compress-lzma-plugin-1.10-6.el8_2.x86_64.rpm nss-sysinit-3.53.1-12.an8_2.x86_64.rpm python3-pycurl-7.43.0.2-4.el8.x86_64.rpm
cifs-utils-6.8-3.el8.x86_64.rpm libknet1-compress-lzo2-plugin-1.10-6.el8_2.x86_64.rpm nss-util-3.53.1-12.an8_2.x86_64.rpm repodata
clufter-bin-0.77.1-5.el8.x86_64.rpm libknet1-compress-plugins-all-1.10-6.el8_2.x86_64.rpm overpass-fonts-3.0.2-3.el8.noarch.rpm resource-agents-4.1.1-44.el8_2.bclinux.6.x86_64.rpm
clufter-common-0.77.1-5.el8.noarch.rpm libknet1-compress-zlib-plugin-1.10-6.el8_2.x86_64.rpm pacemaker-2.0.3-5.el8_2.bclinux.1.x86_64.rpm rpcbind-1.2.5-7.el8.x86_64.rpm
corosync-3.0.3-2.el8_2.bclinux.x86_64.rpm libknet1-crypto-nss-plugin-1.10-6.el8_2.x86_64.rpm pacemaker-cli-2.0.3-5.el8_2.bclinux.1.x86_64.rpm ruby-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64.rpm
corosynclib-3.0.3-2.el8_2.bclinux.x86_64.rpm libknet1-crypto-openssl-plugin-1.10-6.el8_2.x86_64.rpm pacemaker-cluster-libs-2.0.3-5.el8_2.bclinux.1.x86_64.rpm ruby-libs-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64.rpm
createrepo_c-0.15.1-2.el8.x86_64.rpm libknet1-crypto-plugins-all-1.10-6.el8_2.x86_64.rpm pacemaker-libs-2.0.3-5.el8_2.bclinux.1.x86_64.rpm rubygem-openssl-2.1.2-105.module+el8.2.0+10145+e54e5e18.x86_64.rpm
createrepo_c-libs-0.15.1-2.el8.x86_64.rpm libknet1-plugins-all-1.10-6.el8_2.x86_64.rpm pacemaker-schemas-2.0.3-5.el8_2.bclinux.1.noarch.rpm rubygem-psych-3.0.2-105.module+el8.2.0+10145+e54e5e18.x86_64.rpm
cups-libs-2.2.6-33.el8_2.1.x86_64.rpm libnozzle1-1.10-6.el8_2.x86_64.rpm pcs-0.10.4-6.el8_2.bclinux.1.x86_64.rpm rubygems-2.7.6.2-105.module+el8.2.0+10145+e54e5e18.noarch.rpm
drpm-0.4.1-1.el8.x86_64.rpm libqb-1.0.3-10.el8.x86_64.rpm perl-TimeDate-2.30-15.module+el8.2.0+10201+66fd290b.noarch.rpm samba-client-libs-4.11.2-15.an8.x86_64.rpm
fontpackages-filesystem-1.44-22.el8.noarch.rpm libverto-libevent-0.3.0-5.el8.x86_64.rpm psmisc-23.1-4.el8.x86_64.rpm samba-common-4.11.2-15.an8.noarch.rpm
gssproxy-0.8.0-15.el8.x86_64.rpm libwbclient-4.11.2-15.an8.x86_64.rpm python3-asn1crypto-0.24.0-3.el8.noarch.rpm samba-common-libs-4.11.2-15.an8.x86_64.rpm
haproxy-1.8.23-3.el8.x86_64.rpm libxslt-1.1.32-4.0.1.an8.x86_64.rpm python3-cffi-1.11.5-5.0.1.an8.x86_64.rpm telnet-0.17-73.el8.x86_64.rpm
keyutils-1.5.10-6.el8.x86_64.rpm net-snmp-libs-5.8-14.el8.3.x86_64.rpm python3-clufter-0.77.1-5.el8.noarch.rpm
liberation-fonts-common-2.00.3-7.el8.noarch.rpm nfs-utils-2.3.3-31.el8.x86_64.rpm python3-cryptography-2.3-3.el8.x86_64.rpm
liberation-sans-fonts-2.00.3-7.el8.noarch.rpm nspr-4.25.0-2.el8.x86_64.rpm python3-idna-2.5-5.el8.noarch.rpm
[root@xz-sj-dmz-2 chronyrpms]#
安装pcs并启动服务【2个主机同步】
- 下面只展示一个主机安装过程
在rpm包路径下执行dnf install ./*.rpm
然后提示输入y
回车即可
[root@xz-sj-dmz-2 chronyrpms]# pwd
/root/chronyrpms
[root@xz-sj-dmz-2 chronyrpms]# dnf install ./*.rpm
Failed to set locale, defaulting to C.UTF-8
^CUnable to connect to Registration Management Service
Last metadata expiration check: 1:53:57 ago on Wed Feb 8 10:49:14 2023.
Package ds_agent-20.0.0-1620.el8.x86_64 is already installed.
Package python3-asn1crypto-0.24.0-3.el8.noarch is already installed.
Package python3-cffi-1.11.5-5.0.1.an8.x86_64 is already installed.
Package python3-cryptography-2.3-3.el8.x86_64 is already installed.
Package python3-idna-2.5-5.el8.noarch is already installed.
Package python3-pycparser-2.14-14.el8.noarch is already installed.
Dependencies resolved.
==============================================================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
avahi-libs x86_64 0.7-19.el8 @commandline 60 k
bclinux-logos x86_64 80.5-2.el8.bclinux @commandline 1.8 M
cifs-utils x86_64 6.8-3.el8 @commandline 94 k
clufter-bin x86_64 0.77.1-5.el8 @commandline 33 k
clufter-common noarch 0.77.1-5.el8 @commandline 81 k
corosync x86_64 3.0.3-2.el8_2.bclinux @commandline 262 k
corosynclib x86_64 3.0.3-2.el8_2.bclinux @commandline 65 k
createrepo_c x86_64 0.15.1-2.el8 @commandline 81 k
createrepo_c-libs x86_64 0.15.1-2.el8 @commandline 109 k
cups-libs x86_64 1:2.2.6-33.el8_2.1 @commandline 331 k
drpm x86_64 0.4.1-1.el8 @commandline 65 k
fontpackages-filesystem noarch 1.44-22.el8 @commandline 14 k
gssproxy x86_64 0.8.0-15.el8 @commandline 116 k
haproxy x86_64 1.8.23-3.el8 @commandline 1.3 M
keyutils x86_64 1.5.10-6.el8 @commandline 62 k
liberation-fonts-common noarch 1:2.00.3-7.el8 @commandline 24 k
liberation-sans-fonts noarch 1:2.00.3-7.el8 @commandline 608 k
libknet1 x86_64 1.10-6.el8_2 @commandline 75 k
libknet1-compress-bzip2-plugin x86_64 1.10-6.el8_2 @commandline 14 k
libknet1-compress-lz4-plugin x86_64 1.10-6.el8_2 @commandline 16 k
libknet1-compress-lzma-plugin x86_64 1.10-6.el8_2 @commandline 14 k
libknet1-compress-lzo2-plugin x86_64 1.10-6.el8_2 @commandline 15 k
libknet1-compress-plugins-all x86_64 1.10-6.el8_2 @commandline 10 k
libknet1-compress-zlib-plugin x86_64 1.10-6.el8_2 @commandline 14 k
libknet1-crypto-nss-plugin x86_64 1.10-6.el8_2 @commandline 19 k
libknet1-crypto-openssl-plugin x86_64 1.10-6.el8_2 @commandline 17 k
libknet1-crypto-plugins-all x86_64 1.10-6.el8_2 @commandline 10 k
libknet1-plugins-all x86_64 1.10-6.el8_2 @commandline 10 k
libnozzle1 x86_64 1.10-6.el8_2 @commandline 32 k
libqb x86_64 1.0.3-10.el8 @commandline 111 k
libverto-libevent x86_64 0.3.0-5.el8 @commandline 14 k
libwbclient x86_64 4.11.2-15.an8 @commandline 115 k
libxslt x86_64 1.1.32-4.0.1.an8 @commandline 248 k
net-snmp-libs x86_64 1:5.8-14.el8.3 @commandline 820 k
nfs-utils x86_64 1:2.3.3-31.el8 @commandline 466 k
nspr x86_64 4.25.0-2.el8 @commandline 140 k
nss x86_64 3.53.1-12.an8_2 @commandline 720 k
nss-softokn x86_64 3.53.1-12.an8_2 @commandline 482 k
nss-softokn-freebl x86_64 3.53.1-12.an8_2 @commandline 288 k
nss-sysinit x86_64 3.53.1-12.an8_2 @commandline 70 k
nss-util x86_64 3.53.1-12.an8_2 @commandline 133 k
overpass-fonts noarch 3.0.2-3.el8 @commandline 1.1 M
pacemaker x86_64 2.0.3-5.el8_2.bclinux.1 @commandline 434 k
pacemaker-cli x86_64 2.0.3-5.el8_2.bclinux.1 @commandline 327 k
pacemaker-cluster-libs x86_64 2.0.3-5.el8_2.bclinux.1 @commandline 124 k
pacemaker-libs x86_64 2.0.3-5.el8_2.bclinux.1 @commandline 648 k
pacemaker-schemas noarch 2.0.3-5.el8_2.bclinux.1 @commandline 65 k
pcs x86_64 0.10.4-6.el8_2.bclinux.1 @commandline 12 M
perl-TimeDate noarch 1:2.30-15.module+el8.2.0+10201+66fd290b @commandline 52 k
psmisc x86_64 23.1-4.el8 @commandline 149 k
python3-clufter noarch 0.77.1-5.el8 @commandline 346 k
python3-lxml x86_64 4.2.3-1.el8 @commandline 1.5 M
python3-pyOpenSSL noarch 18.0.0-1.el8 @commandline 101 k
python3-pycurl x86_64 7.43.0.2-4.el8 @commandline 226 k
resource-agents x86_64 4.1.1-44.el8_2.bclinux.6 @commandline 460 k
rpcbind x86_64 1.2.5-7.el8 @commandline 68 k
ruby x86_64 2.5.5-105.module+el8.2.0+10145+e54e5e18 @commandline 85 k
ruby-libs x86_64 2.5.5-105.module+el8.2.0+10145+e54e5e18 @commandline 2.9 M
rubygem-openssl x86_64 2.1.2-105.module+el8.2.0+10145+e54e5e18 @commandline 187 k
rubygem-psych x86_64 3.0.2-105.module+el8.2.0+10145+e54e5e18 @commandline 93 k
rubygems noarch 2.7.6.2-105.module+el8.2.0+10145+e54e5e18 @commandline 306 k
samba-client-libs x86_64 4.11.2-15.an8 @commandline 5.1 M
samba-common noarch 4.11.2-15.an8 @commandline 211 k
samba-common-libs x86_64 4.11.2-15.an8 @commandline 172 k
telnet x86_64 1:0.17-73.el8 @commandline 70 k
Upgrading:
chrony x86_64 3.5-1.0.1.an8 @commandline 268 k
Transaction Summary
==============================================================================================================================================================================================================================================================================
Install 65 Packages
Upgrade 1 Package
Total size: 36 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: libknet1-1.10-6.el8_2.x86_64 1/1
Installing : libknet1-1.10-6.el8_2.x86_64 1/67
Installing : nspr-4.25.0-2.el8.x86_64 2/67
Running scriptlet: nspr-4.25.0-2.el8.x86_64 2/67
Installing : libxslt-1.1.32-4.0.1.an8.x86_64 3/67
Installing : libqb-1.0.3-10.el8.x86_64 4/67
Running scriptlet: libqb-1.0.3-10.el8.x86_64 4/67
Installing : nss-util-3.53.1-12.an8_2.x86_64 5/67
Installing : ruby-libs-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64 6/67
Installing : corosynclib-3.0.3-2.el8_2.bclinux.x86_64 7/67
Running scriptlet: corosynclib-3.0.3-2.el8_2.bclinux.x86_64 7/67
Installing : psmisc-23.1-4.el8.x86_64 8/67
Installing : rubygem-openssl-2.1.2-105.module+el8.2.0+10145+e54e5e18.x86_64 9/67
Installing : rubygem-psych-3.0.2-105.module+el8.2.0+10145+e54e5e18.x86_64 10/67
Installing : rubygems-2.7.6.2-105.module+el8.2.0+10145+e54e5e18.noarch 11/67
Installing : ruby-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64 12/67
Installing : python3-lxml-4.2.3-1.el8.x86_64 13/67
Running scriptlet: samba-common-4.11.2-15.an8.noarch 14/67
Installing : samba-common-4.11.2-15.an8.noarch 14/67
Running scriptlet: samba-common-4.11.2-15.an8.noarch 14/67
Installing : keyutils-1.5.10-6.el8.x86_64 15/67
Installing : fontpackages-filesystem-1.44-22.el8.noarch 16/67
Installing : drpm-0.4.1-1.el8.x86_64 17/67
Installing : avahi-libs-0.7-19.el8.x86_64 18/67
Installing : cups-libs-1:2.2.6-33.el8_2.1.x86_64 19/67
Installing : libwbclient-4.11.2-15.an8.x86_64 20/67
Installing : samba-common-libs-4.11.2-15.an8.x86_64 21/67
Installing : samba-client-libs-4.11.2-15.an8.x86_64 22/67
Installing : cifs-utils-6.8-3.el8.x86_64 23/67
Running scriptlet: cifs-utils-6.8-3.el8.x86_64 23/67
Installing : createrepo_c-libs-0.15.1-2.el8.x86_64 24/67
Installing : liberation-fonts-common-1:2.00.3-7.el8.noarch 25/67
Installing : liberation-sans-fonts-1:2.00.3-7.el8.noarch 26/67
Installing : overpass-fonts-3.0.2-3.el8.noarch 27/67
Installing : nss-softokn-freebl-3.53.1-12.an8_2.x86_64 28/67
Installing : nss-softokn-3.53.1-12.an8_2.x86_64 29/67
Installing : nss-3.53.1-12.an8_2.x86_64 30/67
Installing : nss-sysinit-3.53.1-12.an8_2.x86_64 31/67
Installing : libknet1-crypto-nss-plugin-1.10-6.el8_2.x86_64 32/67
Installing : libknet1-compress-bzip2-plugin-1.10-6.el8_2.x86_64 33/67
Installing : libknet1-compress-lz4-plugin-1.10-6.el8_2.x86_64 34/67
Installing : libknet1-compress-lzma-plugin-1.10-6.el8_2.x86_64 35/67
Installing : libknet1-compress-lzo2-plugin-1.10-6.el8_2.x86_64 36/67
Installing : libknet1-compress-zlib-plugin-1.10-6.el8_2.x86_64 37/67
Installing : libknet1-compress-plugins-all-1.10-6.el8_2.x86_64 38/67
Installing : libknet1-crypto-openssl-plugin-1.10-6.el8_2.x86_64 39/67
Installing : libknet1-crypto-plugins-all-1.10-6.el8_2.x86_64 40/67
Installing : libknet1-plugins-all-1.10-6.el8_2.x86_64 41/67
Running scriptlet: rpcbind-1.2.5-7.el8.x86_64 42/67
Installing : rpcbind-1.2.5-7.el8.x86_64 42/67
Running scriptlet: rpcbind-1.2.5-7.el8.x86_64 42/67
Installing : python3-pycurl-7.43.0.2-4.el8.x86_64 43/67
Installing : python3-pyOpenSSL-18.0.0-1.el8.noarch 44/67
Installing : perl-TimeDate-1:2.30-15.module+el8.2.0+10201+66fd290b.noarch 45/67
Installing : pacemaker-schemas-2.0.3-5.el8_2.bclinux.1.noarch 46/67
Running scriptlet: pacemaker-libs-2.0.3-5.el8_2.bclinux.1.x86_64 47/67
Installing : pacemaker-libs-2.0.3-5.el8_2.bclinux.1.x86_64 47/67
Installing : pacemaker-cli-2.0.3-5.el8_2.bclinux.1.x86_64 48/67
Running scriptlet: pacemaker-cli-2.0.3-5.el8_2.bclinux.1.x86_64 48/67
Installing : pacemaker-cluster-libs-2.0.3-5.el8_2.bclinux.1.x86_64 49/67
Installing : net-snmp-libs-1:5.8-14.el8.3.x86_64 50/67
Installing : libverto-libevent-0.3.0-5.el8.x86_64 51/67
Installing : gssproxy-0.8.0-15.el8.x86_64 52/67
Running scriptlet: gssproxy-0.8.0-15.el8.x86_64 52/67
Running scriptlet: nfs-utils-1:2.3.3-31.el8.x86_64 53/67
Installing : nfs-utils-1:2.3.3-31.el8.x86_64 53/67
Running scriptlet: nfs-utils-1:2.3.3-31.el8.x86_64 53/67
Installing : resource-agents-4.1.1-44.el8_2.bclinux.6.x86_64 54/67
Installing : libnozzle1-1.10-6.el8_2.x86_64 55/67
Installing : corosync-3.0.3-2.el8_2.bclinux.x86_64 56/67
Running scriptlet: corosync-3.0.3-2.el8_2.bclinux.x86_64 56/67
Installing : pacemaker-2.0.3-5.el8_2.bclinux.1.x86_64 57/67
Running scriptlet: pacemaker-2.0.3-5.el8_2.bclinux.1.x86_64 57/67
Installing : clufter-common-0.77.1-5.el8.noarch 58/67
Installing : clufter-bin-0.77.1-5.el8.x86_64 59/67
Installing : python3-clufter-0.77.1-5.el8.noarch 60/67
Installing : bclinux-logos-80.5-2.el8.bclinux.x86_64 61/67
Running scriptlet: bclinux-logos-80.5-2.el8.bclinux.x86_64 61/67
Installing : pcs-0.10.4-6.el8_2.bclinux.1.x86_64 62/67
Running scriptlet: pcs-0.10.4-6.el8_2.bclinux.1.x86_64 62/67
Installing : createrepo_c-0.15.1-2.el8.x86_64 63/67
Running scriptlet: chrony-3.5-1.0.1.an8.x86_64 64/67
Upgrading : chrony-3.5-1.0.1.an8.x86_64 64/67
warning: /etc/chrony.conf created as /etc/chrony.conf.rpmnew
Running scriptlet: chrony-3.5-1.0.1.an8.x86_64 64/67
Installing : telnet-1:0.17-73.el8.x86_64 65/67
Running scriptlet: haproxy-1.8.23-3.el8.x86_64 66/67
Installing : haproxy-1.8.23-3.el8.x86_64 66/67
Running scriptlet: haproxy-1.8.23-3.el8.x86_64 66/67
Running scriptlet: chrony-3.5-1.el8.x86_64 67/67
Cleanup : chrony-3.5-1.el8.x86_64 67/67
Running scriptlet: chrony-3.5-1.el8.x86_64 67/67
Running scriptlet: libwbclient-4.11.2-15.an8.x86_64 67/67
Running scriptlet: nss-3.53.1-12.an8_2.x86_64 67/67
Running scriptlet: bclinux-logos-80.5-2.el8.bclinux.x86_64 67/67
Running scriptlet: pcs-0.10.4-6.el8_2.bclinux.1.x86_64 67/67
Running scriptlet: chrony-3.5-1.el8.x86_64 67/67
Verifying : avahi-libs-0.7-19.el8.x86_64 1/67
Verifying : bclinux-logos-80.5-2.el8.bclinux.x86_64 2/67
Verifying : cifs-utils-6.8-3.el8.x86_64 3/67
Verifying : clufter-bin-0.77.1-5.el8.x86_64 4/67
Verifying : clufter-common-0.77.1-5.el8.noarch 5/67
Verifying : corosync-3.0.3-2.el8_2.bclinux.x86_64 6/67
Verifying : corosynclib-3.0.3-2.el8_2.bclinux.x86_64 7/67
Verifying : createrepo_c-0.15.1-2.el8.x86_64 8/67
Verifying : createrepo_c-libs-0.15.1-2.el8.x86_64 9/67
Verifying : cups-libs-1:2.2.6-33.el8_2.1.x86_64 10/67
Verifying : drpm-0.4.1-1.el8.x86_64 11/67
Verifying : fontpackages-filesystem-1.44-22.el8.noarch 12/67
Verifying : gssproxy-0.8.0-15.el8.x86_64 13/67
Verifying : haproxy-1.8.23-3.el8.x86_64 14/67
Verifying : keyutils-1.5.10-6.el8.x86_64 15/67
Verifying : liberation-fonts-common-1:2.00.3-7.el8.noarch 16/67
Verifying : liberation-sans-fonts-1:2.00.3-7.el8.noarch 17/67
Verifying : libknet1-1.10-6.el8_2.x86_64 18/67
Verifying : libknet1-compress-bzip2-plugin-1.10-6.el8_2.x86_64 19/67
Verifying : libknet1-compress-lz4-plugin-1.10-6.el8_2.x86_64 20/67
Verifying : libknet1-compress-lzma-plugin-1.10-6.el8_2.x86_64 21/67
Verifying : libknet1-compress-lzo2-plugin-1.10-6.el8_2.x86_64 22/67
Verifying : libknet1-compress-plugins-all-1.10-6.el8_2.x86_64 23/67
Verifying : libknet1-compress-zlib-plugin-1.10-6.el8_2.x86_64 24/67
Verifying : libknet1-crypto-nss-plugin-1.10-6.el8_2.x86_64 25/67
Verifying : libknet1-crypto-openssl-plugin-1.10-6.el8_2.x86_64 26/67
Verifying : libknet1-crypto-plugins-all-1.10-6.el8_2.x86_64 27/67
Verifying : libknet1-plugins-all-1.10-6.el8_2.x86_64 28/67
Verifying : libnozzle1-1.10-6.el8_2.x86_64 29/67
Verifying : libqb-1.0.3-10.el8.x86_64 30/67
Verifying : libverto-libevent-0.3.0-5.el8.x86_64 31/67
Verifying : libwbclient-4.11.2-15.an8.x86_64 32/67
Verifying : libxslt-1.1.32-4.0.1.an8.x86_64 33/67
Verifying : net-snmp-libs-1:5.8-14.el8.3.x86_64 34/67
Verifying : nfs-utils-1:2.3.3-31.el8.x86_64 35/67
Verifying : nspr-4.25.0-2.el8.x86_64 36/67
Verifying : nss-3.53.1-12.an8_2.x86_64 37/67
Verifying : nss-softokn-3.53.1-12.an8_2.x86_64 38/67
Verifying : nss-softokn-freebl-3.53.1-12.an8_2.x86_64 39/67
Verifying : nss-sysinit-3.53.1-12.an8_2.x86_64 40/67
Verifying : nss-util-3.53.1-12.an8_2.x86_64 41/67
Verifying : overpass-fonts-3.0.2-3.el8.noarch 42/67
Verifying : pacemaker-2.0.3-5.el8_2.bclinux.1.x86_64 43/67
Verifying : pacemaker-cli-2.0.3-5.el8_2.bclinux.1.x86_64 44/67
Verifying : pacemaker-cluster-libs-2.0.3-5.el8_2.bclinux.1.x86_64 45/67
Verifying : pacemaker-libs-2.0.3-5.el8_2.bclinux.1.x86_64 46/67
Verifying : pacemaker-schemas-2.0.3-5.el8_2.bclinux.1.noarch 47/67
Verifying : pcs-0.10.4-6.el8_2.bclinux.1.x86_64 48/67
Verifying : perl-TimeDate-1:2.30-15.module+el8.2.0+10201+66fd290b.noarch 49/67
Verifying : psmisc-23.1-4.el8.x86_64 50/67
Verifying : python3-clufter-0.77.1-5.el8.noarch 51/67
Verifying : python3-lxml-4.2.3-1.el8.x86_64 52/67
Verifying : python3-pyOpenSSL-18.0.0-1.el8.noarch 53/67
Verifying : python3-pycurl-7.43.0.2-4.el8.x86_64 54/67
Verifying : resource-agents-4.1.1-44.el8_2.bclinux.6.x86_64 55/67
Verifying : rpcbind-1.2.5-7.el8.x86_64 56/67
Verifying : ruby-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64 57/67
Verifying : ruby-libs-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64 58/67
Verifying : rubygem-openssl-2.1.2-105.module+el8.2.0+10145+e54e5e18.x86_64 59/67
Verifying : rubygem-psych-3.0.2-105.module+el8.2.0+10145+e54e5e18.x86_64 60/67
Verifying : rubygems-2.7.6.2-105.module+el8.2.0+10145+e54e5e18.noarch 61/67
Verifying : samba-client-libs-4.11.2-15.an8.x86_64 62/67
Verifying : samba-common-4.11.2-15.an8.noarch 63/67
Verifying : samba-common-libs-4.11.2-15.an8.x86_64 64/67
Verifying : telnet-1:0.17-73.el8.x86_64 65/67
Verifying : chrony-3.5-1.0.1.an8.x86_64 66/67
Verifying : chrony-3.5-1.el8.x86_64 67/67
Upgraded:
chrony-3.5-1.0.1.an8.x86_64
Installed:
avahi-libs-0.7-19.el8.x86_64 bclinux-logos-80.5-2.el8.bclinux.x86_64 cifs-utils-6.8-3.el8.x86_64 clufter-bin-0.77.1-5.el8.x86_64
clufter-common-0.77.1-5.el8.noarch corosync-3.0.3-2.el8_2.bclinux.x86_64 corosynclib-3.0.3-2.el8_2.bclinux.x86_64 createrepo_c-0.15.1-2.el8.x86_64
createrepo_c-libs-0.15.1-2.el8.x86_64 cups-libs-1:2.2.6-33.el8_2.1.x86_64 drpm-0.4.1-1.el8.x86_64 fontpackages-filesystem-1.44-22.el8.noarch
gssproxy-0.8.0-15.el8.x86_64 haproxy-1.8.23-3.el8.x86_64 keyutils-1.5.10-6.el8.x86_64 liberation-fonts-common-1:2.00.3-7.el8.noarch
liberation-sans-fonts-1:2.00.3-7.el8.noarch libknet1-1.10-6.el8_2.x86_64 libknet1-compress-bzip2-plugin-1.10-6.el8_2.x86_64 libknet1-compress-lz4-plugin-1.10-6.el8_2.x86_64
libknet1-compress-lzma-plugin-1.10-6.el8_2.x86_64 libknet1-compress-lzo2-plugin-1.10-6.el8_2.x86_64 libknet1-compress-plugins-all-1.10-6.el8_2.x86_64 libknet1-compress-zlib-plugin-1.10-6.el8_2.x86_64
libknet1-crypto-nss-plugin-1.10-6.el8_2.x86_64 libknet1-crypto-openssl-plugin-1.10-6.el8_2.x86_64 libknet1-crypto-plugins-all-1.10-6.el8_2.x86_64 libknet1-plugins-all-1.10-6.el8_2.x86_64
libnozzle1-1.10-6.el8_2.x86_64 libqb-1.0.3-10.el8.x86_64 libverto-libevent-0.3.0-5.el8.x86_64 libwbclient-4.11.2-15.an8.x86_64
libxslt-1.1.32-4.0.1.an8.x86_64 net-snmp-libs-1:5.8-14.el8.3.x86_64 nfs-utils-1:2.3.3-31.el8.x86_64 nspr-4.25.0-2.el8.x86_64
nss-3.53.1-12.an8_2.x86_64 nss-softokn-3.53.1-12.an8_2.x86_64 nss-softokn-freebl-3.53.1-12.an8_2.x86_64 nss-sysinit-3.53.1-12.an8_2.x86_64
nss-util-3.53.1-12.an8_2.x86_64 overpass-fonts-3.0.2-3.el8.noarch pacemaker-2.0.3-5.el8_2.bclinux.1.x86_64 pacemaker-cli-2.0.3-5.el8_2.bclinux.1.x86_64
pacemaker-cluster-libs-2.0.3-5.el8_2.bclinux.1.x86_64 pacemaker-libs-2.0.3-5.el8_2.bclinux.1.x86_64 pacemaker-schemas-2.0.3-5.el8_2.bclinux.1.noarch pcs-0.10.4-6.el8_2.bclinux.1.x86_64
perl-TimeDate-1:2.30-15.module+el8.2.0+10201+66fd290b.noarch psmisc-23.1-4.el8.x86_64 python3-clufter-0.77.1-5.el8.noarch python3-lxml-4.2.3-1.el8.x86_64
python3-pyOpenSSL-18.0.0-1.el8.noarch python3-pycurl-7.43.0.2-4.el8.x86_64 resource-agents-4.1.1-44.el8_2.bclinux.6.x86_64 rpcbind-1.2.5-7.el8.x86_64
ruby-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64 ruby-libs-2.5.5-105.module+el8.2.0+10145+e54e5e18.x86_64 rubygem-openssl-2.1.2-105.module+el8.2.0+10145+e54e5e18.x86_64 rubygem-psych-3.0.2-105.module+el8.2.0+10145+e54e5e18.x86_64
rubygems-2.7.6.2-105.module+el8.2.0+10145+e54e5e18.noarch samba-client-libs-4.11.2-15.an8.x86_64 samba-common-4.11.2-15.an8.noarch samba-common-libs-4.11.2-15.an8.x86_64
telnet-1:0.17-73.el8.x86_64
Complete!
[root@xz-sj-dmz-2 chronyrpms]#
- 启动服务
[root@xz-sj-dmz-2 ~]# systemctl enable --now pcsd; systemctl start pcsd; systemctl status pcsd
Created symlink /etc/systemd/system/multi-user.target.wants/pcsd.service → /usr/lib/systemd/system/pcsd.service.
● pcsd.service - PCS GUI and remote configuration interface
Loaded: loaded (/usr/lib/systemd/system/pcsd.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2023-02-08 12:44:07 CST; 31ms ago
Docs: man:pcsd(8)
man:pcs(8)
Main PID: 1318239 (pcsd)
Tasks: 1 (limit: 101112)
Memory: 27.4M
CGroup: /system.slice/pcsd.service
└─1318239 /usr/libexec/platform-python -Es /usr/sbin/pcsd
Feb 08 12:44:06 xz-sj-dmz-2.novalocal systemd[1]: Starting PCS GUI and remote configuration interface...
Feb 08 12:44:07 xz-sj-dmz-2.novalocal systemd[1]: Started PCS GUI and remote configuration interface.
[root@xz-sj-dmz-2 ~]#
创建集群用户和密码【2个主机同步操作】
- 主机1
[root@xz-sj-dmz-2 ~]# echo 'password' | passwd --stdin hacluster
Changing password for user hacluster.
passwd: all authentication tokens updated successfully.
[root@xz-sj-dmz-2 ~]#
- 主机2
[root@xz-sj-dmz-1 ~]# echo 'password' | passwd --stdin hacluster
Changing password for user hacluster.
passwd: all authentication tokens updated successfully.
[root@xz-sj-dmz-1 ~]#
验证pcs运行,两个节点的用户注册到集群
- 只需要在一台主机上执行
我这在主机2上执行的pcs host auth 主机名1主机名 主机2主机名 -u 集群名称 -p password
[root@xz-sj-dmz-2 ~]# pcs host auth xz-sj-dmz-1 xz-sj-dmz-2 -u hacluster -p password
xz-sj-dmz-2: Authorized
xz-sj-dmz-1: Authorized
[root@xz-sj-dmz-2 ~]#
配置集群名称mycluster和启动集群
- 只需要在一台主机上执行【并且主机和上面操作为同一台主机】
我这在主机2上执行的pcs cluster setup 自定义名称 主机1主机名 主机2主机名
[root@xz-sj-dmz-2 ~]# pcs cluster setup mycluster xz-sj-dmz-1 xz-sj-dmz-2
No addresses specified for host 'xz-sj-dmz-1', using 'xz-sj-dmz-1'
No addresses specified for host 'xz-sj-dmz-2', using 'xz-sj-dmz-2'
Destroying cluster on hosts: 'xz-sj-dmz-1', 'xz-sj-dmz-2'...
xz-sj-dmz-2: Successfully destroyed cluster
xz-sj-dmz-1: Successfully destroyed cluster
Requesting remove 'pcsd settings' from 'xz-sj-dmz-1', 'xz-sj-dmz-2'
xz-sj-dmz-2: successful removal of the file 'pcsd settings'
xz-sj-dmz-1: successful removal of the file 'pcsd settings'
Sending 'corosync authkey', 'pacemaker authkey' to 'xz-sj-dmz-1', 'xz-sj-dmz-2'
xz-sj-dmz-2: successful distribution of the file 'corosync authkey'
xz-sj-dmz-2: successful distribution of the file 'pacemaker authkey'
xz-sj-dmz-1: successful distribution of the file 'corosync authkey'
xz-sj-dmz-1: successful distribution of the file 'pacemaker authkey'
Sending 'corosync.conf' to 'xz-sj-dmz-1', 'xz-sj-dmz-2'
xz-sj-dmz-2: successful distribution of the file 'corosync.conf'
xz-sj-dmz-1: successful distribution of the file 'corosync.conf'
Cluster has been successfully set up.
[root@xz-sj-dmz-2 ~]#
状态检查及验证
-
截止目前 下面这些状态2台主机都可以查看。
-
主机1
[root@xz-sj-dmz-1 ~]# pcs cluster enable --all
xz-sj-dmz-1: Cluster Enabled
xz-sj-dmz-2: Cluster Enabled
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]# pcs cluster start --all
xz-sj-dmz-1: Starting Cluster...
xz-sj-dmz-2: Starting Cluster...
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]# pcs cluster status
Cluster Status:
Cluster Summary:
* Stack: corosync
* Current DC: xz-sj-dmz-1 (version 2.0.3-5.el8_2.bclinux.1-4b1f869f0f) - partition with quorum
* Last updated: Wed Feb 8 16:45:55 2023
* Last change: Wed Feb 8 13:01:32 2023 by root via cibadmin on xz-sj-dmz-2
* 2 nodes configured
* 2 resource instances configured
Node List:
* Online: [ xz-sj-dmz-1 xz-sj-dmz-2 ]
PCSD Status:
xz-sj-dmz-1: Online
xz-sj-dmz-2: Online
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]# cat /etc/corosync/corosync.conf
totem {
version: 2
cluster_name: mycluster
transport: knet
crypto_cipher: aes256
crypto_hash: sha256
}
nodelist {
node {
ring0_addr: xz-sj-dmz-1
name: xz-sj-dmz-1
nodeid: 1
}
node {
ring0_addr: xz-sj-dmz-2
name: xz-sj-dmz-2
nodeid: 2
}
}
quorum {
provider: corosync_votequorum
two_node: 1
}
logging {
to_logfile: yes
logfile: /var/log/cluster/corosync.log
to_syslog: yes
timestamp: on
}
[root@xz-sj-dmz-1 ~]# pcs status corosync
Membership information
----------------------
Nodeid Votes Name
1 1 xz-sj-dmz-1 (local)
2 1 xz-sj-dmz-2
- 主机2
[root@xz-sj-dmz-2 ~]# pcs cluster enable --all
xz-sj-dmz-1: Cluster Enabled
xz-sj-dmz-2: Cluster Enabled
[root@xz-sj-dmz-2 ~]# pcs cluster start --all
xz-sj-dmz-2: Starting Cluster...
xz-sj-dmz-1: Starting Cluster...
[root@xz-sj-dmz-2 ~]# pcs cluster status
Cluster Status:
Cluster Summary:
* Stack: unknown
* Current DC: NONE
* Last updated: Wed Feb 8 12:53:29 2023
* Last change: Wed Feb 8 12:53:24 2023 by hacluster via crmd on xz-sj-dmz-2
* 2 nodes configured
* 0 resource instances configured
Node List:
* Node xz-sj-dmz-1: UNCLEAN (offline)
* Node xz-sj-dmz-2: UNCLEAN (offline)
PCSD Status:
xz-sj-dmz-1: Online
xz-sj-dmz-2: Online
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]# cat /etc/corosync/corosync.conf
totem {
version: 2
cluster_name: mycluster
transport: knet
crypto_cipher: aes256
crypto_hash: sha256
}
nodelist {
node {
ring0_addr: xz-sj-dmz-1
name: xz-sj-dmz-1
nodeid: 1
}
node {
ring0_addr: xz-sj-dmz-2
name: xz-sj-dmz-2
nodeid: 2
}
}
quorum {
provider: corosync_votequorum
two_node: 1
}
logging {
to_logfile: yes
logfile: /var/log/cluster/corosync.log
to_syslog: yes
timestamp: on
}
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]# pcs status corosync
Membership information
----------------------
Nodeid Votes Name
1 1 xz-sj-dmz-1
2 1 xz-sj-dmz-2 (local)
[root@xz-sj-dmz-2 ~]#
检查集群配置的有效性
- 注:因为我上面2个操作在节点2上操作的,所以我下面操作也均在节点2上操作的【注意主机别串台】
检查集群报错(unpack_resources) error…处理
- 命令
crm_verify -L -V
【没有输出任何信息则配置正确】- 如果错误,执行下面的两条命令,禁用STONITH:
pcs property set stonith-enabled=false
- 无法仲裁时候,选择忽略:
pcs property set no-quorum-policy=ignore
- 集群故障时候服务迁移:
pcs resource defaults migration-threshold=1
- 如果错误,执行下面的两条命令,禁用STONITH:
[root@xz-sj-dmz-2 ~]# crm_verify -L -V
(unpack_resources) error: Resource start-up disabled since no STONITH resources have been defined
(unpack_resources) error: Either configure some or disable STONITH with the stonith-enabled option
(unpack_resources) error: NOTE: Clusters with shared data need STONITH to ensure data integrity
Errors found during check: config not valid
[root@xz-sj-dmz-2 ~]# pcs property set stonith-enabled=false
[root@xz-sj-dmz-2 ~]# pcs property set no-quorum-policy=ignore
[root@xz-sj-dmz-2 ~]# pcs resource defaults migration-threshold=1
Warning: Defaults do not apply to resources which override them with their own defined values
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-1 ~]# pcs property
Cluster Properties:
cluster-infrastructure: corosync
cluster-name: mycluster
dc-version: 2.0.3-5.el8_2.bclinux.1-4b1f869f0f
have-watchdog: false
no-quorum-policy: ignore
stonith-enabled: false
[root@xz-sj-dmz-1 ~]#
在node1恢复后,为防止node2资源迁回node01(迁来迁去对还是会对业务有一定影响)
[root@xz-sj-dmz-2 ~]# pcs resource defaults resource-stickiness=100
Warning: Defaults do not apply to resources which override them with their own defined values
[root@xz-sj-dmz-2 ~]# pcs resource defaults
migration-threshold=1
resource-stickiness=100
[root@xz-sj-dmz-2 ~]#
设置资源超时时间
[root@xz-sj-dmz-2 ~]# pcs resource op defaults timeout=90s
Warning: Defaults do not apply to resources which override them with their own defined values
[root@xz-sj-dmz-2 ~]# pcs resource op defaults
timeout=90s
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]# pcs property
Cluster Properties:
cluster-infrastructure: corosync
cluster-name: mycluster
dc-version: 2.0.3-5.el8_2.bclinux.1-4b1f869f0f
have-watchdog: false
no-quorum-policy: ignore
stonith-enabled: false
[root@xz-sj-dmz-2 ~]#
执行命令修改如下2个内核参数 (需要root权限)
- 主要针对http服务,如果不是http服务,则不用执行。
sysctl -w net.ipv4.tcp_timestamps=1
开启对于TCP时间戳的支持,若该项设置为0,则下面一项设置不起作用sysctl -w net.ipv4.tcp_tw_recycle=1
表示开启TCP连接中TIME-WAIT sockets的快速回收- 为避免后面启动集群的时候出现这个报错
Mar 13 17:46:11 timevip python[4609]: socket.error: [Errno 99] Cannot assign requested address
验证,正常无回显
- 节点2
[root@xz-sj-dmz-2 ~]# crm_verify -L -V
[root@xz-sj-dmz-2 ~]#
- 节点1【上面操作做完,节点1不需要做啥,理论上也不会有报错的】
[root@xz-sj-dmz-1 ~]# crm_verify -L -V
[root@xz-sj-dmz-1 ~]#
启用nonlocal 绑定内核参数【两台主机均需要操作】
-
注:
net.ipv4.ip_nonlocal_bind = 1
#开启允许绑定非本机的IP -
主机1
[root@xz-sj-dmz-1 ~]# crm_verify -L -V
[root@xz-sj-dmz-1 ~]# echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind
[root@xz-sj-dmz-1 ~]# echo net.ipv4.ip_nonlocal_bind=1 >>/etc/sysctl.d/haproxy.conf
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]# pcs status
Cluster name: mycluster
Cluster Summary:
* Stack: corosync
* Current DC: xz-sj-dmz-1 (version 2.0.3-5.el8_2.bclinux.1-4b1f869f0f) - partition with quorum
* Last updated: Wed Feb 8 13:02:49 2023
* Last change: Wed Feb 8 13:01:32 2023 by root via cibadmin on xz-sj-dmz-2
* 2 nodes configured
* 2 resource instances configured
Node List:
* Online: [ xz-sj-dmz-1 xz-sj-dmz-2 ]
Full List of Resources:
* timevip (ocf::heartbeat:IPaddr2): Started xz-sj-dmz-1
* chronyd (systemd:chronyd): Started xz-sj-dmz-1
Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled
[root@xz-sj-dmz-1 ~]#
- 主机2
[root@xz-sj-dmz-2 ~]# echo net.ipv4.ip_nonlocal_bind=1 >>/etc/sysctl.d/haproxy.conf
[root@xz-sj-dmz-2 ~]# echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind
[root@xz-sj-dmz-2 ~]#
绑定vip
- 单节点操作,我在节点2执行的【和上面配置集群为同一个主机】
pcs resource create timevip【vip主机名(hosts解析定义的)】 ocf:heartbeat:IPaddr2 ip=1.2.3.79【vip_ipaddr】 cidr_netmask=24【掩码】 op【后面为固定内容】 start interval=0s timeout=20s stop interval=0s timeout=20s monitor interval=10s timeout=20s
[root@xz-sj-dmz-2 ~]# pcs resource create timevip ocf:heartbeat:IPaddr2 ip=1.2.3.79 cidr_netmask=24 op start interval=0s timeout=20s stop interval=0s timeout=20s monitor interval=10s timeout=20s
[root@xz-sj-dmz-2 ~]#
绑定chronyd服务
- 这仅仅是展示绑定chronyd服务,更多服务见Pacemaker详解 & pcs命令详解和参数说明这篇文章。
- 我这的vip功能主要是用来绑定chronyd服务的,首先要确认2台主机的chronyd服务都是正常可用的。
[root@xz-sj-dmz-2 ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-02-08 12:43:34 CST; 16min ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Main PID: 1306216 (chronyd)
Tasks: 1 (limit: 101112)
Memory: 1.7M
CGroup: /system.slice/chronyd.service
└─1306216 /usr/sbin/chronyd
Feb 08 12:43:34 xz-sj-dmz-2.novalocal systemd[1]: Starting NTP client/server...
Feb 08 12:43:34 xz-sj-dmz-2.novalocal chronyd[1306216]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Feb 08 12:43:34 xz-sj-dmz-2.novalocal chronyd[1306216]: Frequency -53.297 +/- 0.622 ppm read from /var/lib/chrony/drift
Feb 08 12:43:34 xz-sj-dmz-2.novalocal systemd[1]: Started NTP client/server.
Feb 08 12:43:54 xz-sj-dmz-2.novalocal chronyd[1306216]: Selected source 58.220.133.132
Feb 08 12:46:12 xz-sj-dmz-2.novalocal chronyd[1306216]: Source 114.118.7.163 replaced with 114.118.7.161
Feb 08 12:52:36 xz-sj-dmz-2.novalocal chronyd[1306216]: Selected source 114.118.7.161
[root@xz-sj-dmz-2 ~]#
- 我在节点2操作的
pcs resource create chronyd【服务进程名称】 systemd:chronyd【服务进程名称】 meta interleave=true【下注1内容】 op【后面为固定内容】 start interval=0s timeout=200s stop interval=0s timeout=200s monitor interval=60s
[^注1] :该属性值主要用于改变克隆资源或者 Masters资源之间的 ordering约束行为, Interleave可能的值为 True和 False,如果其值为 False,则位于相同节点上的后一个克隆资源的启动或者停止操作需要等待前一个克隆资源启动或者停止完成才能进行,而如果其值为 True,则后一个克隆资源不用等待前一个克隆资源启动或者停止完成便可进行启动或者停止操作。 Interleave的默认值为 False。pcs constraint colocation【资源捆绑约束】 add chronyd【服务进程名】 with timevip【vip主机名,hosts定义的】 INFINITY
pcs constraint order【顺序约束】 timevip【vip主机名】 then chronyd【进程服务名】
【这行的大概意思就是vip绑定优先级更高】
[root@xz-sj-dmz-2 ~]# pcs resource create timevip ocf:heartbeat:IPaddr2 ip=1.2.3.79 cidr_netmask=24 op start interval=0s timeout=20s stop interval=0s timeout=20s monitor interval=10s timeout=20s
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]# pcs resource create chronyd systemd:chronyd meta interleave=true op start interval=0s timeout=200s stop interval=0s timeout=200s monitor interval=60s
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]# pcs constraint colocation add chronyd with timevip INFINITY
[root@xz-sj-dmz-2 ~]# pcs constraint order timevip then chronyd
Adding timevip chronyd (kind: Mandatory) (Options: first-action=start then-action=start)
[root@xz-sj-dmz-2 ~]# pcs status
Cluster name: mycluster
Cluster Summary:
* Stack: corosync
* Current DC: xz-sj-dmz-1 (version 2.0.3-5.el8_2.bclinux.1-4b1f869f0f) - partition with quorum
* Last updated: Wed Feb 8 13:01:36 2023
* Last change: Wed Feb 8 13:01:32 2023 by root via cibadmin on xz-sj-dmz-2
* 2 nodes configured
* 2 resource instances configured
Node List:
* Online: [ xz-sj-dmz-1 xz-sj-dmz-2 ]
Full List of Resources:
* timevip (ocf::heartbeat:IPaddr2): Started xz-sj-dmz-1
* chronyd (systemd:chronyd): Started xz-sj-dmz-1
Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled
[root@xz-sj-dmz-2 ~]# pcs constraint
Location Constraints:
Ordering Constraints:
start timevip then start chronyd (kind:Mandatory)
Colocation Constraints:
chronyd with timevip (score:INFINITY)
Ticket Constraints:
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]#
- 至此,vip和chronyd绑定完成。
验证vip和自动迁移
vip验证
- 上面操作做完,其实vip就已经通了,如下,我在节点2上能ping通vip,但看不到vip,那么vip肯定就在节点1上了
[root@xz-sj-dmz-2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether fa:16:3e:d5:80:ff brd ff:ff:ff:ff:ff:ff
inet 1.2.3.87/24 brd 1.2.3.255 scope global dynamic noprefixroute ens3
valid_lft 59372sec preferred_lft 59372sec
inet6 fe80::f816:3eff:fed5:80ff/64 scope link
valid_lft forever preferred_lft forever
[root@xz-sj-dmz-2 ~]# ping 1.2.3.79
PING 1.2.3.79 (1.2.3.79) 56(84) bytes of data.
64 bytes from 1.2.3.79: icmp_seq=1 ttl=64 time=1.73 ms
64 bytes from 1.2.3.79: icmp_seq=2 ttl=64 time=0.636 ms
64 bytes from 1.2.3.79: icmp_seq=3 ttl=64 time=0.631 ms
^C
--- 1.2.3.79 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 53ms
rtt min/avg/max/mdev = 0.631/0.998/1.728/0.516 ms
[root@xz-sj-dmz-2 ~]#
- 节点1
[root@xz-sj-dmz-1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether fa:16:3e:8a:68:a0 brd ff:ff:ff:ff:ff:ff
inet 1.2.3.84/24 brd 1.2.3.255 scope global dynamic noprefixroute ens3
valid_lft 69144sec preferred_lft 69144sec
inet 1.2.3.79/24 brd 1.2.3.255 scope global secondary ens3
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe8a:68a0/64 scope link
valid_lft forever preferred_lft forever
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]# ping 1.2.3.79
PING 1.2.3.79 (1.2.3.79) 56(84) bytes of data.
64 bytes from 1.2.3.79: icmp_seq=1 ttl=64 time=0.054 ms
^C
--- 1.2.3.79 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.054/0.054/0.054/0.000 ms
[root@xz-sj-dmz-1 ~]#
自动迁移验证
- 现在vip在节点1上,给节点1关机,能自动迁移到节点2上则正常。
[root@xz-sj-dmz-1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether fa:16:3e:8a:68:a0 brd ff:ff:ff:ff:ff:ff
inet 1.2.3.84/24 brd 1.2.3.255 scope global dynamic noprefixroute ens3
valid_lft 72768sec preferred_lft 72768sec
inet 1.2.3.79/24 brd 1.2.3.255 scope global secondary ens3
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe8a:68a0/64 scope link
valid_lft forever preferred_lft forever
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]# date
Wed Feb 8 13:04:04 CST 2023
[root@xz-sj-dmz-1 ~]#
[root@xz-sj-dmz-1 ~]# reboot
- 节点2已经可以看到vip了,一切正常。
再将节点2关机,看vip是否能自动回迁到节点1上,如果可以,则正常。
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether fa:16:3e:d5:80:ff brd ff:ff:ff:ff:ff:ff
inet 1.2.3.87/24 brd 1.2.3.255 scope global dynamic noprefixroute ens3
valid_lft 59128sec preferred_lft 59128sec
inet 1.2.3.79/24 brd 1.2.3.255 scope global secondary ens3
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fed5:80ff/64 scope link
valid_lft forever preferred_lft forever
[root@xz-sj-dmz-2 ~]# pcs status
Cluster name: mycluster
Cluster Summary:
* Stack: corosync
* Current DC: xz-sj-dmz-2 (version 2.0.3-5.el8_2.bclinux.1-4b1f869f0f) - partition with quorum
* Last updated: Wed Feb 8 13:06:03 2023
* Last change: Wed Feb 8 13:01:32 2023 by root via cibadmin on xz-sj-dmz-2
* 2 nodes configured
* 2 resource instances configured
Node List:
* Online: [ xz-sj-dmz-1 xz-sj-dmz-2 ]
Full List of Resources:
* timevip (ocf::heartbeat:IPaddr2): Started xz-sj-dmz-2
* chronyd (systemd:chronyd): Started xz-sj-dmz-2
Daemon Status:
corosync: active/enabled
pacemaker: active/enabled
pcsd: active/enabled
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]#
[root@xz-sj-dmz-2 ~]# date
Wed Feb 8 13:06:05 CST 2023
[root@xz-sj-dmz-2 ~]# reboot
- 节点1上出现ip,一切正常,那么集群搭建完成。
[root@xz-sj-dmz-1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether fa:16:3e:8a:68:a0 brd ff:ff:ff:ff:ff:ff
inet 1.2.3.84/24 brd 1.2.3.255 scope global dynamic noprefixroute ens3
valid_lft 76326sec preferred_lft 76326sec
inet 1.2.3.79/24 brd 1.2.3.255 scope global secondary ens3
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe8a:68a0/64 scope link
valid_lft forever preferred_lft forever
[root@xz-sj-dmz-1 ~]# pcs config
Cluster Name: mycluster
Corosync Nodes:
xz-sj-dmz-1 xz-sj-dmz-2
Pacemaker Nodes:
xz-sj-dmz-1 xz-sj-dmz-2
Resources:
Resource: timevip (class=ocf provider=heartbeat type=IPaddr2)
Attributes: cidr_netmask=24 ip=1.2.3.79
Operations: monitor interval=10s timeout=20s (timevip-monitor-interval-10s)
start interval=0s timeout=20s (timevip-start-interval-0s)
stop interval=0s timeout=20s (timevip-stop-interval-0s)
Resource: chronyd (class=systemd type=chronyd)
Meta Attrs: interleave=true
Operations: monitor interval=60s (chronyd-monitor-interval-60s)
start interval=0s timeout=200s (chronyd-start-interval-0s)
stop interval=0s timeout=200s (chronyd-stop-interval-0s)
Stonith Devices:
Fencing Levels:
Location Constraints:
Ordering Constraints:
start timevip then start chronyd (kind:Mandatory) (id:order-timevip-chronyd-mandatory)
Colocation Constraints:
chronyd with timevip (score:INFINITY) (id:colocation-chronyd-timevip-INFINITY)
Ticket Constraints:
Alerts:
No alerts defined
Resources Defaults:
migration-threshold=1
resource-stickiness=100
Operations Defaults:
timeout=90s
Cluster Properties:
cluster-infrastructure: corosync
cluster-name: mycluster
dc-version: 2.0.3-5.el8_2.bclinux.1-4b1f869f0f
have-watchdog: false
no-quorum-policy: ignore
stonith-enabled: false
Quorum:
Options:
[root@xz-sj-dmz-1 ~]#
最后
以上就是长情毛衣为你收集整理的Pacemaker详解、pcs命令详解和参数说明、centos8或bclinux8.2离线安装pcs以及搭建pcs、pcs的使用说明【2】Pacemaker详解 & pcs命令详解和参数说明环境说明离线搭建集群pcs的全部内容,希望文章能够帮你解决Pacemaker详解、pcs命令详解和参数说明、centos8或bclinux8.2离线安装pcs以及搭建pcs、pcs的使用说明【2】Pacemaker详解 & pcs命令详解和参数说明环境说明离线搭建集群pcs所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复