Reposted: Multi-network cards in the Linux environment use an IP to improve efficiency - Bonding

xiaoxiao2021-03-06  95

Using a multi-network card in the Linux environment to improve efficiency - Bonding

Http://bbs.chinaunix.net/forum/4/20041026/432364.html

[Foreword] Because I have seen a Bonding article very early, I participated in the discussion in the past few days, so I found it online. Some of this information is outdated, for example, RedHat7.3 has been pre-compiled Bonding, but it is always complete, and the reference value is high. In addition, it is important to say that Linux 2.4.18's bonding is some problem. It is recommended to upgrade the kernel to 2.4.20 before use. Just, I also have Intel and 3Com's network card. When you find a day, you will be able to use it, and you will report the result. [Practice] Bash-2.05a # uname -SRM Linux 2.4.18-3 i686 bash-2.05a # insmod bonding using /lib/Modules/2.4.18-3/kernel/drivers/net/bonding.o Warning: / lib / modules / 2.0.4.18-3/kernel/drivers/net/bonding.o parameter max_bonds Has Max

Install ifnslave.c: # gcc -o2 -s -o ifenslave ifenslave.c # cp ifenslave / sbin / ifenslave 3) Configuring the content system reference to the content of the module parameters. First, you need to add as follows in /etc/conf.modules: Alias ​​Bond0 Bonding uses standard publishing techniques to define Bond0 network interfaces, for example in the RedHat release, add IFCFG-BOND0 in the / etc / sysconfig / network-scripts directory file: DEVICE = IPADDR NETMASK NETWORK BROADCAST ONBOOT BOOTPROTO USERCTL = no bond0 = 192.168.1.1 = 255.255.255.0 = 192.168.1.0 = 192.168.1.255 = yes = none (using the appropriate value to substitute IP address 192.168.1) all belong bond The interface movement must be defined as slave or master. For example, in Redhat, if you want to define Eth0 and Eth1 as part of the interface BOND0, then their configuration files (IFCFG-ETH0, IFCFG-Eth1, etc.) are as follows: device = eth0 userctl = no onboot = yes Master = bond0 slave = yes bootproto = NONE (using device = Eth1 for Eth1; if you define bond2, use Master = Bond1). If the management tool supports you can restart the network subsystem or just start the Bonding device, you will restart your machine. (For RedHat release, using `ifup bond0 'or` /etc/rc.d/init.d/network restart') If your release is not supported to define Master / Slave in a network interface configuration, you need to use The following command manually configures bonding device: # / sbin / ifconfig bond0 192.168.1.1 up # / sbin / ifnslave bond0 Eth0 # / sbin / ifnslave bond0 Eth1 (Defining parameters such as the IP address according to the network) Of course, these commands can be defined For a script for easy execution. 4) Module parameters below the module parameters may be delivered: MODE = 5 (default rotation mode Round Robin Policy), or 1 (hot backup mode), refer to the following HA portion to get more information. MIIMON = integer value, define the MII link monitoring frequency (unit frequency). The default is 0, indicating the closure link monitoring. If you want to use link monitoring, a suitable value is 100. More information is obtained from the reference HA section. Downdlay = When the link fault is found, the integer value specified herein defines the delay of a link (milliseconds). Must be MIIMON's integer times. The default is 0. More information is obtained from the reference HA section. Updelay = When detects the "Link UP" state, the integer values ​​specified here define the latency of an enabled link. Must be MIIMON's integer times. The default is 0. More information is obtained from the reference HA section. If you need to define multiple Bonding devices, the driver must be loaded multiple times.

For example, for the case of two Bonding devices, / etc / conf.modlues must include the following: Alias ​​Bond0 bond0 miimon = 100 options bond1 -o bonding1 miimon = 100 5) Test configuration can be used through the ifconfig command Monitor configuration and transmission policies, such as the rotation strategy, you should get the following information: [root] # / sbin / ifconfig bond0 link encap: Ethernet Hwaddr 00: C0: F0: 1F: 37: B4 inet addr: xxx.xxx.xxx . Yyy Bcast: 1500 metric: 1 RX Packets: 0 Dropped: 0 Overruns: 0 Frame: 0 TX Packets: 3286647 Errors: 1 Dropped: 0 overruns: 1 Carrier: 0 Collisions: 0 TXQueuelen: 0 ETHERNET HWADDR 00: C0: F0: 1F: 37: B4 INET Addr: xxx.xxx.xxx.yyy bcast: xxx.xxx.xxx. 255 Mask: 255.255.252.0 UP BROADCAST RUNNING SLAVE MULTICAST MTU: 1500 Metric: 1 RX packets: 3573025 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 1643167 errors: 1 dropped: 0 overruns: 1 carrier: 0 collisions : 0 TXQuelelen: 100 Interrupt: 10 Base Address: 0x1080 Eth1 Link Encap: Ethernet Hwaddr 00: C0: F0: 1F: 37: B4 inet addr: xxx.xxx.xxx.Yyy Bcast: xxx.xxx.xxx.255 Mask: 255.25 5.252.0 UP BROADCAST RUNNING SLAVE MULTICAST MTU: 1500 Metric: 1 RX packets: 3651769 errors: 0 dropped: 0 overruns: 0 frame: 0 TX packets: 1643480 errors: 0 dropped: 0 overruns: 0 carrier: 0 collisions: 0 txqueuelen : 100 Interrupt: 9 Base Address: 0x1400 Question: 1. Bonding will conflict with SMP? No, the old 2.0.xx version is conflicted with SMP usage, and the new kernel does not have problems. 2. Which type of NIC can use as a bonding? Any type of NIC (can even use a mixed type NIC - an Intel's therexpress PRO / 100 and A 3com 3C905B), even two Gigabit Ethernet card Bonds are used together. 3. How many bonding devices can I have? Corresponding to a module loaded, you can have a Bonding device, the reference module parameters are available to understand how to implement. 4. How many Salve NIC can a Bonding device? The number of network cards that can be supported by Linux, the number of network cards can be plugged in.

