keepalived安装与配置

环境:两台Centos7.9  1C   1G 

          分别为  ha1   ha2

 

1. haproxy1 和 haproxy2 安装keepalived haproxy

#yum install keepalived haproxy -y

2.拷贝keepalived的vip模板配置文件

#find / -name keepalived.conf*
#cp /usr/share/doc/keepalived-1.3.5/samples/keepalived.conf.vrrp /etc/keepalived/keepalived.conf 

3.编辑VIP模板文件

#vim /etc/keepalived/keepalived.conf

 

4.启动keepalived

#systemctl restart keepalived.service

可以看到虚拟  IP  地址

 

5.拷贝配置文件到h2备机并编辑配置文件

#scp /etc/keepalived/keepalived.conf 192.168.181.103:/etc/keepalived/keepalived.conf
#vim /etc/keepalived/keepalived.conf

 

 6.启动keepalived

#systemctl start keepalived.service

 

7.验证

关闭haproxy1的keepalived服务

#systemctl stop keepalived.service

 

8.编辑haproxy文件末尾添加

# vim /etc/haproxy/haproxy.cfg

#cp /etc/haproxy/haproxy.cfg 192.168.181.107:/etc/haproxy/
另外一台haproxy也编辑,直接复制过去

两台haproxy添加核心路由转发功能

 

 最后两台haproxy重启keepalived和haproxy

在haproxy2上能ping通虚拟IP,并通过命令  ip  a   查看ip地址能看到VIP,则配置完成

 

posted @ 2022-02-11 00:07  小小一兆  阅读(254)  评论(0编辑  收藏  举报