Centos7中如何实现pacemaker高可用安装配置
1.下载安装依赖包
yum -y install pcs fence-agents-all resource-agents
2.修改hosts文件
vim /etc/hosts
192.168.4.100 node1
192.168.4.101 node2
3.修改selinux
vim /etc/selinux/config
SELINUX=disabled
4.停止防火墙
systemctl stop firewalld.service
5.禁用防火墙
systemctl disable firewalld.service
6.安装pacemaker
pcs cluster setup --name ha cluster node1 node2
7.启动pacemaker
pcs cluster start --all
8.查看集群状态
pcs status cluster
9.配置集群资源
pcs resource create vip ocf:heartbeat:IPaddr2 ip=192.168.4.99 cidr_netmask=24 op monitor interval=30s
pcs resource create mysql ocf:heartbeat:mysql user=root password=123456 op monitor interval=30s
10.配置集群策略
pcs constraint colocation add vip with mysql INFINITY
pcs constraint order mysql then vip
11.查看集群资源状态
pcs status resources
12.配置集群共享存储
1)挂载共享存储
mkdir -p /data/mysql
mount -t nfs 192.168.4.1:/data/mysql /data/mysql
2)修改mysql配置文件
vim /etc/my.cnf
[mysqld]
datadir=/data/mysql
3)重启mysql服务
service mysql restart
4)查看mysql状态
netstat -ntlp|grep 3306
13.配置集群检测网络状态
pcs resource create pingd ocf:pacemaker:pingd op monitor interval=30s
14.查看集群状态
pcs status cluster
15.在node1上手动停止vip服务
pcs resource disable vip
16.查看集群状态
pcs status cluster
17.在node1上手动停止mysql服务
pcs resource disable mysql
18.查看集群状态
pcs status cluster
相关文章