一、配置bond
1、ifcfg-bond0
# Broadcom Corporation NetXtreme BCM5720 Gigabit Ethernet PCIe
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.0.40.20
NETMASK=255.255.255.0
GATEWAY=10.0.40.254
USERCTL=no
2、ifcfg-eth0
# Broadcom Corporation NetXtreme BCM5720 Gigabit Ethernet PCIe
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
3、ifcfg-eth1
# Broadcom Corporation NetXtreme BCM5720 Gigabit Ethernet PCIe
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
4、/etc/modprobe.conf配置
alias eth0 tg3
alias eth1 tg3
alias eth2 bnx2
alias eth3 bnx2
alias scsi_hostadapter megaraid_sas
alias scsi_hostadapter1 ata_piix
alias scsi_hostadapter2 lpfc
alias usb0 cdc_ether
alias bond0 bonding
options bond0 miimon=100 mode=1
注:网卡绑定需要同型号网卡做bonding,如果eth0和eth2做绑定后,测试冗余性时网络故障后不会切换,但是查看cat /proc/net/bongding/bond0有绑定信息。
二、查看状态
1、重启网络
/etc/init.d/network restart
2、查看bond运行状态
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): 1
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:50:56:a2:4d:00
Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:a2:4d:01
三、测试bond
1、断开eth1网口
[root@test1 network-scripts]# ifdown eth0
2、查看bond状态,eth0已经掉线,现在eth1接管
[root@test1 network-scripts]# 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): 1
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:a2:4d:01
3、激活eth1
[root@test1 network-scripts]# ifup eth0
4、查看bond状态,eth0上线,但是网络流量还是在eth1上跑,eth0作为备份。(之前eth0是承载流量)
[root@test1 network-scripts]# 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): 1
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth1
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:a2:4d:01
Slave Interface: eth0
MII Status: up
Speed: 100 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:a2:4d:00