keepalive:
调度器的高可用
VIP主备之间切换,主在工作时,VIP会在主上,主停止工作,VIP飘移到备服务器。
在主备的优先级不变的情况下,主恢复工作,vip会飘回到主服务器
1、配优先级
2、配置vip和真实服务器
3、主备的id要一致。
4、主备的id要区分。
keepalive是专门为lvs打造的,但是不是为lvs专门使用的
keepalive也可以使用nginx,haproxy
keepalive+nginx实现高可用
nginx1 192.168.11.137
nginx2 192.168.11.138
客户端 192.168.11.136
nginx1配置
[root@test2 ~]# yum install -y keepalived
[root@test2 opt]# cat check_nginx.sh
#!/bin/bash
/usr/bin/curl -I http://localhost &> /dev/null
if [ $? -ne 0 ]
then
systemctl stop keepalived
fi
[root@test2 opt]#chmod 777 check_nginx.sh
[root@test2 opt]# systemctl restart keepalived.service
[root@test2 opt]# systemctl restart nginx
[root@test2 keepalived]# cat keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email