How to configure bond in CentOS

藏色散人
Release: 2021-06-15 11:15:20
forward
5009 people have browsed it

The following tutorial column ofcentoswill introduce to you how to configure bond in CentOS. I hope it will be helpful to friends in need!

CentOS configuration bond

1. What is network card bonding and its simple principle

Network card bonding is also called "network card bundling", which is to use multiple physical network cards to become a virtual network card. A network card to provide load balancing or redundancy and increase bandwidth. When a network card breaks down, the business will not be affected. This aggregated device appears to be a single Ethernet interface device, that is, these network cards have the same IP address and the parallel links are aggregated into one logical link. This technology is called Trunking and Etherchannel technology in network companies such as Cisco. This technology is called bonding in the Linux 2.4.x kernel.

There are 7 modes of Bonding:

#defineBOND_MODE_ROUNDROBIN 0 (balance-rr模式)网卡的负载均衡模式 #defineBOND_MODE_ACTIVEBACKUP 1 (active-backup模式)网卡的容错模式 #defineBOND_MODE_XOR 2 (balance-xor模式)需要交换机支持 #defineBOND_MODE_BROADCAST 3 (broadcast模式) #defineBOND_MODE_8023AD 4 (IEEE 802.3ad动态链路聚合模式)需要交换机支持 #defineBOND_MODE_TLB 5 自适应传输负载均衡模式 #defineBOND_MODE_ALB 6 网卡虚拟化方式
Copy after login

All working modes of the bonding module can be divided into two categories: multi-master working mode and active-standby working mode. balance-rr and broadcast belong to the multi-master working mode and active-backup belongs to the active-backup mode. Operating mode. (balance-xor, adaptive transmission load balancing mode (balance-tlb) and adaptive load balancing mode (balance-alb) also belong to the multi-master working mode, and IEEE 802.3ad dynamic link aggregation mode (802.3ad) belongs to the active and backup mode type working mode.

Details introduction to these 7 modes:

1. balance-rr (mode=0)

Round-robin strategy: from beginning to end Send data packets sequentially on each slave interface. This mode provides load balancing and fault tolerance capabilities.

2. active-backup (mode=1)

Active-backup (active-backup) ) Policy: In a bond, only one slave is activated. Other slaves will be activated if and only if the active slave interface fails. In order to avoid switch chaos, the bound MAC address is only visible on one external port at this time. In In bonding version 2.6.2 and later, when a failover occurs in active-standby mode, bonding will send one or more gratuitous ARPs to the newly activated slave. Bonding's main salve interface and configuration on the interface All VLAN interfaces will send gratuitous ARP, as long as at least one IP address is configured on these interfaces. Gratuitous ARP sent on the VLAN interface will be accompanied by the appropriate VLAN ID. This mode provides fault tolerance, the primary option, documented below will affect Behavior of this mode.

3. balance-xor (mode=2)

XOR strategy: Based on the selected transmission hash strategy.

This mode provides load balancing and Fault tolerance.

4. Broadcast (mode=3)

Broadcast strategy: transmit all packets on all slave interfaces. This mode provides fault tolerance.

5, 802.3ad (mode=4)

IEEE 802.3ad dynamic link aggregation. Create aggregation groups that share the same speed and duplex mode. All slaves can be used to establish aggregate links according to the 802.3ad specification. Salve's outbound selection depends on the hash policy of the transmission. The default policy is a simple XOR policy, and the hash policy can be changed through the xmit_hash_policy option. It should be noted that not all transmission strategies are compatible with 802.3ad, especially the packet mis-ordering requirements in Chapter 43.2.4 of the 802.3ad standard. Implementations of different individuals often have great incompatibilities.

prerequisites:
1. The basic driver of each slave supports Ehtool to obtain the rate and duplex status.
2. The switch supports IEEE 802.3ad dynamic link aggregation. Most switches require some configuration to enable 802.3ad mode.

6. balance-tlb (mode=5)

Adaptive transmission load balancing: Channel binding does not require special switch support. The distribution of egress traffic depends on the current load of each slave (calculating relative speed). Import traffic is received from the current slave. If there is an error in receiving the salve, other slaves will continue to receive the MAC address of the slave that failed to take over.
prerequisites:
The basic driver of each slave supports Ehtool to obtain the rate status.

7, balance-alb (mode=6)

