我在Ubuntu 12.10服务器上安装了keepalived软件包并对其进行了configuration,但稍后在syslog中发出抱怨,必须设置一个虚拟ID
保持活跃的configuration
# 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 } }
networkingconfiguration
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
(这还不是答案,但日志文件太难阅读了)
再次,没有问题
# 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
我使用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
系统日志输出似乎是不同的。
不知道它是否与日志中显示的错误有关,但是您不应该自己在机器上设置VIP。 Keepalived会照顾它。
所以删除/etc/network/interfaces中的eth0:0别名。
最近进入相同的错误信息,并认为我会在这里添加解决scheme。 在我们的例子中,configuration文件的内容已经通过Windows文本编辑器剪切和粘贴。 虽然在Windows(和VI)中文件看起来很好,但在使用“less”查看文件时显然存在一些问题。
查看源代码,可以看到错误消息基本上是configuration文件的问题。 错误信息:
Jan 28 17:08:02 Test-LB1 Keepalived_vrrp [7027]:VRRP_Instance(VI_1)必须设置虚拟ID!
清理文件并使用常规空间后,一切正常。
