Linux dual-nic binding practices
Preface
The work mainly focuses on SUSE, and the network is one of the most important links in the high-availability architecture. Physically, it is generally in the dual-nic binding mode. The default mode is usually 1 (active-backup) as the master-slave relationship.
In the production server that recently tested big data, the binding mode is set to mode = 6 (balance-alb), and the traffic is doubled by using Server Load balancer. In addition, in The SuSE HA architecture test from Skybility HA to Corosync/Openais + Pacemaker, mode = 0 (balance-rr) is used for network switch Port Channel link aggregation ), balanced round robin enables zero packet loss during network interruption.
The following uses CentOS as an example (similar to Red Hat). The dual-nic settings on other platforms are relatively simple. SuSE (YaST), AIX (SMIT), Windows (Intel ), if you have any requirements, you can reply to the message and I will update and supplement it later.
Follows the high availability principle to achieve Failure Protection and load balancing
Additional reading
Three common Bond modes for basic configuration information
The configuration process uses mode = 6 as an example. For the other 7 modes, refer to extended reading.
Mode = 0: Load Balancing mode, with automatic backup, but requires "Switch" support and settings. Mode = 1: automatic backup mode. If one line is disconnected, other lines are automatically backed up. Mode = 6: Load Balancing mode, automatic backup, no need to Switch support and settings.
Physical Interface
Interface |
IP |
Type |
Eth0, eth2 |
|
Two production NICs |
Eth3 |
10.129.46.19 |
Private address |
Bond0 |
10.3.3.214 |
Dual Nic binding address |
CentOS version
- Datanode01: ~> Cat/etc/RedHat-release
- CentOS release 6.4 (Final)
Disable NetworkManager
- # Disable NetworkManager immediately and disable auto-start upon startup
- /Etc/init. d/NetworkManager stop
- Chkconfig NetworkManager off
- /Etc/init. d/network restart
Disable iptables and selinux (optional)
- # Disable iptables immediately and disable auto-start upon startup
- /Etc/init. d/iptables stop
- Chkconfig iptables off
-
- # Disable selinux immediately and disable selinux permanently
- Setenforce 0
- Sed-I's/SELINUX = enforcing/SELINUX = disabled/'/etc/selinux/config
Modify host name
- Vi/etc/sysconfig/network
-
- NETWORKING = yes
- HOSTNAME = namenode01
-
- # Refresh takes effect
- Hostname namnode01
- Source/etc/sysconfig/network
Configure the private IP Address
- Cd/etc/sysconfig/network-scripts
-
- [Root @ datanode09 network-scripts] # cat ifcfg-eth3
- DEVICE = eth3
- ONBOOT = yes
- BOOTPROTO = none
- IPADDR = 10.129.46.19
- NETMASK = 255.255.255.0
- IPV6INIT = no
- USERCTL = no
Bind two NICs
- Cd/etc/sysconfig/network-scripts
-
- # Edit eth0
- Cat> ifcfg-eth0 <EOF
- DEVICE = eth0
- ONBOOT = yes
- BOOTPROTO = none
- USERCTL = no
- MASTER = bond0
- EOF
-
- # Edit eth2
- Cat> ifcfg-eth2 <EOF
- DEVICE = eth2
- ONBOOT = yes
- BOOTPROTO = none
- USERCTL = no
- MASTER = bond0
- EOF
-
- # Edit bond0
- Cat> ifcfg-bond0 <EOF
- DEVICE = bond0
- TYPE = Ethernet
- ONBOOT = yes
- BOOTPROTO = none
- IPADDR = 10.3.3.214
- NETMASK = 255.255.255.0
- GATEWAY = 10.3.3.1
- IPV6INIT = no
- USERCTL = no
- EOF
-
- # Set bond parameters. Pay attention to mode selection.
- Cat>/etc/modprobe. conf <EOF
- Alias bond0 bonding
- Options bond0 miimon = 100 mode = 6
- EOF
-
- # Add auto-start Parameters
- Cat>/etc/rc. local <EOF
- Ifenslave bond0 eth0 eth2
- EOF
-
- # Restart an Eni
- Service network restart
-
- # Make the bound Nic effective immediately
- Ifenslave bond0 eth0 eth2
-
- # Test network binding
- Ping 10.3.3.1
-
Comparison of three common Nic binding modes mode = 0
Interrupt any link or restore link, zero packet loss on the network
Advantage: traffic is doubled
Disadvantage: You need to connect to the same vswitch for aggregation configuration, so the high availability of the physical switch cannot be guaranteed (Cisco seems to have a solution ?)
Mode = 1
When one link is interrupted, 1-3 packets are lost (in seconds), and zero packet loss is restored.
Advantage: No need to configure the vswitch
Disadvantages:
Mode = 6
Zero packet loss occurs when any link is interrupted. 10-15 packets are lost when the link is recovered (in seconds)
Advantage: vswitches do not need to be configured, and the traffic is doubled
Disadvantage: Packet Loss takes too long to recover the link.
This article permanently updates the link address: