多 bonding 使用不同 mode 方法

环境,

多网卡, 多 bond 设备,  需要使用不同的工作方式, 如下:

eth0  eth1  -> bond0  ->  mode 0  ( active-backup )

eth2, eth3  -> bond1  -> mode 1  (balance-rr)


参考:

[root@hh-yun-puppet-129021 kickstarts]# yum install -y kernel-doc

[root@hh-yun-puppet-129021 kickstarts]# rpm -ql kernel-doc | grep bonding.txt
/usr/share/doc/kernel-doc-2.6.32/Documentation/networking/bonding.txt


其中该文档描述

/etc/modprobe.d/bond.conf 需要具有下面的配置

<pre class="plain" name="code">alias bond0 bonding
options bond0 -o bond0 mode=balance-rr miimon=100

alias bond1 bonding
options bond1 -o bond1 mode=balance-alb miimon=50

 
 

但上述文档只能够针对 centos 5 或之前版本,  而文档也没有更新 centos 6, 7 下的方法

而 centos 6,7 将不可以使用 -o 参数进行参数定义,  另外,  假如把配置, 参数都写入 /etc/modprobe.d/bond.conf 如

alias bond0 bonding
options bond0 mode=balance-rr miimon=100

alias bond1 bonding
options bond1 mode=balance-alb miimon=50

看上去 bond0, bond1 可以启动,  但从内核参数显示,  上述的设备只会使用相同的工作模式,  不满足不同 bond 设备使用不同模式方法

参考:

[root@hh-yun-compute-130026 ~]# grep Mode /proc/net/bonding/bond0
Bonding Mode: load balancing (round-robin)
[root@hh-yun-compute-130026 ~]# grep Mode /proc/net/bonding/bond1
Bonding Mode: load balancing (round-robin)


centos 6, 7 上正确配置方法:

/etc/modprobe.d/bond.conf

alias bond0 bonding
alias bond1 bonding


/etc/sysconfig/network-scripts/ifcfg-bond0

BONDING_OPTS='mode=1 miimon=100'

/etc/sysconfig/network-scripts/ifcfg-bond1

BONDING_OPTS='mode=0 miimon=100'


另: 注意,  centos 7  下, 假如关闭 ipv6 模块使用,  那么 bond 模块也是无法正常使用的.


而 centos 7 已推荐使用 teamd 进行 bond 配置


teamd 与 bond 实现相同功能,  但新增不少新特性,  比较灵活,   相关信息自己看官方文旦


测试配置方法

[root@node147 network-scripts]# cat ifcfg-eth0
DEVICE="eth0"
DEVICETYPE=TeamPort
ONBOOT=yes
TEAM_MASTER=team0
TEAM_PORT_CONFIG='{"prio": 100}'

[root@node147 network-scripts]# cat ifcfg-eth1
DEVICE=eth1
DEVICETYPE=TeamPort
ONBOOT=yes
TEAM_MASTER=team0
TEAM_PORT_CONFIG='{"prio": 100}'

[root@node147 network-scripts]# cat ifcfg-eth2
DEVICE="eth2"
DEVICETYPE=TeamPort
ONBOOT=yes
TEAM_MASTER=team1
TEAM_PORT_CONFIG='{"prio": 100}'

[root@node147 network-scripts]# cat ifcfg-eth3
DEVICE="eth3"
DEVICETYPE=TeamPort
ONBOOT=yes
TEAM_MASTER=team1
TEAM_PORT_CONFIG='{"prio": 100}'


team 配置与 mode 配置

[root@node147 network-scripts]# cat ifcfg-team0
DEVICE=team0
DEVICETYPE=Team
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.48.147
GATEWAY=192.168.48.1
PREFIX=24
TEAM_CONFIG='{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}'

[root@node147 network-scripts]# cat ifcfg-team1
DEVICE=team1
DEVICETYPE=Team
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.0.0.147
PREFIX=24
TEAM_CONFIG='{"runner": {"name": "loadbalance"}, "link_watch": {"name": "ethtool"}}'

校验方法

[root@node147 network-scripts]# teamdctl -o -v team0 state dump
{"ports": {"eth0": {"ifinfo": {"dev_addr": "00:50:56:81:7e:82", "dev_addr_len": 6, "ifindex": 2, "ifname": "eth0"}, "link": {"duplex": "full", "speed": 10000, "up": true}, "link_watches": {"list": {"link_watch_0": {"delay_down": 0, "delay_up": 0, "name": "ethtool", "up": true}}, "up": true}}, "eth1": {"ifinfo": {"dev_addr": "00:50:56:81:7e:82", "dev_addr_len": 6, "ifindex": 3, "ifname": "eth1"}, "link": {"duplex": "full", "speed": 10000, "up": true}, "link_watches": {"list": {"link_watch_0": {"delay_down": 0, "delay_up": 0, "name": "ethtool", "up": true}}, "up": true}}}, "runner": {"active_port": "eth0"}, "setup": {"daemonized": false, "dbus_enabled": true, "debug_level": 0, "kernel_team_mode_name": "activebackup", "pid": 3191, "pid_file": "/var/run/teamd/team0.pid", "runner_name": "activebackup", "zmq_enabled": false}, "team_device": {"ifinfo": {"dev_addr": "00:50:56:81:7e:82", "dev_addr_len": 6, "ifindex": 8, "ifname": "team0"}}}


[root@node147 network-scripts]# teamdctl -o -v team1 state dump
{"ports": {"eth2": {"ifinfo": {"dev_addr": "00:50:56:81:7c:e7", "dev_addr_len": 6, "ifindex": 4, "ifname": "eth2"}, "link": {"duplex": "full", "speed": 10000, "up": true}, "link_watches": {"list": {"link_watch_0": {"delay_down": 0, "delay_up": 0, "name": "ethtool", "up": true}}, "up": true}}, "eth3": {"ifinfo": {"dev_addr": "00:50:56:81:7c:e7", "dev_addr_len": 6, "ifindex": 5, "ifname": "eth3"}, "link": {"duplex": "full", "speed": 10000, "up": true}, "link_watches": {"list": {"link_watch_0": {"delay_down": 0, "delay_up": 0, "name": "ethtool", "up": true}}, "up": true}}}, "setup": {"daemonized": false, "dbus_enabled": true, "debug_level": 0, "kernel_team_mode_name": "loadbalance", "pid": 3419, "pid_file": "/var/run/teamd/team1.pid", "runner_name": "loadbalance", "zmq_enabled": false}, "team_device": {"ifinfo": {"dev_addr": "00:50:56:81:7c:e7", "dev_addr_len": 6, "ifindex": 9, "ifname": "team1"}}}




你可能感兴趣的:(多 bonding 使用不同 mode 方法)