如果我在命令行上使用手动设置(按照内核指令 ),我可以正确设置我的networking连接:
# modprobe bonding mode=4 miimon=100 # ifconfig bond0 up # ip link set eno1 master bond0 # ip link set eno2 master bond0
为了logging,所使用的交换机是Cisco Nexus 2248,并且我没有指定IP地址,因为还有一个额外的802.1q层(configuration文件的存在或缺失对此问题没有影响)。
问题是我无法创build一个正确的/etc/network/interfaces文件,以便在启动时自动完成此操作。 在ifenslave软件包的不同版本之间存在很多混淆,特别是其文档,以及如何避免使用ifup时的竞争条件。 不pipe以前的Ubuntu版本如何工作,现在已经不复存在了。 如果系统变得更加混乱,我不会感到惊讶。 基本上,无论我尝试什么,我的脚本在启动时都会卡住,我必须在启动过程完成之前等待一到五分钟。
这是我可以达到的最好的:
auto lo iface lo inet loopback allow-bond0 eno1 iface eno1 inet manual bond-master bond0 allow-bond0 eno2 iface eno2 inet manual bond-master bond0 auto bond0 iface bond0 inet manual bond-mode 4 bond-slaves eno1 eno2 bond-miimon 100
在启动的时候启动一个分钟的bond0(因为bond0正在等待至less有一个奴隶被提出,所以从未发生,所以它超时),但是一旦系统启动,使用ifup eno1工作, bond0开始正常工作。
如果我指定了auto eno1 ,那么启动过程将停止五分钟,bond0永远不会正确地启动,并且尝试使用ifdown eno1将会卡住,因为它正在等待/run/network/wherever某个locking(无法记住确切的文件,并已经足够频繁地重新启动这台机器),这似乎表明,是的,我遇到了一个竞争条件,ifup永远卡住eno1。
有没有人有最新的Ubuntu的工作解决scheme?
我有一个工作在16.04(Linux的4.4.0-22)上运行的设置非常相似。
除了LACP率和1G(eno1 +)与10G SFP +(eno49 +)之外,最大的区别似乎是使用auto bond0 。
# /etc/modprobe.d/bonding.conf alias bond0 bonding options bonding mode=4 miimon=100 lacp_rate=1
其中一些选项可能是多余的。
# /etc/network/interfaces auto eno49 iface eno49 inet manual bond-master bond0 auto eno50 iface eno50 inet manual bond-master bond0 auto bond0 iface bond0 inet static address 10.0.0.1 netmask 255.255.255.0 bond-slaves eno49 eno50 bond-mode 4 bond-miimon 100 bond-lacp-rate 1
在开机时没有看到任何摊位。 做一个systemctl restart networking产生了几秒钟的短暂等待,但没有更多。
$ systemd-analyze Startup finished in 2.344s (kernel) + 1.658s (userspace) = 4.002s
我也在16.04有一个工作绑定设置,我的设置在12.04以后在Ubuntu上运行良好,保持不变。
我的解决scheme与@timss的解决scheme几乎是一样的,但我从来不需要搞乱/etc/modprobe.d/bonding.conf,并且随着时间的推移我发现了一些必要的细节。结束。
下面,我有bond0上的接口eth2-eth5
auto eth2 iface eth2 inet manual bond-master bond0 auto eth3 iface eth3 inet manual bond-master bond0 auto eth4 iface eth4 inet manual bond-master bond0 auto eth5 iface eth5 inet manual bond-master bond0 auto bond0 iface bond0 inet manual hwaddress ether 00:00:00:00:00:00 <= ADD MAC of one of the bonded interfaces here bond-slaves eth2 eth3 eth4 eth5 bond-miimon 100 bond-mode 802.3ad bond-lacp-rate 1 xmit_hash_policy layer3+4
注释:
即使从端口没有准备好始终configuration它,您也必须允许系统调出绑定接口,“bond-slaves none”是这样做的。 那么正确的configuration举例:
allow-hotplug eno1 iface eno1 inet manual bond-master bond0 allow-hotplug eno2 iface eno2 inet manual bond-master bond0 auto bond0 iface bond0 inet manual bond-mode 802.3ad bond-miimon 100 bond-lacp-rate fast bond-slaves none bond-xmit_hash_policy layer2+3
我想出了一个丑陋的黑客,我宁愿没有得到任何的信任,但希望它会帮助人们开始,并在等待正确的答案/修复时做更重要的事情:
auto bond0 iface bond0 inet manual pre-up modprobe bonding mode=4 miimon=100 pre-up ifconfig bond0 up pre-up ip link set eno1 master bond0 pre-up ip link set eno2 master bond0 up /bin/true down /bin/true post-down ip link set eno2 nomaster post-down ip link set eno1 nomaster post-down ifconfig bond0 down post-down rmmod bonding
它几乎包括重载整个ifup脚本。 在执行ifdown bond0时会显示错误消息,但是ifdown会继续执行剩余的脚本,并且系统最终会清理干净(可以通过ifup / ifdown循环),所以我不觉得有必要修复这个问题。
而且,由于从服务器在主服务器的脚本中处理,因此不需要在configuration文件中声明它们。