本文作者:丁辉
Keepalived部署使用
介绍:当前配置完全可以在大规模生产集群中使用
节点 | 网关IP | VIP |
---|---|---|
主网关一 | 192.168.1.11 | |
从网关二 | 192.168.1.12 | |
192.168.1.10 |
安装 keepalived
1 | yum install -y keepalived |
主节点
编辑配置文件
1 | mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak |
内容如下
1 | ! Configuration File for keepalived |
从节点
编辑配置文件
1 | mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak |
内容如下
1 | ! Configuration File for keepalived |
启动 keepalived
1 | systemctl start keepalived |
配置健康检测
编辑脚本
1
vi /etc/keepalived/check_health_status.sh
内容如下
1
2
3
4
5
6
7
8
/usr/bin/curl -I http://localhost:10254/healthz
if [ $? -ne 0 ];then
cat /var/run/keepalived.pid | xargs kill
fi授权
1
chmod +x /etc/keepalived/check_health_status.sh
确保服务启动后,编辑 keepalived 配置文件取消检测注释,重启后生效
1
systemctl restart keepalived
配置 Keepalived 自恢复
更改 Keepalived Systemd 配置文件, 加入如下内容, Keepalived会一直重启检测服务是否恢复正常
1 | vi /lib/systemd/system/keepalived.service |
1 | [Service] |
防火墙配置
开放其中一种即可
允许vrrp流量
1
iptables -A INPUT -p vrrp -j ACCEPT
允许组播流量
1
iptables -A INPUT -m pkttype --pkt-type multicast -j ACCEPT
I'm so cute. Please give me money.
- 本文链接: https://blog.offends.cn/Linux/资源安装/Keepalived部署.html
- 版权声明: 本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。