Keepalived 安装
一、首先确保一些核心参数配置正确
修改 /etc/sysctl.conf的如下参数:
net.ipv4.ip_forward=1
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
sysctl -p /etc/sysctl.conf
cat /proc/sys/net/ipv4/ip_forward
cat /proc/sys/net/ipv4/ip_nonlocal_bind
cat /proc/sys/net/ipv4/conf/lo/arp_ignore
cat /proc/sys/net/ipv4/conf/lo/arp_announce
cat /proc/sys/net/ipv4/conf/all/arp_ignore
cat /proc/sys/net/ipv4/conf/all/arp_announce
二、在主节点 修改keepalived.conf
global_defs {
notification_email{
andy_hugb@hotmail.com
}
notification_email_from andy_hugb@163.com
smtp_server mail.163.com
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
mcast_src_ip 192.168.222.132
authentication {
auth_type PASS
auth_pass 8888
}
virtual_ipaddress {
192.168.222.134/24 brd 192.168.222.255 dev ens33 label ens33:vip
}
}
三、在备节点修改keepalived.conf
global_defs {
notification_email{
andy_hugb@hotmail.com
}
notification_email_from andy_hugb@163.com
smtp_server mail.163.com
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 100
advert_int 1
mcast_src_ip 192.168.222.133
authentication {
auth_type PASS
auth_pass 8888
}
virtual_ipaddress {
192.168.222.134/24 brd 192.168.222.255 dev ens33 label ens33:vip
}
}