我在 ubuntu 12.10 服务器上安装了 keepalived 包并对其进行了配置,但它后来在系统日志中抱怨必须设置虚拟 ID
保持活动配置
# Define the script used to check if haproxy is still working
vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
# Configuation for the virtual interface
vrrp_instance VI_1 {
state MASTER # set this to BACKUP on the other machine
virtual_router_id 1
priority 101 # set this to 100 on the other machine
interface eth0
authentication {
auth_type AH
auth_pass myPassw0rd # Set this to some secret phrase
}
# The virtual ip address shared between the two loadbalancers
virtual_ipaddress {
192.168.1.10/24
}
# Use the script above to check if we should fail over
track_script {
chk_haproxy
}
}
网络配置
auto eth0
iface eth0 inet static
address 192.168.1.11
netmask 255.255.255.0
auto eth0:1
iface eth0:1 inet static
address 192.168.1.10
netmask 255.255.255.0
SysLog 输出告诉我必须设置虚拟 ID...在任何文档中都找不到与该错误相关的任何内容
Jan 17 06:48:41 haproxy Keepalived_vrrp: Opening file '/etc/keepalived/keepalived.conf'.
Jan 17 06:48:41 haproxy Keepalived_vrrp: VRRP_Instance(VI_1) the virtual id must be set!
Jan 17 06:48:41 haproxy Keepalived_vrrp: Registering Kernel netlink reflector
Jan 17 06:48:41 haproxy Keepalived_vrrp: Registering Kernel netlink command channel
Jan 17 06:48:41 haproxy Keepalived_vrrp: Registering gratutious ARP shared channel
Jan 17 06:48:41 haproxy Keepalived_vrrp: Initializing ipvs 2.6
Jan 17 06:48:41 haproxy Keepalived_vrrp: Opening file '/etc/keepalived/keepalived.conf'.
Jan 17 06:48:41 haproxy Keepalived_vrrp: VRRP_Instance(VI_1) the virtual id must be set!
Jan 17 06:48:41 haproxy Keepalived_vrrp: Registering Kernel netlink reflector
Jan 17 06:48:41 haproxy Keepalived_vrrp: Registering Kernel netlink command channel
Jan 17 06:48:41 haproxy Keepalived_vrrp: Registering gratutious ARP shared channel
Jan 17 06:48:41 haproxy Keepalived_vrrp: Initializing ipvs 2.6
答案1
(这还不是一个答案,但是日志文件在评论中太难读取)
Ubuntu 12.10
再次强调,完全没有问题
网络
# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:66:f0:56
inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe66:f056/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2025 errors:0 dropped:0 overruns:0 frame:0
TX packets:2113 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1244217 (1.2 MB) TX bytes:303305 (303.3 KB)
eth0:1 Link encap:Ethernet HWaddr 08:00:27:66:f0:56
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
eth1 Link encap:Ethernet HWaddr 08:00:27:66:2d:ba
inet addr:10.0.0.11 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe66:2dba/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:55 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7500 (7.5 KB) TX bytes:468 (468.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
安装
# uname -a
Linux u64s10 3.5.0-22-generic #34-Ubuntu SMP Tue Jan 8 21:47:00 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
# dpkg -l|grep keepalived
ii keepalived 1:1.2.2-3ubuntu2 amd64 Failover and monitoring daemon for LVS clusters
系统日志
Jan 20 16:26:56 u64s10 Keepalived: Starting Keepalived v1.2.2 (10/04,2012)
Jan 20 16:26:56 u64s10 Keepalived: Starting Healthcheck child process, pid=1863
Jan 20 16:26:56 u64s10 Keepalived: Starting VRRP child process, pid=1864
Jan 20 16:26:56 u64s10 Keepalived_healthcheckers: Initializing ipvs 2.6
Jan 20 16:26:56 u64s10 Keepalived_vrrp: Registering Kernel netlink reflector
Jan 20 16:26:56 u64s10 Keepalived_vrrp: Registering Kernel netlink command channel
Jan 20 16:26:56 u64s10 Keepalived_vrrp: Registering gratutious ARP shared channel
Jan 20 16:26:56 u64s10 Keepalived_vrrp: Initializing ipvs 2.6
Jan 20 16:26:57 u64s10 kernel: [ 294.832154] nf_conntrack version 0.5.0 (3931 buckets, 15724 max)
Jan 20 16:26:57 u64s10 kernel: [ 294.857887] IPVS: Registered protocols (TCP, UDP, SCTP, AH, ESP)
Jan 20 16:26:57 u64s10 kernel: [ 294.857935] IPVS: Connection hash table configured (size=4096, memory=64Kbytes)
Jan 20 16:26:57 u64s10 kernel: [ 294.857986] IPVS: Creating netns size=2064 id=0
Jan 20 16:26:57 u64s10 kernel: [ 294.859535] IPVS: ipvs loaded.
Jan 20 16:26:57 u64s10 Keepalived_vrrp: Opening file '/etc/keepalived/keepalived.conf'.
Jan 20 16:26:57 u64s10 Keepalived_healthcheckers: Registering Kernel netlink reflector
Jan 20 16:26:57 u64s10 Keepalived_healthcheckers: Registering Kernel netlink command channel
Jan 20 16:26:57 u64s10 Keepalived_healthcheckers: Opening file '/etc/keepalived/keepalived.conf'.
Jan 20 16:26:57 u64s10 Keepalived_healthcheckers: Configuration is using : 4587 Bytes
Jan 20 16:26:57 u64s10 Keepalived_healthcheckers: Using LinkWatch kernel netlink reflector...
Jan 20 16:26:57 u64s10 Keepalived_vrrp: Configuration is using : 62468 Bytes
Jan 20 16:26:57 u64s10 Keepalived_vrrp: Using LinkWatch kernel netlink reflector...
Jan 20 16:26:58 u64s10 Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
Jan 20 16:26:59 u64s10 Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Ubuntu 12.04
我按原样使用 OP keepalived.conf
,并且能够启动它而不会出现任何 syslog 错误,无论有没有 eth0:1(192.168.1.10)。
安装 keepalived
apt-get install keepalived
dpkg -l|grep keepalived
ii keepalived 1:1.2.2-3ubuntu1 Failover and monitoring daemon for LVS clusters
该包中没有keepalive.conf
文件,只有一个空/etc/keepalived
目录。
ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:cb:0d:5c
inet addr:192.168.1.211 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fecb:d5c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8548 errors:0 dropped:0 overruns:0 frame:0
TX packets:3029 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4967707 (4.9 MB) TX bytes:290373 (290.3 KB)
eth0:1 Link encap:Ethernet HWaddr 08:00:27:cb:0d:5c
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:780 (780.0 B) TX bytes:780 (780.0 B)
系统日志
Jan 20 03:43:54 U64D211 Keepalived: Starting Keepalived v1.2.2 (12/23,2011)
Jan 20 03:43:54 U64D211 Keepalived: Starting Healthcheck child process, pid=5140
Jan 20 03:43:54 U64D211 Keepalived_healthcheckers: Initializing ipvs 2.6
Jan 20 03:43:54 U64D211 Keepalived: Starting VRRP child process, pid=5142
Jan 20 03:43:54 U64D211 Keepalived_healthcheckers: Registering Kernel netlink reflector
Jan 20 03:43:54 U64D211 Keepalived_healthcheckers: Registering Kernel netlink command channel
Jan 20 03:43:54 U64D211 Keepalived_healthcheckers: Opening file '/etc/keepalived/keepalived.conf'.
Jan 20 03:43:54 U64D211 Keepalived_healthcheckers: Configuration is using : 4493 Bytes
Jan 20 03:43:54 U64D211 Keepalived_healthcheckers: Using LinkWatch kernel netlink reflector...
Jan 20 03:43:54 U64D211 Keepalived_vrrp: Registering Kernel netlink reflector
Jan 20 03:43:54 U64D211 Keepalived_vrrp: Registering Kernel netlink command channel
Jan 20 03:43:54 U64D211 Keepalived_vrrp: Registering gratutious ARP shared channel
Jan 20 03:43:54 U64D211 Keepalived_vrrp: Initializing ipvs 2.6
Jan 20 03:43:54 U64D211 Keepalived_vrrp: Opening file '/etc/keepalived/keepalived.conf'.
Jan 20 03:43:54 U64D211 Keepalived_vrrp: Configuration is using : 62374 Bytes
Jan 20 03:43:54 U64D211 Keepalived_vrrp: Using LinkWatch kernel netlink reflector...
Jan 20 03:43:55 U64D211 Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE
系统日志输出似乎不同。
答案2
不确定这是否与日志中显示的错误有关,但您不应该自己在机器上设置 VIP。Keepalived 会处理它。
因此删除eth0:0
中的别名/etc/network/interfaces
。
答案3
最近遇到了同样的错误消息,我想在这里添加解决方案。在我们的例子中,配置文件的内容是通过 Windows 文本编辑器剪切和粘贴的。虽然文件在 Windows(和 VI)中看起来不错,但使用“less”查看文件时显然存在一些问题。
查看源代码,您可以看到错误消息基本上是配置文件问题的全部内容。错误消息:
1 月 28 日 17:08:02 Test-LB1 Keepalived_vrrp[7027]: VRRP_Instance(VI_1) 必须设置虚拟 ID!
清理文件并使用常规空格后,一切正常。