运维

Centos7 网卡绑定(链路聚合)

2018-12-01  本文已影响61人  运维开发_西瓜甜

链路聚合 多网卡 bonding

内核参数调优

1. 创建bonding 网卡设备 bond0

[root@ansible network-scripts]$ sudo cat ifcfg-bond0 
DEVICE=bond0
TYPE=Ethernet  
ONBOOT=yes     # 启动网络服务自动激活
NM_CONTROLLED=no
BOOTPROTO=none # 此选项是设置IP地址为静态 ,设置为 staitc 也行
IPADDR=192.168.56.130
PREFIX=24      # 24 位掩码
IPV6INIT=no
USERCTL=no
GATEWAY=192.168.56.2  # 自己的网关地址

2. 备份并修改原来网卡的配置

[root@ansible network-scripts]$ sudo cp ifcfg-eth0{,.bak}
[root@ansible network-scripts]$ sudo ls ifcfg-*
ifcfg-bond0  ifcfg-eth0  ifcfg-eth0.bak  ifcfg-eth1  ifcfg-lo
[root@ansible network-scripts]$ sudo cp ifcfg-eth1{,.bak}
[root@ansible network-scripts]$ sudo vi ifcfg-eth0
[root@ansible network-scripts]$ sudo cat ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes
[root@ansible network-scripts]$ sudo cat ifcfg-eth0 > ifcfg-eth1
[root@ansible network-scripts]$ sudo sed -ir 's/eth0/eth1/g' ifcfg-eth1
[root@ansible network-scripts]$ sudo cat ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes

3. 重启网络服务

[root@ansible network-scripts]$ sudo service network restart

查看详情

[root@ansible network-scripts]$ sudo cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: load balancing (round-robin)
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: 00:0c:29:99:78:8a
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:99:78:94
Slave queue ID: 0

必要时修改一下bonding 的参数

linux系统下bond mode参数说明:

mode=4 在交换机支持LACP时推荐使用,其能提供更好的性能和稳定性

# 配置文件默认没有,vi 一个即可
[root@ansible network-scripts]$ sudo vi /etc/modprobe.d/bond0.conf
alias bond0 bonding
options bonding mode=0 miimon=100
上一篇下一篇

猜你喜欢

热点阅读