Production of server network card bond0

According to business requirements, realize the bond production of 50 new server NICs. The
current servers are equipped with 4 Gigabit NICs by default. In the production environment, no matter how difficult it is, it is necessary to achieve dual Standby mode), the most basic master-standby is the basic principle. Therefore, network equipment (switches) must be taken into consideration in early planning.

1. Concept

Three common network modes for link aggregation

  • mode0 (balanced load mode): The two network cards work in balance at the same time and automatically back up, but port aggregation needs to be performed on the switch device connected to the server's local network card to support the bonding technology.
  • mode1 (automatic backup mode): 1 network card works, when the working network card fails, the second network card replaces the faulty network card, purely active and standby mode.
  • mode6 (balanced load mode): The two network cards work in a balanced manner and automatically back up, without the need for auxiliary support from the switch device.

Key point: Remember that mode0 must implement port aggregation technology on the upstream switch.

2. Modify the name of the network card

The master who took me told me that for a good operation and maintenance, you must keep the server environment pure, and you must maintain the cleanliness of your own operating environment and technical cleanliness. This is a good habit.
Because the names of the network cards of the server are different, they are changed to eth0 eth1 ethxxx, and several names of several network cards are changed.

2.1 Operating environment

a virtual machine
image.png

2.2 Add two network cards

image.png

2.3 Modify the name of the network card to ethxxx

image.png

2.3.1 Modify configuration information

Modify to
add net.ifnames=p biosdevname=0

[root@zoey ~]# vim /etc/default/grub 

GRUB_TIMEOUT=2  5改为2 属于系统层面的优化,就是开机时间
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0 crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

2.3.2 Load configuration information

If the boot mode of the virtual machine is UEFI, the directory where the boot files are located is: /boot/efi/EFI/centos/.
If it is the BIOS startup mode, the directory where the startup file is located is: /boot/grub2/.
Load the modified information
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
or load it into the startup
grub2-mkconfig -o /boot/grub2/grub.cfg

2.3.3 Check the startup method

[root@zoey ~]# [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
BIOS
[root@zoey ~]#

