1. mode=0 (round-robin)
链路聚合:将两个或者更多数据信道结合成一个单一的信道,该信道以一个更高带宽的逻辑链路出现,链路聚合一般用来连接一个或多个带宽需求量大的设备,链路聚合是指将多个物理端口绑定在一起,成为一个逻辑端口,
以实现出、入流量的各成员端口中的负荷分担,当一个成员端口故障时,就停止发送报文,并根据负荷分担策略在剩下的链路中重新计算报文发送,端口恢复后重新计算报文发送的端口。链路聚合在增加带宽、实现链路传输弹性和冗余方面是很重要的技术。
逻辑链路的带宽增加了大约(n-1)倍,这里n为聚合的链路数,聚合后,可靠性大大提升,n条链路中只要有一条链路正常工作,这个链路就能正常工作,除此之外链路聚合可以实现负载均衡。
链路聚合有以下优点:
(1) 增加带宽。 链路聚合可以将多个链路捆绑在一个逻辑链路,捆绑后的链路带宽是每个独立链路的总和。
(2)提高网络连接的可靠性。链路聚合中的多个链路互为备份,当有一条链路断开,流量会自动在剩下的链路中重新分配。
[[email protected] ~]# cd /etc/sysconfig/network-scripts/ [[email protected] network-scripts]# vim ifcfg-eth1 DEVICE=eth1 BOOTPROTO=none TYPE=Ethernet PEERDNS=yes MASTER=bond0 SLAVE=yes [[email protected] network-scripts]# vim ifcfg-eth2 DEVICE=eth2 TYPE=Ethernet BOOTPROTO=none PEERDNS=yes ONBOOT=yes MASTER=bond0 SLAVE=yes [[email protected] network-scripts]# vim ifcfg-bond0 # 新建ifcfg-bond0文件 DEVICE=bond0 BOOTPROTO=none TYPE=Ethernet IPADDR=192.168.2.11 NETMASK=255.255.255.0 GATEWAY=192.168.2.1 DNS1=192.168.2.1 DNS2=114.114.114.114 [[email protected] network-scripts]# vim /etc/modprobe.d/bond0.conf3alias bond0 bondingoptions bond0 miimon=100 mode=0[[email protected] network-scripts]# service network restart正在关闭接口 bond0: [确定]关闭环回接口: [确定]弹出环回接口: [确定]弹出界面 bond0: [确定] 这样mode=0 (round-robin) 双网卡链路聚合建立完毕。
[[email protected] ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009) Bonding Mode: load balancing (round-robin) # 状态更改为round-robin 目前是两块网卡:eth1和eth2 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:7b:9f:8c Slave queue ID: 0 Slave Interface: eth2 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:7b:9f:96 Slave queue ID: 0
[[email protected] ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000 link/ether 00:0c:29:7b:9f:8c brd ff:ff:ff:ff:ff:ff 3: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000 link/ether 00:0c:29:7b:9f:8c brd ff:ff:ff:ff:ff:ff 4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP link/ether 00:0c:29:7b:9f:8c brd ff:ff:ff:ff:ff:ff inet 192.168.2.11/24 brd 192.168.2.255 scope global bond0 inet6 fe80::20c:29ff:fe7b:9f8c/64 scope link tentative dadfailed valid_lft forever preferred_lft forever mode 0下bond所绑定网卡的IP都被修改为一样的MAC地址,如果这些网卡都被接入同一个交换机,那么交换机的arp表里,这个mac地址对应的端口就有多个,那么交换机接受到这个mac地址的包应该往哪里发送呢?正常情况下mac地址是唯一的,一个mac地址对应多个端口肯定使交换机迷惑。所以在mode 0的模式下bond要连接交换机,交换机这几个端口应该采用聚合方式。
2. mode=1 (active-backup)
主备网卡,一个网卡处于活动状态,另一个网卡处于备份状态,所有流量都在主链路上处理,当活动链路(主链路)down掉时,启用备份网卡
以上网卡配置都相同。唯一修改的地方时模式的切换。
[[email protected] ~]# vim /etc/modprobe.d/bond0.conf alias bond0 bonding options bond0 miimon=100 mode=1
[[email protected] ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: eth1 # 当前活动网卡为eth1,备份网卡为eth2 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:7b:9f:8c Slave queue ID: 0 Slave Interface: eth2 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:7b:9f:96 Slave queue ID: 0
时间: 2024-10-24 03:00:16