keepalived 高可用离线配置

安装

rpm -ivh ./*.rpm --nodeps --force

检测脚本复制到/etc/keepalived/,命名为check_platform.sh

#!bin/bash

# 检查中台前端服务端口5601的访问状态
curl -s http://127.0.0.1:5601 > /dev/null 2>&1
if [ $? -ne 0 ]; then
  # 如果服务不可达,返回1表示失败
  exit 1
fi
# 服务可达,返回0表示成功
exit 0

修改/etc/keepalived/配置文件keepalived.conf

! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id keepalived1
   vrrp_skip_check_adv_addr
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}

vrrp_script check_platform {
    script "/etc/keepalived/check_platform.sh"
    interval 2 # 每两秒执行一次脚本
    weight -20 # 权重,服务失败直接-20
    fall 2 # 连续失败2次触发优先级下降
    rise 2 # 连续成功2次就恢复优先级
}

vrrp_instance PLATFORM_VI_1 {
    state BACKUP #主从节点BACKUP、MASTER 都配主,都配从,都可以
    interface ens192 #对应网卡ip a查看
    virtual_router_id 81
    priority 100 #权重
    advert_int 1 #广播间隔
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.22.32.166 #虚IP
    }
    track_script {
        check_platform
    }
}

增加权限

chmod +x /etc/keepalived/check_platform.sh

启动

systemctl start keepalived

查看是否启动成功,网卡中多了虚拟的ip则启动成功

ip a

查看日志

journalctl -u keepalived -n -f 
相关推荐
LYK_HAHA16 天前
keepalived+lVS(dr)高可用集群
lvs·keepalived
pcj_88822 天前
keepalived双机热备方案实现Nginx高可用
nginx·keepalived·ha
稻草人ZZ24 天前
Keepalived部署
linux·服务器·网络·keepalived
cnskylee1 个月前
【Keepalived】Keepalived 2.3.2版本编译报错
keepalived·keepalived2.3.2·make报错
lldhsds3 个月前
借助keepalived配置高可用nginx集群
nginx·keepalived·高可用
小亦小亦_空中接力3 个月前
openssl+keepalived安装部署
openssl·keepalived
童安格粉丝3 个月前
centos 7 防止及解决keepalive脑裂现象(主备均有vip)
运维·centos·问题·keepalived·vip·漂移·两台都有
小时候的阳光3 个月前
Docker方式部署ProxySQL和Keepalived组合实现MGR的高可用访问
mysql·docker·keepalived·mgr·proxysql
小时候的阳光3 个月前
Docker部署tenine实现后端应用的高可用与负载均衡
docker·负载均衡·keepalived·高可用·tengine