corosync+pacemaker+pcs+haproxy负载均衡高可用

部署环境:

操作系统

Centos7

集群用户hacluster密码

hello

haproxy01

172.16.12.97

haproxy02

172.16.12.98

 

部署过程:

关闭selinux、防火墙。同步时间、双机互信hosts文件解析。

******************以下命令两台haproxy机器上都运行********************

# yum  install epel-release  -y

# yum  install  pcs  pacemaker  corosync  fence-agents-all  haproxy  -y

# systemctl start pcsd.service

# systemctl enable pcsd.service

# echo  hello  |   passwd    --stdin   hacluster

   //给集群用户创建密码,密码为hello,后面建立集群时会用到密码!!!!

 

 

*****************以下命令在任意一台机器上进行***************************

# pcs cluster auth  haproxy01 haproxy02 -u hacluster -p hello --force //输入集群用户名和密码进行验证。

# pcs cluster setup --start --name lb_cluster  haproxy01  haproxy02  //创建集群,起个集群名字并指定集群成员

# pcs cluster enable--all        //设置集群开机自启

# pcs cluster status           //查看集群状态

# crm_verify --V            //验证配置是否正确,无输出正确

 

# pcs property set stonith-enabled=false  //禁用STONITH设备

# pcs property set no-quorum-policy=ignore   //忽略票数仲裁

 

 

**********创建集群资源*****************

# pcs resource create vip ocf:heartbeat:IPaddr2 params ip="10.0.0.11" cidr_netmask="24" op monitor interval="30s"      //创建虚拟IP资源

# pcs resource create haproxy systemd:haproxy op monitor interval="5s"  //创建haproxy资源

# pcs constraint colocation add vip haproxy INFINITY   //ip资源haproxy资源绑定

# pcs constraint order vip then haproxy   //约束定义,先启动ip资源再启动haproxy资源

 

然后重新启动两台节点

 

如果集群资源部署完成,运行pcs  status命令时,出现以下错误。重新启动两台节点服务器即可


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值