Keepalived

keepalived 未啟動並抱怨未設置虛擬 ID

  • January 29, 2015

我在 ubuntu 12.10 伺服器上安裝了 keepalived 包並對其進行了配置,但它稍後在 syslog 中抱怨必須設置虛擬 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

(這還不是答案,但是日誌文件在評論中太難讀了)

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

syslog 輸出似乎有所不同。

引用自:https://serverfault.com/questions/470003