一般我见过的公司有 做mode=4 的,接下来我要实践的是做mode=6 的一种模式(Bonding Mode: adaptive load balancing)
系统环境:
1
2
3
|
$
cat
/etc/issue
CentOS release 6.7 (Final)
Kernel \r on an \m
|
需要一个bond口 自定义创建
1
2
3
4
5
6
7
8
9
|
$
cat
/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BONDING_OPTS=
"mode=6 miimon=100"
BOOTPROTO=none
ONBOOT=
yes
IPADDR=
NETMASK=255.255.255.0
GATEWAY=
USERCTL=no
|
改变eth0 和 eth0 的配置
1
2
3
4
5
6
7
|
$
cat
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=
yes
MASTER=bond0
SLAVE=
yes
USERCTL=no
|
1
2
3
4
5
6
7
|
$
cat
/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=
yes
MASTER=bond0
SLAVE=
yes
USERCTL=no
|
在创建一个文件 并写入一行配置
1
2
|
$
cat
/etc/modprobe
.d
/bonding
.conf
alias
bond0 bonding
|
注意一定要加载了bonding模块,一般默认是加载的。可以用以下命令查看
1
2
|
$ lsmod |
grep
bonding
bonding 131724 0
|
加载命令(加载了就不需要打,打了也么关系)
1
|
modprobe bonding
|
重启网卡 /etc/init.d/network restart
测试命令:
ifocnfig -a
cat /proc/net/bonding/bond0
重要查看网络流量的信息
1
|
$
cat
/proc/net/bonding/bond0
|
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 24:6e:96:0b:35:b8
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 24:6e:96:0b:35:b9
Slave queue ID: 0
上述可以看到 当前Active的是 eth1
测试经验:
1 ifdown 其中一个口,其中一个起来(如果起来速度慢 一致ping bond地址 如果很慢 可能使交换机的收敛策略有关,要和你们网络工程师了解了)
2 直接reboot 机器看是否绑定也生效也正常
特点:
1 bond口的mac 地址和正在使用的Currently Active Slave 网卡地址样
1
2
3
4
|
$
ifconfig
-a |
grep
-i hw
bond0 Link encap:Ethernet HWaddr 24:6E:96:0B:36:00
eth0 Link encap:Ethernet HWaddr 24:6E:96:0B:36:01
eth1 Link encap:Ethernet HWaddr 24:6E:96:0B:36:00
|
2 流量是负载分担的
bond口流量=eth1 + eth0
3 交换机上不用做任何配置(mode=6 交换机上一定不要做port channel 端口绑定)
本文转自残剑博客51CTO博客,原文链接http://blog.51cto.com/cuidehua/1768388如需转载请自行联系原作者
cuizhiliang