Huawei server centos 6.5 dual network card binding operation steps

Keywords: Linux network CentOS Mac

Recently, a batch of Centos 6.5 server network card binding operation has been completed. Because of the current network production environment, the operation is very cautious, but who knows there are still errors, the two servers directly ping is not working, ran to the computer room. All kinds of ups and downs.

Therefore, I would like to share the operation steps and precautions here.

1. Environmental Description

Huawei pcserver installs the Centos 6.5664-bit operating system. The server is equipped with four network cards, two of which are in use, and two network wires are connected with two switches respectively to achieve redundancy.

2. Operational steps

1) Through ifconfig-a grep eth command, we can see that eth0 and eth1 are in running state, that is to say, eth0 and eth1 have one network cable inserted in each network card at present, so eth0 and eth1 need to be bound to two network cards.

eth0      Link encap:Ethernet  HWaddr E8:4D:D0:BF:D1:9B  
          inet addr:10.168.122.13  Bcast:10.168.122.255  Mask:255.255.255.0
          inet6 addr: fe80::ea4d:d0ff:febf:d19b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:21281229862 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20649353230 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1927808267139 (1.7 TiB)  TX bytes:1543317199732 (1.4 TiB)
          Memory:92300000-92400000 

eth1      Link encap:Ethernet  HWaddr E8:4D:D0:BF:D1:9C  
          inet6 addr: fe80::ea4d:d0ff:febf:d19c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1495871 errors:0 dropped:0 overruns:0 frame:0
          TX packets:204395 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:97238155 (92.7 MiB)  TX bytes:15301940 (14.5 MiB)
          Memory:92200000-92300000 

eth2      Link encap:Ethernet  HWaddr E8:4D:D0:C9:EA:B2  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Memory:c8100000-c8200000 

eth3      Link encap:Ethernet  HWaddr E8:4D:D0:C9:EA:B3  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
          Memory:c8000000-c8100000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:130023805258 errors:0 dropped:0 overruns:0 frame:0
          TX packets:130023805258 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:19290336847188 (17.5 TiB)  TX bytes:19290336847188 (17.5 TiB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:3F:C3:47  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

virbr0-nic Link encap:Ethernet  HWaddr 52:54:00:3F:C3:47  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

2) Close the Network Manager service in service management and disable automatic startup. (This step is very critical, I did not first implement this step, resulting in all the work done, restart network services, tragedy happened)

The executive orders are as follows:

   service NetworkManager stop   --Close NetworkManager service
   service NetworkManager status 
   chkconfig NetworkManager off   --Disabling NetworkManager Service auto-start
   chkconfig NetworkManager --list 

3) Create a file named ifcfg-bond0 in the / etc/sysconfig/network-scripts directory, edit the file and add the following

vi ifcfg-bond0
BOOTPROTO=none
DEVICE=bond0         --Note here
ONBOOT=yes           --Note here
IPADDR=10.168.122.13       --Will host the ip Address added here
NETMASK=255.255.255.0
GATEWAY=10.168.122.254
USERCTL=no
TYPE=Ethernet
IPV6INIT=no

Edit ifcfg-eth0 and ifcfg-eth1 files in turn, and replace the following with ifcfg-eth0 and ifcfg-eth1. (Note that before replacing, you must backup the files before the changes and copy them to a path other than / etc/sysconfig/network-scripts)

vi ifcfg-eth0
BOOTPROTO=none
DEVICE=eth0    --Note here
ONBOOT=yes     --Note here
MASTER=bond0   --Note here
SLAVE=yes      --Note here
USERCTL=no
TYPE=Ethernet
IPV6INIT=no

vi ifcfg-eth1
BOOTPROTO=none 
DEVICE=eth1   --Note here
ONBOOT=yes    --Note here
MASTER=bond0  --Note here
SLAVE=yes     --Note here
USERCTL=no
TYPE=Ethernet
IPV6INIT=no

4) Load the bonding module, bond0 is the external virtual network interface device, and add the following two lines at the end of the / etc/modprobe.d/dist.conf file

alias bond0 bonding
options bond0 mode=1 miimon=100

As for the meaning of the two-line command added here, we can find the following explanation from Baidu: the option millmon is to specify how long to monitor the link, the unit is ms. # Option mode is the working mode of the binding port. There are 7 modes in 0-7. There are commonly used modes 0 and 1. mode=0 is the "round-robin" strategy. The two cards work in the load balancing state at the same time. mode=1 denotes the "active-backup" strategy, with two cards in a standby backup state.

5) Restart network services:
Service network restart (if the prompt command is incorrect, execute: / etc/rc.d/init.d/network restart)

6) Verify that the bindings of dual network cards are successful (if the server is not connected after the fifth step above, it means sorrow, need to run the computer room.... Therefore, it is suggested that a free server should be selected for the first operation to do a test, so as to avoid excessive impact on the network environment.

Method 1:

If successful, ifconfig-a displays the same MAC address of bond0 and eth0 and eth1 network cards.

Method 2:

Test whether the bond is successfully bound:

cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1                ----eth1 Main mode
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: ac:16:2d:77:1f:cc

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: ac:16:2d:77:1f:cd

7) If you are interested, you can do the following. To test the results of bindings of dual network cards.

Let's assume that the eth0 hardware of the network card is broken. implement
ifdown eth0

It is found that the server can still ping....

This means that redundancy plays a role.

Posted by smilinmonki666 on Sat, 01 Jun 2019 12:40:15 -0700