Linux

虛擬介面應該與keepalived衝突嗎?

  • July 13, 2018

我今天在伺服器上工作,debian 擠壓。在兩台登台伺服器上對此進行測試後,我向 /etc/network/interfaces 添加了一個虛擬網路介面,如下所示:

# The primary network interface
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
   address 10.100.2.70
   netmask 255.255.0.0
   gateway 10.100.0.1

# adding this one
auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
   address 10.100.2.77
   netmask 255.255.0.0
   gateway 10.100.0.1

Keepalived 正在管理機器上的虛擬 IP

ip addr show
....
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:24:81:81:e5:54 brd ff:ff:ff:ff:ff:ff
inet 10.100.2.70/16 brd 10.100.255.255 scope global eth0
inet 10.100.2.72/32 scope global eth0

有了新的介面數據,sudo service networking restart盒子上的網路就關閉了。使用通過 iDrac 的控制台,即使從文件中刪除了新行,網路也無法啟動,並且需要重新啟動。我知道我本可以做到if-up eth0:0的,但我想看到整個事情的順利進行。

keepalived 的某些功能是否會導致我的問題?我在 syslog 中看到的唯一日誌消息是

Sep 30 15:48:17 pgpool01 Keepalived_vrrp: Kernel is reporting: interface eth0 DOWN
Sep 30 15:48:17 pgpool01 Keepalived_vrrp: VRRP_Instance(VI_1) Entering FAULT STATE
Sep 30 15:48:17 pgpool01 Keepalived_vrrp: VRRP_Instance(VI_1) Now in FAULT state

就像我說的,我沒有看到暫存箱上的問題。

任何提示都會有所幫助,謝謝。

編輯:添加 ip 連結和 ifconfig 輸出

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
   link/ether 00:24:81:81:e5:54 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
   link/ether 00:24:81:81:e5:55 brd ff:ff:ff:ff:ff:ff

$ /sbin/ifconfig
eth0  Link encap:Ethernet  HWaddr 00:24:81:81:e5:54  
     inet addr:10.100.2.70  Bcast:10.100.255.255  Mask:255.255.0.0
     inet6 addr: fe80::224:81ff:fe81:e554/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
     RX packets:2080027816 errors:0 dropped:0 overruns:0 frame:0
     TX packets:2498837332 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000 
     RX bytes:683029542202 (636.1 GiB)  TX bytes:710577938507 (661.7 GiB)
     Interrupt:16 Memory:fc4c0000-fc4e0000 

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:45564 errors:0 dropped:0 overruns:0 frame:0
     TX packets:45564 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:0 
     RX bytes:2279497 (2.1 MiB)  TX bytes:2279497 (2.1 MiB)

和keepalived.conf

vrrp_script chk_pgpool {           # Requires keepalived-1.1.13
   script "killall -0 pgpool"     # cheaper than pidof
   interval 2                      # check every 2 seconds
   weight 2                        # add 2 points of prio if OK
}
vrrp_instance VI_1 {
   interface eth0
   state MASTER
   virtual_router_id 72
   priority 101                    # 101 on master, 100 on backup
   virtual_ipaddress {
       10.100.2.72
   }
   track_script {
       chk_pgpool
   }
}

感謝您發布附加資訊。我忘記了keepalived 不會將vrrp 實例分配給虛擬介面(例如eth0:0)。

因為當eth0消失時你做了一個service networking restartkeepalived。

您需要做的是在啟動 keepalived 之前配置介面或手動配置新介面,而不是重新啟動網路。您可以通過將新介面添加到“/etc/network/interfaces”然後執行ifup eth0:#.

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