centos6.8 bond模式4配置延伸

mode 模式以及参数解释参考redhat 官方文档 
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Specific_Kernel_Module_Capabilities.html
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-networkscripts-interfaces-chan.html
Allows you to specify the bonding policy. The <value> can be one of:
balance-rr or 0 — Sets a round-robin policy for fault tolerance and load balancing. Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available.
active-backup or 1 — Sets an active-backup policy for fault tolerance. Transmissions are received and sent out via the first available bonded slave interface. Another bonded slave interface is only used if the active bonded slave interface fails.
balance-xor or 2 — Sets an XOR (exclusive-or) policy for fault tolerance and load balancing. Using this method, the interface matches up the incoming request's MAC address with the MAC address for one of the slave NICs. Once this link is established, transmissions are sent out sequentially beginning with the first available interface.
broadcast or 3 — Sets a broadcast policy for fault tolerance. All transmissions are sent on all slave interfaces.
802.3ad or 4 — Sets an IEEE 802.3ad dynamic link aggregation policy. Creates aggregation groups that share the same speed and duplex settings. Transmits and receives on all slaves in the active aggregator. Requires a switch that is 802.3ad compliant.
balance-tlb or 5 — Sets a Transmit Load Balancing (TLB) policy for fault tolerance and load balancing. The outgoing traffic is distributed according to the current load on each slave interface. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed slave. This mode is only suitable for local addresses known to the kernel bonding module and therefore cannot be used behind a bridge with virtual machines.
balance-alb or 6 — Sets an Adaptive Load Balancing (ALB) policy for fault tolerance and load balancing. Includes transmit and receive load balancing for IPv4 traffic. Receive load balancing is achieved through ARP negotiation. This mode is only suitable for local addresses known to the kernel bonding module and therefore cannot be used behind a bridge with virtual machines.

lacp_rate=<value>
slow or 0 — Default setting. This specifies that partners should transmit LACPDUs every 30 seconds.
fast or 1 — Specifies that partners should transmit LACPDUs every 1 second.


#查看是否加载
modprobe --first-time bonding
FATAL: Module bonding already in kernel.
#显示bonding 信息
modinfo bonding

#代表支持miimon这个参数
ethtool em1| grep "Link detected:"
Link detected: yes

#查看设备上存在的bond
cat /sys/class/net/bonding_masters

#1.测试 配置单网卡允许多个vlan通过 
Network 设备
interface Eth-Trunk100
description BOND-VLAN
port link-type trunk
port trunk allow-pass vlan 999

Server 设备 em2为例 例如vlan 999 需要创建 ifcfg-em2.vlan(编号) 本例 ifcfg-em2.999;如果还需创建其他vlan ifcfg-em2.vlan(编号)
ifcfg-em2
DEVICE=em2
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none

vi ifcfg-em2.999
DEVICE=em2.999
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.99.253
NETMASK=255.255.255.192
USERCTL=no
VLAN=yes #增加vlan

#2.测试配置 bond mode 4 (8023.ad)允许多个vlan通过 vlan999 和vlan2204;用bond0 em1-em2 物理网卡
Network 设备
interface Eth-Trunk100
description BOND-VLAN
port link-type trunk
port trunk allow-pass vlan 999 2204
mode lacp

lacp timeout fast

Server 设备
cat ifcfg-em1
DEVICE=em1
HWADDR=20:47:47:95:7C:4A
TYPE=Ethernet
UUID=ced63bdd-86fa-4f20-a896-d55f6d9aa864
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

cat ifcfg-em2
DEVICE=em2
HWADDR=20:47:47:95:7C:4C
TYPE=Ethernet
UUID=34ed2243-eac7-4c96-a94b-380d67f8c792
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

cat ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
BONDING_OPTS="miimon=100 mode=4 lacp_rate=fast"
NM_CONTROLLED=no

cat ifcfg-bond0.2000 # 2000是vlan2000
DEVICE=bond0.2000
BOOTPROTO=static
ONBOOT=yes
IPADDR=172.16.68.2
NETMASK=255.255.255.248
GATEWAY=172.16.68.1
BONDING_OPTS="miimon=100 mode=4 lacp_rate=1"
NM_CONTROLLED=no
VLAN=yes

cat ifcfg-bond0.999 #999 是vlan 999
DEVICE=bond0.999
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.99.253
NETMASK=255.255.255.192
BONDING_OPTS="miimon=100 mode=4 lacp_rate=1"
NM_CONTROLLED=no
VLAN=yes

#3.测试配置 br0 桥接网络,bond配置 mode 4
br0-----bond0 ---{em1+em2}

举例bond0.2000 对应br0
       bond0.999   对应br1

em1 em2 bond0 配置和#2步骤一样不再说明
cat ifcfg-br0
DEVICE=br0
ONBOOT=yes
TYPE=Bridge
IPADDR=172.16.68.2
NETMASK=255.255.255.248
GATEWAY=172.16.68.1
NM_CONTROLLED=no

cat ifcfg-bond0.2000
DEVICE=bond0.2000
BOOTPROTO=static
ONBOOT=yes
BONDING_OPTS="miimon=100 mode=4 lacp_rate=1"
NM_CONTROLLED=no
VLAN=yes
BRIDGE=br0
#cat ifcfg-bond0.999
DEVICE=bond0.999
BOOTPROTO=static
ONBOOT=yes
BONDING_OPTS="miimon=100 mode=4 lacp_rate=1"
NM_CONTROLLED=no
VLAN=yes
BRIDGE=br1 #新建桥接网卡 br1

[root@localhost network-scripts]# cat ifcfg-br1
DEVICE=br1
ONBOOT=yes
TYPE=Bridge
IPADDR=192.168.99.253
NETMASK=255.255.255.192
NM_CONTROLLED=no

查看目前生效的bond模式

cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

802.3ad info
LACP rate: fast
Aggregator selection policy (ad_select): stable
Active Aggregator Info:
Aggregator ID: 3
Number of ports: 2
Actor Key: 17
Partner Key: 25905
Partner Mac Address: 04:9f:ca:20:09:a0

Slave Interface: em1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 20:47:47:95:7c:4a
Aggregator ID: 3
Slave queue ID: 0

Slave Interface: em2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 20:47:47:95:7c:4c
Aggregator ID: 3
Slave queue ID: 0


备注:重启网卡服务包这个报错:
Bridge support not available: brctl not found
解决办法:
yum -y install bridge-utils

posted @ 2017-09-15 16:42  怪兽在行动  阅读(1266)  评论(0)    收藏  举报