IT评测·应用市场-qidao123.com

标题: Centos7.6下corosync+pacemaker+pcs高可用集群环境安装 [打印本页]

作者: 三尺非寒    时间: 2023-3-7 20:53
标题: Centos7.6下corosync+pacemaker+pcs高可用集群环境安装
在容灾备份领域,有多种高可用方案,corosync+pacemaker无疑是开源方案中的佼佼者。
1. 什么是corosync、pacemaker、pcs?





2. 环境准备

1、保证两个节点上的/etc/hosts文件均添加了下面的内容
  1. 10.10.4.176 g0001210030-00-server01
  2. 10.10.4.177 g0001210030-00-server02
复制代码
2、关闭防火墙(每个节点都需执行)
  1. setenforce 0
  2. sed -i.bak "s/SELINUX=enforcing/SELINUX=permissive/g" /etc/selinux/config
  3. systemctl disable firewalld.service
  4. systemctl stop firewalld.service
  5. iptables --flush
复制代码
3、查看主备机是否安装ntp服务
  1. systemctl status ntpd.service
复制代码

若未安装ntp服务,先安装,确认安装ntp服务后,主机执行以下命令
  1. cp /etc/ntp.conf /etc/ntp.conf.bak
  2. rm -f /etc/ntp.conf
  3. vi /etc/ntp.conf
复制代码
在/etc/ntp.conf文件输入以下内容
  1. restrict default kod nomodify notrap nopeer noquery
  2. restrict -6 default kod nomodify notrap nopper noquery
  3. restrict 127.0.0.1
  4. restrict -6::1
  5. restrict 10.10.1.0 mask 255.255.0.0 nomodify notrap
  6. server 10.10.4.176
  7. server 127.127.1.0
  8. fudge 127.127.1.0 stratum 10
复制代码
启动主机ntp服务
  1. #systemctl start ntpd.service
复制代码
备机执行以下命令
  1. ntpdate 10.10.4.176
复制代码
如果出现下面提示
  1. 21 Sep 18:01:41 ntpdate[2604]: no server suitable for synchronization found
复制代码
稍等片刻再执行一次
  1. ntpdate 10.10.4.176
复制代码
3. 安装集群软件



安装完毕,输入pcs status查询集群状态为下图所示,表示集群安装成功

4. 集群资源配置

1、注意:配置集群资源时,为防止资源启动的节点不一致,需要暂时将备节点的集群服务停止。在任意节点输入
  1. pcs cluster stop G0001210030-00-SERVER02
复制代码
即可关闭备节点集群服务。
2、配置浮动IP和ha服务高可用(ip需根据实际情况修改、在任意节点配置即可)
  1. pcs resource create vip ocf:heartbeat:IPaddr2 ip=192.168.8.53 cidr_netmask=16 op monitor interval=30s
  2. pcs resource create ha systemd:ha op monitor interval=60s timeout=60s on-fail=restart
复制代码
配置资源关系
  1. pcs constraint colocation add vip ha INFINITY
复制代码
设置启动顺序
  1. pcs constraint order vip  then ha
复制代码
3、配置其他资源,如mariadb数据库服务(在任意节点配置即可,需要注意的是:配置mariadb服务高可用需要将mariadb服务设置为开机不自启)
  1. pcs resource create mysql-s systemd:mariadb op monitor interval=60s timeout=60s on-fail=restart
复制代码
配置资源关系
  1. pcs constraint colocation add ha mysql-s INFINITY
复制代码
设置启动顺序
  1. pcs constraint order ha then mysql-s
复制代码
至此整个搭建过程完毕。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!




欢迎光临 IT评测·应用市场-qidao123.com (https://dis.qidao123.com/) Powered by Discuz! X3.4