How to configure bond in 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 网卡虚拟化方式
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
如果有类似上面的信息输出,说明已经支持了.
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
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
3 # vi /etc/modprobe.conf
编辑/etc/modprobe.conf 文件,加入如下一行内容,以使系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0
加入下列两行
alias bond0 bonding options bond0 miimon=100 mode=0
说明:
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
到这时已经配置完毕重新启动机器.
重启会看见以下信息就表示配置成功了
................
Bringing up interface bond0 OK Bringing up interface eth0 OK Bringing up interface eth1 OK
2、配置Bond 1 热备模式
特点:
1. 正在工作的网卡不正常后,切换到备用网卡,此时会中间几秒钟
2. 恢复不正常的网卡时,不会引发网络中断.
其他步骤一致,只在第3步骤,将mode设置成1即可.
alias bond0 bonding options bond0 miimon=100 mode=1
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Methods for using Chinese input in CentOS include: using the fcitx input method: install and enable fcitx, set shortcut keys, press the shortcut keys to switch input methods, and input pinyin to generate candidate words. Use iBus input method: Install and enable iBus, set shortcut keys, press the shortcut keys to switch input methods, and input pinyin to generate candidate words.

To read U disk files in CentOS 7, you need to first connect the U disk and confirm its device name. Then, use the following steps to read the file: Mount the USB flash drive: mount /dev/sdb1 /media/sdb1 (replace "/dev/sdb1" with the actual device name) Browse the USB flash drive file: ls /media/sdb1; cd /media /sdb1/directory; cat file name

There are two ways to enter the root authority of CentOS 7: use the sudo command: enter sudo su - in the terminal and enter the current user password. Log in directly as the root user: Select "Other" on the login screen, enter "root" and the root password. Note: Operate carefully with root privileges, perform tasks with sudo privileges, and change the root password regularly.

One can use the scp command to securely copy files between network hosts. It uses ssh for data transfer and authentication. Typical syntax is: scpfile1user@host:/path/to/dest/scp -r/path/to/source/user@host:/path/to/dest/scp exclude files I don't think you can when using scp command Filter or exclude files. However, there is a good workaround to exclude the file and copy it securely using ssh. This page explains how to filter or exclude files when copying directories recursively using scp. How to use rsync command to exclude files The syntax is: rsyncav-essh-

Solutions for forgotten CentOS passwords include: Single-user mode: Enter single-user mode and reset the password using passwd root. Rescue Mode: Boot from CentOS Live CD/USB, mount root partition and reset password. Remote access: Use SSH to connect remotely and reset the password with sudo passwd root.

After forgetting your CentOS username and password, there are two ways to restore access: Reset the root password: Restart the server, edit the kernel command line in the GRUB menu, add "rw init=/sysroot/bin/sh" and press Ctrl+x ;Mount the root file system and reset the password in single-user mode. Use rescue mode: Start the server from the CentOS installation ISO image, select rescue mode; mount the root file system, copy the chroot environment from the ISO image, reset the password, exit the chroot environment and restart the server.

CentOS 7 disables root permissions by default. You can enable it by following the following steps: Temporarily enable it: Enter "su root" on the terminal and enter the root password. Permanently enabled: Edit "/etc/ssh/sshd_config", change "PermitRootLogin no" to "yes", and restart the SSH service.

Three solutions for forgotten passwords in CentOS 7: Single-user mode: Restart the system, edit the kernel options, change ro to rw init=/sysroot/bin/sh, and use the passwd command to reset the root password. Rescue mode: Boot from the installation media, select rescue mode, mount the root file system, chroot to the root file system, and use the passwd command to reset the root password. Grub2 command line: Restart the system, press c to enter the command line, load the kernel, mount the root file system, chroot to the root file system, and use the passwd command to reset the root password.
