In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Network Management of Linux (5) Multi-Nic bond single IP- active / standby mode
A single network card is used in Linux. After setting the ip address, it can be accessed externally and internally, but it does not have much impact on a small amount of data. However, in general, there is only a single network card in the virtual host or server, so receiving massive data from the network at the same time will bring about the permanence of the data queue, which may cause network channel congestion. Therefore, we can set up multiple network cards to bind to use a single IP address at the same time, so that multiple network cards can distribute the amount of data, so as to reduce the load of network data.
Of course, it is impossible to directly set IP addresses to multiple network cards at the same time, so the network module function in the linux kernel provides a network card binding mechanism. Because the communication between hosts through the network card is finally identified by the MAC address, the Bonding mechanism can be used to set up the kernel to identify multiple network cards as the same MAC address, so sending and receiving data on the network is equivalent to multiple channels, division of labor coordination, load balancing.
The mode of operation of Bonding:
Mode 0 (balance-rr)
Round-robin strategy: packets are sent sequentially on each slave network card from beginning to end. And provide load balancing and fault tolerance.
Mode 1 (active-backup)
Active-backup (active / standby) policy: only one slave is activated in the binding. Other slave is activated when and only if the active slave interface is identified. In order to avoid messy transmission on the switch, the bound MAC address is visible on only one external port.
Mode 3 (broadcast)
Broadcast strategy: all messages are sent over all slave interfaces. This model provides fault tolerance.
Configuration template for Bonding:
1. First, you need to create a configuration file for the bonding device.
Create an ifcfg-bond0 file in the / etc/sysconfig/network-scripts/ directory:
DEVICE=bond0
BOOTPROTO=none
BONDING_OPTS= "miimon=100 mode=0"
2. Set the self-device Nic that needs to be bound into a bound device.
/ etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=no
3. After setting the configuration file, you need to restart the network service to take effect.
At the same time, check the / proc/net/bonding/bond0 file to view the specified bond device information. Bond0 represents the network subscription device of the DEVICE=bond0.
Example test, which is tested here on redhat6.4.
# Host system is redhat6.4
[root@meng ~] # cat / etc/redhat-release Red Hat Enterprise Linux Server release 6.4 (Santiago)
# check the Nic device of this machine
# 2 enabled network devices are shown here, and the following Bonding configuration is performed:
1. Create a master-bound virtual device profile, which is set to mode 1 and active / standby mode.
2. Modify 2 network cards and bind them to become sub-devices.
Bind eth0
Bind eth2
3. Restart the network service
Service network restart
4. View the device information of the network card
Ifconfig
Resolution: at this time, we found that eth0 and eth2 no longer have IP address and other information, while bond0 devices use the mac address of eth0, so external access is provided as bond is the same Nic device, but now actually only eth0 is used, and eth2 is only in standby state.
# check the usage status of bond0 below
Cat / proc/net/binding/bond
Resolution: this shows that the mode is the master / slave mode, the currently active Nic is eth0, but eth2 does not appear, and the sub-devices are displayed as none. Is it possible that eth2 will only appear if eth0 is not in use again? The following tests this statement:
# unplug the eth0 network card, which is used in the vm virtual machine, so you can disconnect the corresponding network adapter.
# check the bond0 binding status again
Cat / proc/net/binding/bond0
Parsing: there seems to be a problem here. Eth0 has become down, so eth2 should be topped up as the main network interface, but it shows that the primary Nic device is none. It seems that although eth2 is recognized as a bond device, it seems that bond0 does not recognize this device. So debug and check.
# next, we connect the eth2 and want to restart the network card service to check whether there is a network configuration file misconfigured.
Service network restart
Parsing: there is no obvious error. File exists may be a duplicate device name read by the kernel, but it does not affect it. Here eth0 can be recognized, but eth2 is not topped when eth0 is disconnected, so there may be a problem with eth2 configuration.
# View the Nic configuration file
Paste ifcfg-eth0 ifcfg-eth2
Parsing: it is found here that the variable name of the secondary setting of SLAVE in eth2 is misspelled as SALVE. Let's modify the configuration of eth2.
# modify eth2 configuration
# start the network service again
/ etc/init.d/network restart
# check bond status again
Cat / proc/net/bonding/bond0
Parsing: because eth0 was disconnected just now, all currently active eth2 network cards are displayed, and bond0 has identified eth2 successfully. Status for eth2 displays up, while eth0 displays down.
# now connect eth0 and disconnect eth2
Parsing: where gray indicates that it has been disconnected, then eth0 is enabled and eth2 is disconnected
# check bond0 status again
Resolution: here the current sub-device and the change from eth2 to eth0,eth0 to up state, and eth2 to down state.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.