5. What happens when a SLAVE link is faulty? If your Ethernet card supports MII status monitoring, and MII monitoring has been used in the drive (the contents of the reference module parameter), then unfortunate results will not occur. This version of the Bonding driver can get MII information and to enable or disable a SLAVE network card according to the link status. More information is obtained from the reference HA section. All the soil drivers that cannot be reported to their link status cannot be well dealt with. Bonding drivers cannot transmit datagrams continuously, causing some datagrams to lose. Rebirth may cause serious performance issues (if a net card is lost, it may have a serious performance impact on TCP or UDP). 6. Can Bonding be used as high availability items? Of course, if you use MII monitoring, and all your NIC drivers support MII link status reports. Refer to the part of the HA. 7. Which type of Switches / Systems can Bonding applies? In the rotation mode, it will work together with the Trunking system: * Cisco 5500 Series (refer to EtherChannel Support related content). * Suntrunking Software. * Alteon Acedirector Switches / WebOS (Trunk Switches). * BayStack Switches (Trunks must be configured). Stackable module (450) defines in ports of different physical units * Linux bonding. For hot backup mode It can work with all Layer 2 switches. 8. Which network card is from the MAC of a Bonding device? If there is no significant use of ifconfig to configure the specified, the MAC address of the Bonding device is obtained from its first SLAVE. This MAC address is then passed with all other SLAVE devices, which will have this Mac, even if the first SLAVE device is removed. Only the Bonding device restarts or DOWN, the MAC address will change. If you want to modify the MAC address, you can use ifconfig to set: # i10: 33: 44: 55 You can change the MAC address of the Bonding device by UP / DOWN device, then modify its slave's order: # Ifconfig bond0 down; modprobe -r bonding # ifconfig bond0 .... Up # ifenslave bond0 Eth ... This method will automatically get the address from the next SLAVE that will be added. In order to restore the SLAVE MAC address, it is necessary to separate it from the Bonding device (`ifnslave -d bond0 eth0 '), Down off the device (` ifconfig eth0 down'), remove the module (`RMMOD 3C59X '), then overload It allows it to get its MAC address from its EEPROMS. If a driver is owned by multiple devices, it is necessary to drop all DOWN.

Another method is to view the MAC address of the card (DMESG or TAIL / VAR / LOG / MESSAGES), and use ifconfig to reset it: # ifconfig eth0 down # ifconfig Eth0 HW Ether 00: 20: 40: 60: 80 : A0 9. What transmission mode is used? Rotation mode: Based on SLAVE sequence, the rotation is transmitted through different network cards through different network cards; the thermal backup mode: ensures that only one network card is transmitted only, and another hot backup as the activation card, the data stream is immediately Switch to the hot backup card, this mode is often used in high availability in high availability using the switch to implement high availability using a Bonding driver, you need to compile the driver as a module, because the passing parameters are driven at this time. The only way. This situation may change later. First, you need to make sure all NIC supports the MII link status report. In Linux2.2.17 and above, all 100M Ethernet and YELLOWFIN Gigabit Ethernet support MII link status reports. If your NIC driver does not support this technology, then the link status is monitored as a fault. Bonding drivers currently detect all of its SLAVE links by monitoring the MII status registrar. The detection interval has a module parameter "miimon" to define. This value is an integer value, unit is MilliseConds. 100ms is a suitable value because it is too small to affect system performance. That is, it will be discovered within 100 ms seconds after the link is fault. For example: # modprobe bonding miimon = 100 or in /etc/modules.conf is defined as follows: Alias ​​Bond0 Bonding Options Bond0 Miimon = 100 There are two strategies for high availability, depending on whether the host is connected to a single host or Support Trunking Switch B) Host Connecting to Multiple Different Switches, or Single Not Supported Trunking Switch 1) Easy to configure and understand this mode on a single switch or host, only a simple configuration remote configuration Equipment (host or switch) to disperse data traffic in multiple ports (Trunk, EtherChannel, etc.) and configure the Bonding interface. If the module is loaded, the MII parameter is specified, and MII will work automatically. What information has been monitored by the drive device monitoring by removing or recovering a different link, then see which information has been monitored by the drive device. When monitoring, you may encounter such problems: If all the interfaces connected to the Trunk are DOWN, some bugs have a Diable Trunk for a long time. These issues can be corrected by restarting the switch. Example 1: Master and host implementation multiple: in each host, run: # modprobe bonding miimon = 100 # ifconfig bond0 addr # ifenslave bond0 Eth0 Eth1 Example 2: Host Connection Switch To implement multiple speed: Run in Host A: # ModProbe Bonding Miimon = 100 # ifconfig Bond0 Addr # ifslave bond0 Eth0 Eth1 In the switch: # Set Trunking for Port1 and Port2. 2) This mode is more likely to have problems in multiple switches or single switch situations on multiple switches or hosts on multiple switches or hosts. The MAC address can only be visible by one port to avoid confusing switches.

