In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to realize the RedHat server network card array configuration". In the daily operation, I believe that many people have doubts about how to realize the RedHat server network card array configuration. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to realize the RedHat server network card array configuration". Next, please follow the editor to study!
Network card array configuration
1. Modify the vi / etc/rc.d/rc.local file by adding the following (note that eth0 and eth2 ports are added here)
The code is as follows:
Ifenslave bond0 eth0 eth2
# if a network card fails, the system will start the network card in the order of / etc/rc.d/rc.local to protect against failure.
Echo "0" > > / proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
Setsebool ftpd_disable_trans 1
Service vsftpd restart
Route add-net 224.0.0.0 Universe 4 dev bond0
# add routes to set sending rules
two。 Modify configuration file / etc/sysconfig/network-scripts
Add a new ifcfg-bond0 file, as follows:
DEVICE=bond0 # device name
BOOTPROTO=static # does not enable DHCP
ONBOOT=yes # Bootstrap
IPADDR=192.168.101.X # ip address of the Nic array
NETMASK=255.255.255.0 # mask
GATEWAY=192.168.101.1 # Gateway
Modify the ifcfg-eth0,ifcfg-eth2 file, and add the following according to the actual configuration file:
The code is as follows:
MASTER=bond0
SLAVE=yes
BOOTPROTO=static # configure static address, do not enable DHCP
ONBOOT=yes # Boot Network Card self-booting
3. Modify / etc/modprobe.d/dist.conf (press esc to: $enter to the last line and add the following two sentences at the end)
The code is as follows:
Alias bond0 bonding
(Bonding can only provide link monitoring, whether the link from the host to the switch is connected. If only the external link of the switch is down down and the switch itself is not faulty, bonding will continue to use it because there is no fault.)
The code is as follows:
Options bond0 miimon=100 mode=1
(miimon is used for link monitoring. Each 100ms monitors the connection status of the link, if one line is transferred to another line. The value of mode indicates the working mode. There are four modes, one, two, three, four.
Mode=0 indicates that load balancing (round-robin) is a load balancing mode.
Mode=1 indicates that fault- tolerance (active-backup) is redundant mode, active / standby mode)
The code is as follows:
Alias net-pf-10 off # disable ipv6 support without adding it
For cascaded branch exchanges
The code is as follows:
Alias bond0 bonding
Options bond0 mode=1 arp_interval=500 arp_ip_target=192.168.101.254 arp_validate=all primary=eth0
# through a timer, each slave interface continuously sends ARP packets to change the corresponding relationship between the switch port and the MAC
So that every network card is working. The sending rules of this ARP are:
Arp requests are sent to arp_ip_target at each arp_interval (MS) interval, and arp requests can be sent to multiple arp_ip_target.
4. Increase / etc/udev/rules.d/50-hwinterfaces.rules
(lock the physical address of the network card, enter the physical address in the SYSFS {address} = "" double quotation marks)
The code is as follows:
KERNEL== "eth*", SYSFS {address} = "", NAME= "eth0"
KERNEL== "eth*", SYSFS {address} = "", NAME= "eth2"
KERNEL== "eth*", SYSFS {address} = "", NAME= "eth3"
KERNEL== "eth*", SYSFS {address} = "", NAME= "eth4"
KERNEL== "eth*", SYSFS {address} = "", NAME= "eth5"
Prevent the mac address of the machine network card from drifting
5. Check the configuration of the network card array
The code is as follows:
# ifconfig-a | grep HWaddr
Check the mac information of the network card. If the bond0,eth0,eth2 hardware address is the same, the configuration is successful.
The code is as follows:
# cat / proc/net/bonding/bond0
View bond0 working status
Notes on common operation methods of network card
The mac address on the 1.bond0 is modified to be consistent, and these network cards are connected to the same switch, so the arp table of the switch has multiple ports corresponding to the same mac address, and the switch cannot determine the port to which the packet is sent, so the corresponding port of the switch is required to adopt aggregation mode, and the aggregated port uses the same mac address.
two。 Make the network card configuration take effect immediately, no need to restart the machine, command
The code is as follows:
# service network restart or
# / etc/rc.d/init.d/network restart
The NetworkManager service must be turned off
The code is as follows:
# service NetworkManager stop / / disable the service in the current environment
# chkconfig NetworkManager off / / Boot / shutdown service
3. Restart the network card, command
The code is as follows:
# ifconfig bond0 down/ifdown bond0
# ifconfig eth0 down/ifdown eth0
# ifconfig eth2 down/ifdown eth2
# ifenslave bond0 eth0
# ifenslave bond0 eth2
# ifconfig bond0 up/ifup bond0
# ifconfig eth0 up/ifup eth0
# ifconfig eth2 up/ifup eth2
4. There are 7 modes of Bonding:
The code is as follows:
# defineBOND_MODE_ROUNDROBIN 0.balance-rr mode, load balancing mode of Nic
# defineBOND_MODE_ACTIVEBACKUP 1.active-backup mode, fault-tolerant mode of Nic
# defineBOND_MODE_XOR 2.balance-xor mode, which requires switch support
# defineBOND_MODE_BROADCAST 3.broadcast mode
# defineBOND_MODE_8023AD 4.IEEE 802.3ad dynamic link aggregation mode, which requires the switch to support # defineBOND_MODE_TLB 5. Custom transport load balancing mode
# defineBOND_MODE_ALB 6. Network card virtualization mode
All the working modes of bonding module can be divided into two types: multi-main working mode and active-standby working mode, balance-rr and broadcast belong to multi-main working mode, and active-backup belongs to active and standby working mode. (balance-xor, adaptive transmission load balancing mode (balance-tlb) and adaptive load balancing mode (balance-alb) also belong to multi-master working mode, while IEEE 802.3ad dynamic link aggregation mode (802.3ad) belongs to active and standby working mode.
(1) in BOND_MODE_ROUNDROBIN mode, the processing logic of bonding for sending and receiving data is inconsistent. For data reception, bonding basically does not do any processing, but relies solely on the change of switch port and MAC to receive data alternately. When sending, the switch learns the relationship between the port and the MAC according to the source MAC of the data, so what bonding does is choose a different network card to send.
(2) the fault-tolerant mode of the Nic (mode = BOND_MODE_ACTIVEBACKUP). The configuration method of the fault-tolerant mode is basically the same as that of the load balancer mode, except that you can modify / etc/modprobe.conf.
5.arp detection mode
Observing the MAC address learned on the switch port, it is found that MAC will switch repeatedly in BOND_MODE_ROUNDROBIN mode on the two ports, and the processing logic of bonding for sending and receiving data is inconsistent. For data reception, bonding basically does not do any processing, relying solely on the change of switch port and MAC to receive data alternately. When sending, the switch learns the relationship between the port and the MAC according to the source MAC of the data, so what bonding does is choose a different network card to send.
For the transmission of data
The code is as follows:
Static inline voidbond_set_mode_ops (struct net_device * bond_dev, int mode)
{
Switch (mode) {
Case BOND_MODE_ROUNDROBIN:
Bond_dev- > hard_start_xmit = bond_xmit_roundrobin
Break
...
The sending function of bond is registered as bond_xmit_roundrobin. It can be found through the implementation of bond_xmit_roundrobin.
The code is as follows:
Static int bond_xmit_roundrobin (structsk_buff * skb, struct net_device * bond_dev)
{
Ead_lock (& bond- > curr_slave_lock)
Slave = start_at = bond- > curr_active_slave
Read_unlock (& bond- > curr_slave_lock)
Bond_for_each_slave_from (bond, slave, iMagazine startkeeper) {
If (IS_UP (slave- > dev) & &
(slave- > link = = BOND_LINK_UP) & &
(slave- > state = = BOND_STATE_ACTIVE)) {
Res = bond_dev_queue_xmit (bond, skb, slave- > dev)
Write_lock (& bond- > curr_slave_lock)
Bond- > curr_active_slave= slave- > next
Write_unlock (& bond- > curr_slave_lock)
Break
}
Bond_xmit_roundrobin will send through the device that the curr_active_slave pointer points to, and of course curr_active_slave will point to the next slave device after calling bond_dev_queue_xmit to complete the actual send. Bond_dev_queue_xmit actually calls the general sending function dev_queue_xmit, which is passed to dev_queue_xmit as a skb. Before passing, skb- > dev is designated as the current slave device, so the kernel will find the corresponding real Nic device to send. Finally, the polling switch of the curr_active_slave pointer realizes the load balancing working mode of bonding.
From this mode, we can see that bonding implements a module similar to the network card driver, and the corresponding bond0 device is a pure virtual device. Although the data is sent through it, it takes a series of calls to return to the real network card device to send it, which will undoubtedly consume certain system performance.
The BOND_MODE_ROUNDROBIN mode is simply tested with UDP packets at the 100Mbps rate.
In the process of testing, it is found that there will be more out-of-order packets at the receiver. Observing the situation of the switch ports, the switching frequency between the ports is irregular, which should be closely related to the configuration or performance of the switch. If necessary, further research is needed. Whether the correctness and timing of the data can be guaranteed needs to be further carefully tested.
6. Mii link detection method
It is different from the previous arp detection. These two link detection methods can be used under all kinds of mode, but it should be noted that they can not be used at the same time.
Mii detection implementation of bonding. First of all, like arp-monitor, mii is triggered by a timer.
The code is as follows:
If (bond- > params.miimon) {/ * link checkinterval, in milliseconds. , /
Init_timer (mii_timer)
Mii_timer- > expires= jiffies + 1
Mii_timer- > data = (unsigned long) bond_dev
Mii_timer- > function = (void*) & bond_mii_monitor
Add_timer (mii_timer)
}
The essential principle of the bond_mii_monitor function is to detect the link state of the network card. Bonding defines that the network card has four link states: BOND_LINK_UP:
Normal state (the Nic in this state is a potential candidate for sending packets)
BOND_LINK_FAIL: network card failed, switching to status BOND_LINK_DOWN
BOND_LINK_DOWN: failure statu
BOND_LINK_BACK: network card recovery, switching to status BOND_LINK_UP
From top to bottom, it indicates that the network card link is from normal to failure and then to recovery state. The bond_mii_monitor function checks whether the link state of the network card is in these states in turn, and then indicates whether it is necessary to switch the slave network card by marking the do_failover variable. The code is large, but the logic is clear, so it is not listed here.
In BOND_MODE_ACTIVEBACKUP mode, one of the two network cards actually does not work and is set to the state of IFF_NOARP. At the same time, the MAC addresses of bond virtual devices and slave devices are the same, so this network card will not be detected by the outside world. There is no case that the switch wants to send packets to this port. When bond's mii detection finds that the current active device is invalid, it will switch to this backup device.
In the bond_change_active_slave function
The code is as follows:
If (bond- > params.mode = = BOND_MODE_ACTIVEBACKUP) {
If (old_active) {
Bond_set_slave_inactive_flags (old_active)
}
If (new_active) {
Bond_set_slave_active_flags (new_active)
}
}
This is the switching logic in BOND_MODE_ACTIVEBACKUP mode. It is very simple to note that in bond_set_slave_inactive_flags (old_active), the state of the interface needs to be set to IFF_NOARP, otherwise the switch may send the packet to the wrong port.
At this point, the study on "how to implement the RedHat server network card array configuration" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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