显示keepalived.conf的配置内容
! Configuration File for keepalived
global_defs {
router_id EODC_HA
}
vrrp_script chk_80 {
script “/etc/keepalived/chk_status.sh”
interval 1
weight -3
}
vrrp_instance VI_1 {
interface ens192
state MASTER
priority 101
virtual_router_id 51
garp_master_delay 1
authentication {
auth_type PASS
auth_pass 123456
}
track_interface {
ens192
}
virtual_ipaddress {
172.17.0.20/32 dev ens192 label ens192:0 #填写VIP, 网卡名,VIP的网卡别名
}
track_script {
chk_80
}
}
chk_status.sh
#!/bin/bash
curl -L -k -i http://localhost/api/values|grep “200 OK” > /dev/null
if [ $? -eq 0 ]; then
exit 0
else
exit 1
fi