Adaptive load balancing: including balance-tlb (mode 5) and receiving load balancing for IPV4 traffic , and no special switch support is required. Receive load balancing is achieved through ARP negotiation. The bonding driver intercepts ARP Replies (ARP response messages) sent by the local machine and rewrites the source address of the ARP message with the hardware address of a slave of the bond, so that the server uses different hardware addresses for different devices. The incoming traffic of connections established by this server is also load balanced. When the machine sends an ARP Request, the bonding driver copies and saves the node's IP information through the ARP message. When receiving an ARP Reply from another node, the bonding driver obtains the node's hardware address and responds with an ARP Reply containing the bound slave's hardware address to the sending node. One problem with load balancing using ARP negotiation is that every time the bond's hardware address is used to broadcast an ARP message, all the data sent by other nodes will be concentrated on one slave. When processing ARP updates to all other nodes, each node will Hardware addresses are relearned, resulting in traffic redistribution. When a new slave is added or an inactive slave is reactivated, the received traffic will also be redistributed. The receive traffic load is distributed serially (round-robin) on a set of slaves with the highest rate in the bond.
When a link is reconnected or a new slave is added, bond will reinitialize ARP Replies to all clients. The value of the updelay parameter must be equal to or greater than the forwarding delay of the switch to prevent ARP Replies from being blocked by the switch.
prerequisites:
1. The basic driver of each slave supports Ehtool to obtain the rate status.

2. The basic driver supports resetting the hardware address when the device is turned on. Each slave is also required to have a unique hardware address. If curr_active_slave fails, its hardware address is replaced by the newly selected curr_active_slave hardware address.

Configure Bond0 and Bond1 on CentOS:

First of all, you need to check whether linux supports bonding. RHEL4 already supports it by default. (Most distributions support it)

# modinfo bonding filename: /lib/modules/2.6.18-8.el5/kernel/drivers/net/bonding/bonding.ko author: Thomas Davis, tadavis@lbl.gov and many others de.ion: Ethernet Channel Bonding Driver, v3.0.3 version: 3.0.3 license: GPL srcversion: 2547D22885C2FDF28EF7D98
Copy after login

如果有类似上面的信息输出,说明已经支持了.

1、配置Bond 0 负载均衡

特点:

1. 双网块同时工作,实现负载均衡,某一网卡不正常时,不会引发网络中断.

2. 恢复不能正常工作的网卡时,会引发网络中断几秒,然后双网卡同时工作.

1.编辑虚拟网络接口配置文件,指定网卡IP

cp /etc/sysconfig/network-scripts/ifcfg-lo ifcfg-bond0 vi ifcfg-bond0 DEVICE=bond0 IPADDR=10.10.10.1 NETMASK=255.255.255.0 NETWORK=10.10.10.0 BROADCAST=10.10.10.255 ONBOOT=yes BOOTPROTO=none USERCTL=no GATEWAY=192.168.0.1
Copy after login

2.在bond0上添加网关,是确保默认路由无故障

[root@Linux ~]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.0 * 255.255.255.0 U 0 0 0 bond0 10.0.0.0 * 255.255.255.0 U 0 0 0 eth0 10.0.0.0 * 255.255.255.0 U 0 0 0 eth1 169.254.0.0 * 255.255.0.0 U 0 0 0 bond0 default 10.0.0.1 0.0.0.0 UG 0 0 0 bond0 vi ifcfg-eth0 DEVICE=eth0 BOOTPROTO=none ONBOOT=yes USERCTL=no MASTER=bond0 SLAVE=yes vi ifcfg-eth1 DEVICE=eth1 BOOTPROTO=none ONBOOT=yes USERCTL=no MASTER=bond0 SLAVE=yes
Copy after login

3 # vi /etc/modprobe.conf

编辑/etc/modprobe.conf 文件,加入如下一行内容,以使系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0

加入下列两行

alias bond0 bonding options bond0 miimon=100 mode=0
Copy after login

说明:

miimon是用来进行链路监测的。 比如:miimon=100,那么系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路;

mode的值表示工作模式,他共有0,1,2,3四种模式,常用的为0,1两种。

mode=0表示load balancing (round-robin)为负载均衡方式,两块网卡都工作。

mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份.

4 # vi /etc/rc.d/rc.local

加入以下内容

# 仅在热备模式下,eht0 eth1网卡的工作顺序. ifenslave bond0 eth0 eth1
Copy after login

到这时已经配置完毕重新启动机器.

重启会看见以下信息就表示配置成功了

................

Bringing up interface bond0 OK Bringing up interface eth0 OK Bringing up interface eth1 OK
Copy after login

2、配置Bond 1 热备模式

特点:

1. 正在工作的网卡不正常后,切换到备用网卡,此时会中间几秒钟

2. 恢复不正常的网卡时,不会引发网络中断.

其他步骤一致,只在第3步骤,将mode设置成1即可.

alias bond0 bonding options bond0 miimon=100 mode=1
Copy after login

The above is the detailed content of How to configure bond in CentOS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!