LINUX Dual NIC Binding Technology Realize load balancing

xiaoxiao2021-03-06  168

Keep the high availability of the server's high availability. NIC (NIC can.) Important factors in an enterprise-level IT environment.) Binding technology helps to ensure that high availability is the most important point of which is server network connectivity and provides other advantages to improve network

We look at the Linux in this introduction looks a single line link polymerization into a logical link EtherChannel technology. The earliest application in Linu is in the cluster - discusses the principle of bonding, under normal circumstances, NIC only The data frame is filtered off to reduce the driving, and the data frame of the drive set MAC can be accepted in the network. Then the double network card binding is to use two network Ethernet interface equipment, and the popular point is working. In fact, this technology also uses this beowulf in the kernel of the 2.4.x of Sun and Cisx, in order to improve the cluster node What is Bonding that requires a burden on the Mac Address program from the NIC's mixed purpose. However, the NIC also supports another, such as tcpdump, is the MAC address running in the program, transmitting the two network cards to the Bond driver card virtual into a network card, this aggregation is the same IP address of the two network cards And Co has already existed, called Trunking and technology, known as bonding. Data transmission of Bonding skills is designed. Let's talk about the PROMISC mode. We know that it is an Ethernet frame of your own Mac, and for other other models called hybrid PROMISC mode this mode. Bonding is also running in this MAC address change, which can receive special processes.

After saying theory of half a day, it is actually a simple configuration, a total of four steps:

The experiment's operating system is Redhat Linux Enterprise 3.0

Binding Prerequisites: Chipset models, and network cards should have their own independent BIOS chip

1. Edit the virtual network interface configuration file, specify the network card IP

Vi / etc / sysconfig / network-scripts / ifcfg-bond0

[root @ rhas-13 root] # cp / etc / sysconfig / network-scripts / ifcfg-eth0 IFCFG-BOND0

2 #vi ifcfg-bond0

Change the first line to device = bond0

# Cat ifcfg-bond0

Device = bond0

Bootproto = static

Ipaddr = 172.31.0.13

Netmask = 255.255.252.0

Broadcast = 172.31.3.254

Onboot = YES

TYPE = Ethernet

Here you need ideas, do not specify in the IP Adapter (Bonding) of a single network card. Address, subnet mask or network card ID. Specify the above information to the virtual

[root @ rhas-13 network-scripts] # ​​Cat ifcfg-eth0

Device = eth0

Onboot = YES

Bootproto = DHCP

[root @ rhas-13 network-scripts] # ​​Cat ifcfg-eth1

Device = eth0

Onboot = YES

Bootproto = DHCP

3 # vi /etc/modules.conf

Edit /etc/modules.co block, external virtual network interface device NF file, add the following line content, for BOND0 to make the system load Bonding mode when starting

Join the following two lines

Alias ​​bond0 bonding

Options bond0 miimon = 100 mod = 1

Note: MIIMON is used to enter the connection state, if there is a line 1, 2, 3 modes, commonly used 0 row links. For example, miimon = 1 will transfer to another line; Mode, 1. 00, then the system monitors the value of the primary chain every 100 ms represents the working mode, he has a total of 0, and Mode = 0 indicates that load balancing (Round-Robin) is a load balancing mode, and the two network cards work.

