事先需要準備好網(wǎng)絡yum源,保證服務器可正常上網(wǎng)
關(guān)閉防火墻,關(guān)閉selinux
本次實驗虛擬機環(huán)境下模擬,網(wǎng)卡為nat模式,dhcp分配ip,現(xiàn)添加兩張網(wǎng)卡,如圖

image.png
登錄服務器后,由于是后添加的網(wǎng)卡,發(fā)現(xiàn)/etc/sysconfig/network-scripts下沒有新加網(wǎng)卡的配置文件,然后使用以下命令
nmtui
把有線連接
image.png
改為對應網(wǎng)卡改為對應網(wǎng)卡名字

image.png
然后
cd /etc/sysconfig/network-scripts/
然后修改ifcfg-ens37,ifcfg-ens38配置文件(相當于末尾追加MASTER=bond0 SLAVE=yes,把BOOTPROTO改為none),如下
[root@localhost network-scripts]# cat ifcfg-ens37
HWADDR=00:0C:29:B2:F3:A9
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens37
UUID=f69a315d-2735-4489-b99e-7153f016e7b2
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[root@localhost network-scripts]# cat ifcfg-ens38
HWADDR=00:0C:29:B2:F3:B3
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens38
UUID=3e20bf34-6f74-34ff-b702-7f0e74ed34bc
ONBOOT=yes
AUTOCONNECT_PRIORITY=-999
MASTER=bond0
SLAVE=yes
然后新加一個bond配置文件,這里選擇mode 6,無需配置交換機
[root@localhost network-scripts]# cat ifcfg-bond0
TYPE=Bond
BOOTPROTO=dhcp
ONBOOT=yes
DEVICE=bond0
BONDING_MASTER=yes
BONDING_OPTS="mode=6 miimon=100"
然后重啟網(wǎng)絡
systemctl restart network
然后使用nmtui發(fā)現(xiàn)

image.png
[root@localhost network-scripts]# lsmod | grep bonding
bonding 152979 0
[root@localhost 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: ens37
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: ens37
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:b2:f3:a9
Slave queue ID: 0
Slave Interface: ens38
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:b2:f3:b3
Slave queue ID: 0
[root@localhost 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
Duplex: Full
Port: Other
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
Link detected: yes