Table of Contents
CentOS configuration bond
1. What is network card bonding and its simple principle
1. balance-rr (mode=0)
2. active-backup (mode=1)
3. balance-xor (mode=2)
4. Broadcast (mode=3)
5, 802.3ad (mode=4)
6. balance-tlb (mode=5)
7, balance-alb (mode=6)
Home Operation and Maintenance CentOS How to configure bond in CentOS

How to configure bond in CentOS

Jun 15, 2021 am 11:14 AM
centos

The following tutorial column of centos will 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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1270
29
C# Tutorial
1250
24
What are the backup methods for GitLab on CentOS What are the backup methods for GitLab on CentOS Apr 14, 2025 pm 05:33 PM

Backup and Recovery Policy of GitLab under CentOS System In order to ensure data security and recoverability, GitLab on CentOS provides a variety of backup methods. This article will introduce several common backup methods, configuration parameters and recovery processes in detail to help you establish a complete GitLab backup and recovery strategy. 1. Manual backup Use the gitlab-rakegitlab:backup:create command to execute manual backup. This command backs up key information such as GitLab repository, database, users, user groups, keys, and permissions. The default backup file is stored in the /var/opt/gitlab/backups directory. You can modify /etc/gitlab

Centos shutdown command line Centos shutdown command line Apr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

Difference between centos and ubuntu Difference between centos and ubuntu Apr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

How to optimize CentOS HDFS configuration How to optimize CentOS HDFS configuration Apr 14, 2025 pm 07:15 PM

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

Centos configuration IP address Centos configuration IP address Apr 14, 2025 pm 09:06 PM

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

What are the common misunderstandings in CentOS HDFS configuration? What are the common misunderstandings in CentOS HDFS configuration? Apr 14, 2025 pm 07:12 PM

Common problems and solutions for Hadoop Distributed File System (HDFS) configuration under CentOS When building a HadoopHDFS cluster on CentOS, some common misconfigurations may lead to performance degradation, data loss and even the cluster cannot start. This article summarizes these common problems and their solutions to help you avoid these pitfalls and ensure the stability and efficient operation of your HDFS cluster. Rack-aware configuration error: Problem: Rack-aware information is not configured correctly, resulting in uneven distribution of data block replicas and increasing network load. Solution: Double check the rack-aware configuration in the hdfs-site.xml file and use hdfsdfsadmin-printTopo

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

How is the GPU support for PyTorch on CentOS How is the GPU support for PyTorch on CentOS Apr 14, 2025 pm 06:48 PM

Enable PyTorch GPU acceleration on CentOS system requires the installation of CUDA, cuDNN and GPU versions of PyTorch. The following steps will guide you through the process: CUDA and cuDNN installation determine CUDA version compatibility: Use the nvidia-smi command to view the CUDA version supported by your NVIDIA graphics card. For example, your MX450 graphics card may support CUDA11.1 or higher. Download and install CUDAToolkit: Visit the official website of NVIDIACUDAToolkit and download and install the corresponding version according to the highest CUDA version supported by your graphics card. Install cuDNN library:

See all articles