Configure bond ip redundancy in CentOS

Source: Internet
Author: User

Configure bond ip redundancy in CentOS

There are 7 Bonding modes:

# DefineBOND_MODE_ROUNDROBIN 0 (balance-rr mode) Nic Load Balancing Mode

# DefineBOND_MODE_ACTIVEBACKUP 1 (active-backup mode) fault tolerance mode of the NIC

# DefineBOND_MODE_XOR 2 (balance-xor mode) requires switch support

# DefineBOND_MODE_BROADCAST 3 (broadcast mode)

# DefineBOND_MODE_8023AD 4 (IEEE 802.3ad dynamic link aggregation mode) requires switch support

# DefineBOND_MODE_TLB 5 adaptive transmission Load Balancing Mode

# DefineBOND_MODE_ALB 6 Nic virtualization Mode

The bonding module can work in two modes: Multi-master mode and master-slave mode, balance-rr and broadcast belong to multi-master mode while active-backup belongs to master-slave mode. (Balance-xor, balance-tlb and balance-alb) are also in Multi-master mode, the IEEE 802.3ad dynamic link aggregation mode (802.3ad) belongs to the active/standby mode.

These seven modes are described in detail:

1. balance-rr (mode = 0)

Round-robin policy: send packets on each slave interface sequentially from start to end. This mode provides load balancing and fault tolerance capabilities.

2. active-backup (mode = 1)

Active-Backup (active/standby) Policy: Only one slave is activated during binding. Other slave instances are activated only when the active slave interface fails. To avoid vswitch confusion, the bound MAC address is only visible on one external port. In bongding 2.6.2 and later versions, when a fault migration occurs in Master/slave Mode, bonding will send one or more gratuitous ARP packets to the newly activated slave. All VLAN interfaces configured on the primary salve interface and the interface of bonding send gratuitous ARP, as long as at least one IP address is configured on these interfaces. The gratuitous ARP sent on the VLAN interface will be attached with the appropriate VLAN id. This mode provides Fault Tolerance capabilities. primary option and incluented below will affect the behavior of this mode.

3. balance-xor (mode = 2)

XOR policy: Based on the selected transfer hash policy.

This mode provides load balancing and fault tolerance capabilities.

4. broadcast (mode = 3)

Broadcast Policy: transmits all packets on all slave interfaces. This mode provides Fault Tolerance capabilities.

5. 802.3ad (mode = 4)

IEEE 802.3ad dynamic link aggregation. Create an aggregation group that shares the same rate and duplex mode. All slave can be used to establish an aggregation link according to 802.3ad specifications. Salve's outbound selection depends on the transmitted hash policy. The default policy is a simple XOR policy, while the hash policy can be changed through the xmit_hash_policy option. Note that not all transmission policies are compatible with 802.3ad, especially the requirements for packet mis-ordering in Chapter 43.2.4 of the 802.3ad standard. Different individual implementations are often incompatible.

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

6. balance-tlb (mode = 5)

Adaptive transmission load balancing: Channel binding does not require special switch support. The distribution of outbound traffic depends on the current load of each slave (relative computing speed ). Incoming traffic is received from the current slave. If an error occurs when receiving the salve, other slave takes over the MAC address of the failed slave and continues to receive it.
Prerequisites:
The basic driver of each slave supports Ehtool to get the speed status.

7. balance-alb (mode = 6)

Adaptive Load Balancing: includes balance-tlb (mode 5) and load balancing for receiving IPV4 traffic, and does not require special switch support. The received Server Load balancer is implemented through ARP negotiation. The bonding driver intercepts ARP Replies (ARP response packets) sent by the local machine, and uses a hardware address of bond to rewrite the source address of ARP packets, this allows the server to use different hardware addresses for different devices. The incoming traffic of the Connection established on this server is also load balancing. When the local machine sends an ARP Request, the bonding driver copies and saves the IP information of the node through the ARP packet. When ARP Reply is received from another node, the bonding driver obtains the hardware address of the node and returns an ARP Reply containing the hardware address of the bound slave to the sent node. One problem with Server Load balancer that uses ARP negotiation is that each time an ARP packet is broadcast using the bond hardware address, all the data sent by other nodes is concentrated on one slave, when ARP is updated to all other nodes, each node learns the hardware address again, causing traffic redistribution. When a new Server Load balancer instance or an inactive server Load balancer instance is reactivated, the received traffic is reallocated. The received traffic load is the serial (rotation) distribution on the highest speed slave of bond.
When a link is reconnected or a new slave is added, bond reinitializes ARP Replies to all clients. The value of the updelay parameter must be equal to or greater than the forwarding delay value of the switch to avoid ARP Replies being blocked by the switch.
Prerequisites:
1. The basic driver of each slave supports Ehtool to get the speed status.

2. The basic driver supports resetting the hardware address when the device is turned on. Each slave must 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, check whether linux supports bonding. RHEL4 is supported by default. (most releases support this function)

# Modinfo bonding

Filename:/lib/modules/2.6.18-8. el5/kernel/drivers/net/bonding. ko

Author: Thomas Davis, tadavis@lbl.gov and other others

De. ion: Ethernet Channel Bonding Driver, v3.0.3

Version: 3.0.3

License: GPL

Srcversion: 2547D22885C2FDF28EF7D98

If the output is similar to the above information, it indicates that it is supported.

1. Configure Bond 0 Server Load balancer

Features:

1. Dual Network blocks work at the same time to achieve load balancing. If a network card is abnormal, the network will not be interrupted.

2. When you restore an abnormal Nic, it may interrupt the network for several seconds and then the dual NIC will work simultaneously.

1. Edit the virtual network interface configuration file and specify the nic ip Address

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. Add a gateway on bond0 to ensure that the default route is not faulty.

[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

Edit the NIC configuration file:

Vi ifcfg-eth0

DEVICE = eth0

BOOTPROTO = none

ONBOOT = yes

USERCTL = no

MASTER = bond0

SLAVE = yes

Edit another Nic configuration file:

Vi ifcfg-eth1

DEVICE = eth1

BOOTPROTO = none

ONBOOT = yes

USERCTL = no

MASTER = bond0

SLAVE = yes

3,

Edit the/etc/modprobe. conf file and add the following line to enable the system to load the bonding module at startup. The external virtual network interface device is bond0.

Add the following two rows

Alias bond0 bonding

Options bond0 miimon = 100 mode = 0

Note:

Miimon is used for link monitoring. For example: miimon = 100, The system monitors the link connection status every Ms. If one line fails, it is transferred to another line;

The value of mode indicates the working mode. There are four modes: 0, 1, and 2, which are commonly used: 0, 1.

Mode = 0 indicates that the load balancing (round-robin) method is load balancing, and both NICs work.

Mode = 1 indicates that fault-tolerance (active-backup) provides redundancy, working in the active/standby mode. That is to say, by default, only one network card works and the other is used for backup.

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

Add the following content

# The work sequence of the eht0 eth1 Nic only in hot standby mode.

Ifenslave bond0 eth0 eth1

After the configuration is complete, restart the machine.

The following information is displayed after restart, indicating that the configuration is successful.

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

Bringing up interface bond0 OK

Bringing up interface eth0 OK

Bringing up interface eth1 OK

2. Configure Bond 1 hot standby mode

Features:

1. When the network adapter is working abnormally, switch to the backup network adapter, which will take a few seconds

2. When an abnormal Nic is restored, the network will not be interrupted.

The other steps are the same. In Step 3rd, set mode to 1.

Alias bond0 bonding

Options bond0 miimon = 100 mode = 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.