Keepalived
keepalived virtual_ipaddress 和網路遮罩
我有以下 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 創建的)中不同的廣播和網路地址。
這些不應該與正常界面中的匹配嗎?
目前,我的設置似乎有效,但我想確保它設置正確。
您可以簡單地將虛擬 IP 地址塊修改為:
virtual_ipaddress { 192.168.120.25/27 label ens160:10 }
預設遮罩是
/32
或255.255.255.255
。