原文:http://blog.chinaunix.net/uid-24540106-id-1643137.html

 

1、工作在模式0时

通过查看bond0的工作状态查询能详细的掌握bonding的工作情况,正常状态下的/proc/net/bonding/bond0文件:
[root@support ~]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:30:48:56:da:72

Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 00:30:48:56:da:73

从win7 ping,通过拔插网线查看结果,不存在丢包

通过日志查看网卡工作情况
[root@support ~]# tail -f /var/log/messages
May 29 08:01:41 support kernel: e1000: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX/TX
May 29 08:01:41 support kernel: bonding: bond0: link status definitely up for interface eth0.
May 29 08:01:48 support kernel: e1000: eth1 NIC Link is Down
May 29 08:01:48 support kernel: bonding: bond0: link status definitely down for interface eth1, disabling it
May 29 08:02:18 support kernel: e1000: eth1 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX/TX
May 29 08:02:18 support kernel: bonding: bond0: link status definitely up for interface eth1.
May 29 08:08:49 support kernel: e1000: eth0 NIC Link is Down
May 29 08:08:49 support kernel: bonding: bond0: link status definitely down for interface eth0, disabling it
May 29 08:08:56 support kernel: e1000: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX/TX
May 29 08:08:56 support kernel: bonding: bond0: link status definitely up for interface eth0.

2、工作在模式1时

正常状态下的/proc/net/bonding/bond0文件:
[root@support ~]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:30:48:56:da:72

Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:30:48:56:da:73

从win7 ping,通过拔插网线查看结果,发现在拔网线时,偶尔会存在丢掉一个包的情况。

通过日志查看网卡工作情况
[root@support ~]# tail -f /var/log/messages
May 29 08:25:24 support kernel: e1000: eth0 NIC Link is Down
May 29 08:25:24 support kernel: bonding: bond0: link status definitely down for interface eth0, disabling it
May 29 08:25:24 support kernel: bonding: bond0: making interface eth1 the new active one.
May 29 08:25:32 support kernel: e1000: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX/TX
May 29 08:25:32 support kernel: bonding: bond0: link status definitely up for interface eth0.
May 29 08:27:02 support kernel: e1000: eth1 NIC Link is Down
May 29 08:27:02 support kernel: bonding: bond0: link status definitely down for interface eth1, disabling it
May 29 08:27:02 support kernel: bonding: bond0: making interface eth0 the new active one.
May 29 08:27:48 support kernel: e1000: eth1 NIC Link is Up 100 Mbps Full Duplex, Flow Control: RX/TX
May 29 08:27:48 support kernel: bonding: bond0: link status definitely up for interface eth1.

小结

在 测试过程中,发现丢包情况与设备有关,老式的网新易得服务器上做测试时,两个网卡无论是接到同一个二层交换机,还是分别接到两个二层交换机,在拔插网线, 偶尔会出现丢掉一个包的情况。但是在戴尔R710上,当使用模式1时,丢包比较多,甚至在被其他计算机ping时,会出现ping不同的情况。

另外,模式0只是实现了简单的负载均衡及冗余备份。如果要实现高效的负载均衡,提高网络流量,需设置成模式4,而这需要交换机的支持,牵涉到交换机的链路聚合(LACP)功能。有待日后再研究。