Mode = 1 Represents Fault-Tolerance (Activ, that is, only one network card e-backup is provided by default, providing redundant functions, working mode is the workfield for the active and standby, and the other is backed up.

Bonding can only provide link monitoring, that is, from the main link Down, the switch itself does not have the link to the switch to switch. If only the switch is outside, then Bonding will think that there is no problem with the link.

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

Join two lines

ifenslave bond0 eth0 Eth1

Route Add -Net 172.31.3.254 Netmask 255.255.255.0 bond0

The restart of the machine has been configured until this time.

The restart will see the following information means the configuration is successful.

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

Bringing Up Interface Bond0 OK

Bringing Up Interface Eth0 OK

Bringing Up Interface Eth1 OK

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

Below we discuss the following modes of 0, 1

Mode = 1 In the active preparation mode, then Eth1 as a backup network card is NO ARP

[root @ rhas-13 network-scripts] # ​​ifconfig verifies the configuration information of the NIC

Bond0 Link ENCAP: Ethernet Hwaddr00: 0e: 7f: 25: D9: 8B

inet addr: 172.31.0.13 bcast: 172.31.3.255 Mask: 255.255.252.0

Up Broadcast RunningMaster Multicast MTU: 1500 Metric: 1

RX Packets: 18495 Errors: 0 Dropped: 0 overruns: 0 frame: 0

TX Packets: 480 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0

Collisions: 0 TXQuelelen: 0

RX bytes: 1587253 (1.5 MB) TX bytes: 89642 (87.5 KB)

Eth0 Link Encap: Ethernet Hwaddr 00:0e: 7f: 25: D9: 8B

inet addr: 172.31.0.13 bcast: 172.31.3.255 Mask: 255.255.252.0

Up Broadcast Running Slave Multicast MTU: 1500 metric: 1

RX Packets: 9572 Errors: 0 Dropped: 0 overruns: 0 frame: 0

TX Packets: 480 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0

Collisions: 0 TXQuelelen: 1000

Rx bytes: 833514 (813.9 KB) TX bytes: 89642 (87.5 kB)

Interrupt: 11

Eth1 Link Encap: Ethernet Hwaddr 00:0e: 7f: 25: D9: 8B

inet addr: 172.31.0.13 bcast: 172.31.3.255 Mask: 255.255.252.0

Up Broadcast Running Noarp Slavemulticast MTU: 1500 Metric: 1

RX Packets: 8923 Errors: 0 Dropped: 0 overruns: 0 frame: 0

TX Packets: 0 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0

Collisions: 0 TXQuelelen: 1000

Rx Bytes: 753739 (736.0 KB) TX bytes: 0 (0.0 B)

Interrupt: 15

That is to say that in the active and standby mode, the system will be in accordance with the function of CAT / ETC / RC effect. Next, when a network interface fails (for example, the order of the network card in .d / rc.local, the main switch is powered down) No return to the network work, the machine can still serve the external service, playing

In Mode = 0 load balancing mode, he can provide twice the bandwidth, let's take a look at the network card configuration information.

[root @ rhas-13 root] # ifconfig

Bond0 Link Encap: Ethernet Hwaddr 00:0e: 7f: 25: D9: 8B

inet addr: 172.31.0.13 bcast: 172.31.3.255 Mask: 255.255.252.0

Up Broadcast RunningMaster Multicast MTU: 1500 Metric: 1

RX Packets: 2817 Errors: 0 Dropped: 0 overruns: 0 frame: 0

TX Packets: 95 Errors: 0 Dropped: 0overruns: 0 Carrier: 0

Collisions: 0 TXQuelelen: 0

RX bytes: 226957 (221.6 kB) TX bytes: 15266 (14.9 kB)

Eth0 Link Encap: Ethernet Hwaddr 00:0e: 7f: 25: D9: 8B

inet addr: 172.31.0.13 bcast: 172.31.3.255 Mask: 255.255.252.0

Up Broadcast Runningslave MultiCast MTU: 1500 Metric: 1

RX Packets: 1406 Errors: 0 Dropped: 0 overruns: 0 Frame: 0

TX Packets: 48 Errors: 0 Dropped: 0 overruns: 0 Carrier: 0

Collisions: 0 TXQuelelen: 1000

RX bytes: 113967 (111.2 KB) TX bytes: 7268 (7.0 kB)

Interrupt: 11

Eth1 Link Encap: Ethernet Hwaddr 00:0e: 7f: 25: D9: 8B

inet addr: 172.31.0.13 bcast: 172.31.3.255 Mask: 255.255.252.0

Up Broadcast Running Slave Multicast MTU: 1500 metric: 1

RX Packets: 1411 Errors: 0 Dropped: 0 overruns: 0 Frame: 0

TX Packets: 47 Errors: 0 Dropped: 0overRuns: 0 Carrier: 0

Collisions: 0 TXQuelelen: 1000

Rx bytes: 112990 (110.3 KB) TX bytes: 7998 (7.8 kB)

Interrupt: 15

In this case, a network card is invalid, which is only a decrease in the export bandwidth of the server, nor does it affect the network.

Master Bonding's working status by viewing the working status query of Bond0

[root @ rhas-13 bonding] # cat / proc / net / bonding / bond0

Bonding.c: v2.4.1 (September 15, 2003)

Bonding Mode: loading balancing (runk)

MII STATUS: UP

MII Polling Interval (MS): 0

UP DELAY (MS): 0

Down DELAY (MS): 0

Multicast Mode: All Slaves

Slave Interface: Eth1

MII STATUS: UP

Link Failure Count: 0

Permanent HW Addr: 00:0e: 7f: 25: D9: 8A

Slave Interface: Eth0

MII STATUS: UP

Link Failure Count: 0

Permanent HW Addr: 00:0e: 7f: 25: D9: 8B

转载请注明原文地址:https://www.9cbs.com/read-128117.html

New Post(0)