If you need to know which port is activity, which is backup, then use ifconfig. All backup interfaces are set to have a Noaep flag. In order to use this mode, "MODE = 1" is delivered when loading: # modprobe bonding miimon = 100 mode = 1 or add the following: Alias ​​Bond0 Bonding Options Bond0 Miimon = 100 Mode = 1 Example 1: Use multiple hosts and multiple switches to create "No Fetile Point Bottleneck" Solution: In this configuration, there is an ISL-switch between inter-switch link (Inter Sitch Link, possibly a trunk), multiple The host (Host1, Host2 ...) is simultaneously connected to the switch, and multiple ports are connected to the external network (port3 ...), and only one slave is activated in each host, but all links are still monitored. (The system can monitor the fault of the activity link and start the backup link). If Host1 and Host2 have the same function, and is used in load balancing, the Host1 active interface is connected to one of the switches and Host2 is connected to another switch is a very good selection. This system can still guarantee the work in a single host, switch or line. The worst possible situation is that a single switch has failed, one of which will not be accessible until another switch maintained forwarding table expires, and another host will convert activation interfaces to normal switches. Example 2: Use multiple Ethernet cards to connect to a switch to cope with the NIC fault, to improve availability: in host a: # modprobe bonding miimon = 100 mode = 1 # ifconfig bond0 addr # ifenslave bond0 Eth0 Eth1 in the switch : # (Optional) Minimize Transfer Expiration Expiration Each host switches its activity interface, which will use the new interface until the interface is faulty. In this example, the overgent time of the host is converted by the switch. 3) Adjusting the frequency of the switch If the switch is turned too long if the switch is converted to the backup interface, it is generally hoped to enable the standby interface immediately when the current interface fails. You can achieve a delay in which a fully disable of an interface can be achieved by passing the module parameter "Downdlay". When a switch is restarted, the port may appear in the port "LINK UP" status in the port. This can make the bonding device uses ports that are not available. This may delay the time of the active port being reused by passing the module parameter "Updelay". The same problem occurs when a host and switch re-interact to determine a lost link. In the case of the Bonding interface, the driver will use the first UP interface immediately without being limited by the Updelay parameter. This reduces the time of system DOWN. For example: # modProbe bonding miimon = 100 mode = 1 downndlay = 2000 Updelay = 5000 # modprobe bonding miimon = 100 mode = 0 downndlay = 0 UpDelay = 5000 4) Limit main limit is: only link status is monitored, if the switch itself Down Falling, for example, no longer forwarding the data but the link is still intact. Then the link will not be DIABLE. Another way to monitor the fault link statistically an access data frame of a heavy load host. But it is not recommended for which of which loads are small.

Resource Links Donald Becker's soil driver and Diag programs can be below: - http://www.scyld.com/neetwork/ - http://cesdis.gsfc.nasa.gov/linux/drivers/ (Seems to Be dead now - ftp://cesdis.gsfc.nasa.goc/pub/linux/Drivers/ (Seems to Be dead now) can also get a lot of information about Ethernet, NWAY, and MII at www.scyld.com. Y Y is the new version of the driver, the kernel patch and the updated user space tool can be obtained in Willy Tarreau's website: - http://wtarreau.free.fr/pub/bonding/ - http: // www-miaif. Lip6.fr/willy/pub/bonding/ For the latest Linux Kernel development information, please pay attention: http://boudca.tux.org/hypermail/linux-kernel/latest/ linux2.4.x core Bonding implementation Because Bonding is already included in the kernel 2.4.x, you only need to select the Bonding Driver Support in the Network Device Option when compiling. Then, recompile the core, restart the computer, execute the following command: Insmod Bonding ifconfig Eth0 Down ifconfig Eth1 Down IFCONFIG BOND0 ipaddress ifenslave Bond0 Eth0 ifenslave bond0 Eth1 Now two network cards are already as well as a piece. This can improve the data between cluster nodes transmission. You'd better write these sentences into a script, then call the /etc/rc.d/rc.local so that it will take effect on it. Bonding is a better choice for the server. When there is no Gigabit network card, use two three 100 megabytes cards for Bonding, which greatly enhances the bandwidth between the server to the switch. But you need to set two connections to the Bonding network card on the switch. The mouth map is the same virtual interface (Trunking technology).

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

New Post(0)