[root@zoey ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-0cc2c6af8dad4af38bc7264960bfedce
Found initrd image: /boot/initramfs-0-rescue-0cc2c6af8dad4af38bc7264960bfedce.img
done
[root@zoey ~]# 

Important:
restart the server
image.png

2.4 View network card information

Check if it is eth

[root@zoey ~]# nmcli dev
DEVICE  TYPE      STATE   CONNECTION 
eth0    ethernet  连接的  eth0       
eth1    ethernet  连接的  eth1       
eth2    ethernet  连接的  eth2       
lo      loopback  未托管  --         
[root@zoey ~]# 

[root@zoey ~]# nmcli conn
NAME        UUID                                  TYPE      DEVICE 
ens33       c96bc909-188e-ec64-3a96-6a90982b08ad  ethernet  ens33  
有线连接 1  61014de7-c684-333e-a33b-46e10348550a  ethernet  ens36  
有线连接 2  723fd97f-e254-35ac-8df1-679e1235709d  ethernet  ens37  
[root@zoey ~]# 

2.5 Delete network card information

[root@zoey ~]# nmcli conn delete c96bc909-188e-ec64-3a96-6a90982b08ad
成功删除连接 'ens33'(c96bc909-188e-ec64-3a96-6a90982b08ad)。
[root@zoey ~]# nmcli conn delete 61014de7-c684-333e-a33b-46e10348550a
成功删除连接 '有线连接 1'(61014de7-c684-333e-a33b-46e10348550a)。
[root@zoey ~]# nmcli conn delete 723fd97f-e254-35ac-8df1-679e1235709d
成功删除连接 '有线连接 2'(723fd97f-e254-35ac-8df1-679e1235709d)。
[root@zoey ~]# 


2.5 Add network card information

image.png

[root@zoey ~]# nmcli conn
NAME  UUID                                  TYPE      DEVICE 
eth0  26a744a0-ef48-40c4-ab57-bfeef6ee88d1  ethernet  eth0   
eth1  f32f770e-d434-4232-b98b-92e821e64c83  ethernet  eth1   
eth2  9da992fc-6063-4a91-aa97-5adcb22bd8cb  ethernet  eth2   
[root@zoey ~]# 

2.6 Modify the network card dhcp to none

Modify the dhcp of the network card to none, and modify the unused network card to start not to start.
Why change the dhcp to none
because restarting the network card without a dhcp server in the real environment will get stuck

[root@zoey network-scripts]# sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/g' ifcfg-eth0
[root@zoey network-scripts]# sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/g' ifcfg-eth1
[root@zoey network-scripts]# sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/g' ifcfg-eth2
[root@zoey network-scripts]# 

[root@zoey network-scripts]# sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/g' ifcfg-eth2
[root@zoey network-scripts]# sed -i 's/ONBOOT=yes/ONBOOT=no/g' ifcfg-eth2
[root@zoey network-scripts]# sed -i 's/ONBOOT=yes/ONBOOT=no/g' ifcfg-eth1
[root@zoey network-scripts]# sed -i 's/ONBOOT=yes/ONBOOT=no/g' ifcfg-eth0
[root@zoey network-scripts]# 

3. Arrange bond

Make the two network cards eth1 and eth2 into a bond

3.1 Modify the network card configuration file

[root@zoey network-scripts]# vim ifcfg-eth1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth1 
UUID=f32f770e-d434-4232-b98b-92e821e64c83
DEVICE=eth1 
ONBOOT=yes
MASTER=bond0

[root@zoey network-scripts]# vim ifcfg-eth2

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=eth2
UUID=9da992fc-6063-4a91-aa97-5adcb22bd8cb
DEVICE=eth2
ONBOOT=yes
MASTER=bond0
[root@zoey network-scripts]# vim ifcfg-bond0 

TYPE=Bond
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=bond0
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
BONDING_OPTS='miimon=100 mode=6 fail_over_mac=1'

3.2 Configuration explanation

BONDING_OPTS='miimon=100 mode=6 fail_over_mac=1'
**miimon=100: **Frequency of monitoring network links, in milliseconds
Fail_over_mac=1 : There are two ways for this bond0 to obtain the mac address, one is from the first Obtain the mac address from an active network card, and then use the mac address of the rest of the SLAVE network card's mac address; the other is to use the fail_over_mac parameter, which means that bond0 uses the mac address of the current active network card, the mac address or the conversion of the active network card. .

3.3 View bond

[root@zoey network-scripts]# ethtool bond0
Settings for bond0:
	Supported ports: [ ]
	Supported link modes:   Not reported
	Supported pause frame use: No
	Supports auto-negotiation: No
	Supported FEC modes: Not reported
	Advertised link modes:  Not reported
	Advertised pause frame use: No
	Advertised auto-negotiation: No
	Advertised FEC modes: Not reported
	Speed: 2000Mb/s    变为2000MB
	Duplex: Full
	Port: Other
	PHYAD: 0
	Transceiver: internal
	Auto-negotiation: off
	Link detected: yes

[root@zoey network-scripts]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:42:61:6d
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:42:61:63
Slave queue ID: 0
[root@zoey network-scripts]# 

[root@zoey network-scripts]# ifconfig bond0
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::20c:29ff:fe42:616d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:42:61:6d  txqueuelen 1000  (Ethernet)
        RX packets 38  bytes 5446 (5.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 214  bytes 13016 (12.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@zoey network-scripts]# 

3.4 Testing

insert image description here

3.4.1 Remove the network card of eth1 or eth2

Direct hardware shutdown of network card
insert image description here

关闭eth1
[root@zoey ~]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: down    关掉
Speed: Unknown
Duplex: Unknown    
Link Failure Count: 2
Permanent HW addr: 00:0c:29:42:61:6d
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:0c:29:42:61:63
Slave queue ID: 0
[root@zoey ~]# 

There is a brief packet loss

Confirm that if one network card is turned off, the other network card will continue to work and automatically backup
bond0 MAC remains unchanged

Guess you like

Origin blog.csdn.net/xiaolong1155/article/details/131497003