我有以下 keepalived.conf 文件:
vrrp_script chk_nginx {
script "curl http://localhost/vrrp_healthcheck/"
interval 2 # every 2 seconds
weight 2 # add 2 points if OK
}
vrrp_instance VI_1 {
interface ens160 # interface to monitor
virtual_router_id 50
priority 100
virtual_ipaddress {
192.168.120.25 label ens160:10
}
track_script {
chk_nginx
}
notify /usr/local/bin/notify.sh
}
在主节点上,我在 ifconfig 输出中看到以下内容:
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.120.20 netmask 255.255.255.224 broadcast 192.168.120.31
ether 00:50:56:a5:c5:3a txqueuelen 1000 (Ethernet)
RX packets 138308 bytes 130425415 (124.3 MiB)
RX errors 0 dropped 73 overruns 0 frame 0
TX packets 122917 bytes 50788591 (48.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens160:10: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.120.25 netmask 255.255.255.255 broadcast 0.0.0.0
ether 00:50:56:a5:c5:3a txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
RX packets 9730 bytes 812897 (793.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9730 bytes 812897 (793.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
令我担心的是 ens160:10 条目(由 keepalived 创建的条目)中的不同广播和网络地址。
这些不应该与常规界面相匹配吗?
目前,我的设置似乎有效,但我想确保它设置正确。
答案1
你可以简单地修改虚拟 IP 地址块以使其如下所示:
virtual_ipaddress {
192.168.120.25/27 label ens160:10
}
默认掩码为/32
或255.255.255.255
。