我试图让keepalived在2个debian jessie VM之间工作。
我已定义主机将 VIP 地址绑定到 172.128.28.6,如下所示:
global_defs {
lvs_id tom_lvs
}
vrrp_instace tom_lvs {
state MASTER
interface eth1
virtual_router_id 1
priority 100
authentication {
auth_type PASS
auth_pass 1234
}
advert_int 1
virtual_ipaddress {
172.28.128.6
}
virtual_server 172.28.128.6 3000 {
delay_loop 10
lb_algo wlc
lb_kind DR
protocol TCP
persistence_timeout 1800
sorry_server 172.28.128.3 3000
real_server 172.28.128.4 3000 {
weight 1
HTTP_GET {
url {
path /index.html
}
}
}
}
}
但是,当我运行时,ip addr
我没有看到附加到 eth3 的第二个 IP:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:f6:86:bf brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fef6:86bf/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:05:a5:a1 brd ff:ff:ff:ff:ff:ff
inet 172.28.128.4/24 brd 172.28.128.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe05:a5a1/64 scope link
valid_lft forever preferred_lft forever
我显然在这里遗漏了一些东西,但我已经在这里呆了 2 天了,但仍然没有找到它。
如果完全相关,机器正在使用 vagrant 和 virtual-box 运行,两者都定义为从 dhcp 获取它们的地址,它们的 IP 是 /24 子网上的 172.128.28.4 和 172.128.28.3。
这是输出grep Keepalived /var/log/messages
:
Feb 13 11:39:51 jessie Keepalived_vrrp[1890]: Registering Kernel netlink reflector
Feb 13 11:39:51 jessie Keepalived_vrrp[1890]: Registering Kernel netlink command channel
Feb 13 11:39:51 jessie Keepalived_vrrp[1890]: Registering gratuitous ARP shared channel
Feb 13 11:39:51 jessie Keepalived_vrrp[1890]: Opening file '/etc/keepalived/keepalived.conf'.
Feb 13 11:39:51 jessie Keepalived_vrrp[1890]: Configuration is using : 58175 Bytes
Feb 13 11:39:51 jessie Keepalived_vrrp[1890]: Using LinkWatch kernel netlink reflector...
Feb 13 11:39:51 jessie Keepalived_healthcheckers[1889]: Registering Kernel netlink reflector
Feb 13 11:39:51 jessie Keepalived_healthcheckers[1889]: Registering Kernel netlink command channel
Feb 13 11:39:51 jessie Keepalived_healthcheckers[1889]: Opening file '/etc/keepalived/keepalived.conf'.
Feb 13 11:39:51 jessie Keepalived_healthcheckers[1889]: Configuration is using : 12031 Bytes
Feb 13 11:39:51 jessie Keepalived_healthcheckers[1889]: Using LinkWatch kernel netlink reflector...
Feb 13 11:39:51 jessie Keepalived_healthcheckers[1889]: Activating healthchecker for service [172.28.128.4]:3000
如果您复制/粘贴了配置文件,我注意到您的配置中有错字。除此之外,一切似乎都很好。
您需要修复 VRRP 实例定义为:
您错过了关键字中的第二个
n
字母。vrrp_instance
修复配置并重新启动 keepalived 后,您应该会看到类似于以下内容的日志行: