Keepalived -----》 VIP
即使Master服务器挂了还有Slave服务器,Master服务器的VIP会漂移到Slave服务器
Keepalived 包安装
#CentOS
[root@centos ~]#yum -y install keepalived
#ubuntu
[root@ubuntu1804 ~]#apt -y install keepalived
查看keepalived.service
#dpkg -L keepalived |grep service
/lib/systemd/system/keepalived.service
#grep -Ev '^#' /lib/systemd/system/keepalived.service
[Unit]
Description=Keepalive Daemon (LVS and VRRP)
After=network-online.target
Wants=network-online.target
ConditionFileNotEmpty=/etc/keepalived/keepalived.conf
[Service]
Type=simple
EnvironmentFile=-/etc/default/keepalived
ExecStart=/usr/sbin/keepalived --dont-fork $DAEMON_ARGS
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@ubuntu110 ~]#keepalived -v
Keepalived v2.0.19 (10/19,2019)
安装后服务并未启动
拷贝配置文件模版作为配置文件
#cp /usr/share/doc/keepalived/samples/keepalived.conf.sample /etc/keepalived/keepalived.conf
重启服务
#systemctl restart keepalived.service
#systemctl status keepalived.service
KA1主机IP
KA1配置文件
# vim /etc/keepalived/keepalived.conf
global_defs {
router_id ka1
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 66
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
10.0.0.100/8 dev eth0 label eth0:1
}
}
KA2主机IP
KA2配置文件
# vim /etc/keepalived/keepalived.conf
global_defs {