1、 简述 Keepalived 的主要功能、应用场合。
1.故障切换:实现LB Master主机和Backup主机之间故障转移和自动切换
2.健康检查:负载均衡定期检查RS的可用性决定是否非其分发请求
应用:双机热备,配置负载均衡
2、 使用 Keepalived 实现双机热备时,主、备服务器的配置存在哪些区别?
router_id 不同 主的state 为MASTER 从的为BACKUP priority不同
3、 构建 LVS+Keepalived 高可用群集时,如何缩短故障中断时间?
健康检查
4、 基于 CentOS 7构建nginx的Keepalived 高可用群集
yum install gcc gcc-c++ make openssl-devel libnl libnl-devel -y
wget http://www.keepalived.org/software/keepalived-2.0.20.tar.gz --no-check-certificate
cd /usr/local/src/keepalived-2.0.20
./configure --prefix=/usr/local/keepalived --sysconfdir=/etc
make & make install
ln -sv /usr/local/keepalived/sbin/keepalived /sbin
cp /usr/local/src/keepalived-2.0.10/keepalived/etc/init.d/keepalived /etc/init.d
vim /usr/lib/systemd/system/keepalived.service
服务配置
systemctl daemon-reload keepalived
systemctl start keepalived.service
主机
cd /etc/keepalived/
cp keepalived.conf{,.bak}
vim keepalived.conf
scp keepalived.conf 192.168.28.130:/etc/keepalived/
备机
测试
双主模式:
主机1:
主机2:
systemctl restart keepalived
配置脚本
vim /etc/keepalived/check_nginx.sh
cd /etc/keepalived/
nohup ./check_nginx.sh
停止主机1