Ubuntu 16.04 bonding

bonding简介

Bonding又叫链路聚合,将多个网卡绑定为单个逻辑链路,可以提供网络高可用,负载均衡,大流量通信功能。如在存储系统中,可以通过bonding解决服务器网络大流量问题。

bonding kernel module

  • 查看有没有bonding kernel module
root@ubuntu:~# modinfo bonding | head -n 3
filename:       /lib/modules/4.4.0-98-generic/kernel/drivers/net/bonding/bonding.ko
author:         Thomas Davis, [email protected] and many others
description:    Ethernet Channel Bonding Driver, v3.7.1
  • 内核加载bonding module
root@ubuntu:~# modprobe bonding

root@ubuntu:~# lsmod | grep bonding
bonding               147456  0
  • 开机启动时加载bonding module
root@ubuntu:~# echo bonding > /etc/modules

root@ubuntu:~# cat /etc/modules
bonding

设置bonding

配置注意事项

  • 设置mode,需要bonding链路为down状态,并且移除所有的slaves
  • 添加slave,需要slave的链路为down状态
  • 安装ifenslave后,可以在/etc/network/interfaces文件配置bonding,bonding选项以bond-*开头。
  • miimon, arp_interval或arp_ip_target通常需要指定参数,否则当链路挂了,会导致网络性能下降。大多数设备支持miimon,miimon=100是一个不错初始值。

iproute2配置bonding

root@ubuntu:~# modprobe bonding mode=0 miimon=100

root@ubuntu:~# ip link set bond0 up

root@ubuntu:~# ip link set eth3 master bond0

root@ubuntu:~# ip link set eth8 master bond0

sysfs配置bonding


#添加bonding链路bond1
root@ubuntu:~# echo +bond1 > /sys/class/net/bonding_masters

#删除bonding链路bond1
root@ubuntu:~# echo -bond1 > /sys/class/net/bonding_masters

#设置mode
root@ubuntu:~# echo 0 > /sys/class/net/bond0/bonding/mode

#网卡enp0s3绑定到bond0
root@ubuntu:~# echo +eth3 > /sys/class/net/bond0/bonding/slaves

#删除slave网卡enp0s3
root@ubuntu:~# echo -eth3 > /sys/class/net/bond0/bonding/slaves

interfaces 配置例子

root@ubuntu:~#cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback


auto enp0s3
iface enp0s3 inet manual
  bond-master bond0

auto enp0s8
iface enp0s8 inet manual
  bond-master bond0

auto bond0
iface bond0 inet static
  address 192.168.7.25
  netmask 255.255.255.0
  network 192.168.7.0
  gateway 192.168.7.1
  bond-mode 0
  bond-miimon 100
  bond-slaves enp0s3 enp0s8

查看bonding状态

# MII Status up状态为正常状态
root@ubuntu:~# cat bondingstatus
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: enp0s8
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:90:b1:ac
Slave queue ID: 0

Slave Interface: enp0s3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:04:85:e3
Slave queue ID: 0

参考

  • https://www.kernel.org/doc/Documentation/networking/bonding.txt
  • https://wiki.debian.org/Bonding

你可能感兴趣的:(Ubuntu 16.04 bonding)