Ubuntu 16.04 amd64 bond mode6 配置

1、简介

    本文 旨在 介绍 在 Ubuntu 16.04 环境下 配置 bond mode6
    

1.1 操作 系统

## 本文 测试 使用的是 Ubuntu 16.04 的操作系统
# lsb_release -a

    

1.2 bond

1.2.1 为什么 使用 bond

    随着 网络 信息 时代的发展,很多 时候 单个 网卡 不能 满足 我们 的日常需求,单个 的 千兆(哪怕是 万兆)如今 都已经 出现 了瓶颈;Linux bonding 驱动提供了一种 将多个物理网络端口捆绑为单个逻辑网络端口的方法,用于网络负载均衡、冗余 来 提升网络的性能,解决 单个 网卡 带来的 瓶颈 问题
    

1.2.2 bond 驱动

    Linux的多网卡绑定功能使用的是内核中的"bonding"模块(关于此模块可以参考Linux Ethernet Bonding Driver文档,幸运的 是 目前发布各个Linux版本内核均已包含了此模块,大多数情况下不需要重新编译内核);Linux 的 bonding 驱动提供了绑定/集成(bond)多个网卡为一个虚拟逻辑网口的功能;
    

1.2.3 bond 模式

    网口绑定 (bonded)有多种工作模式: 目前网卡绑定mode共有七种(0~6)bond0、bond1、bond2、bond3、bond4、bond5、bond6(bond6 只是 个名称,bond 配置的 mode6 模式;所以 为了 方便 直观了解,就 已经 成为了 一种 约定俗成 的规范);一般来说,分为 热后备(hot standby) 和 负载均衡(load balancing);本文 只介绍 bond6 (其余 模式 暂不介绍)
    

1.3 bond6

    属于 负载 均衡(发送、接收 都会进行 负载),配置 bond6 不需要对 交换机(switch) 进行相关配置,因此 比较 简单操作(哈哈哈,不需要 配置 交换机哦,我貌似 也不会配交换机)
    

2.1 bond 模块 查看

## 内核模块操作相关的命令:lsmod、modinfo、depmod、rmmod、inmod、modprobe 
## lsmod 结果
##     第一列 :表示 模块的名称
##     第二列 :表示 模块的大小
##     第三列 :表示 依赖该模块的个数
##     第四列 :表示 依赖 该模块 的内容(如果 依赖 个数 为0,则第四列为空)
# lsmod | grep "bond*"
bonding  147456  0

    

2.2 bond 模块加载

## 如果 bond 模块 没有加载,我们需要 手动 加载 该模块
# modprobe bonding

    

2.3 bond 模块信息

## 可以 通过 modinfo 命令 查看 某一模块的具体 信息
## 不想 详细 解释了:filename、author、license、depends...
# modinfo bonding

    

3、网卡 查看

# ifconfig -a

    

4、bond 配置/检测

    不同 操作 系统 对于 bond 配置 方式 不一样,所以 在此处 在此 提示 一下,本文 针对 Ubuntu 16.04 操作 系统 配置 bond的 说明
    

4.1 安装 ifenslave

## 在线安装
# apt-get install ifenslave

    

4.2 bond 模块 开机 自启

## 系统 开启 如果 不自动 加载 bond 驱动,可以 手动添加 
# cat /etc/rc.local 
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

## bond 模块 开机自启
sudo modprobe bonding

exit 0

    

4.3 bond 配置

# cat /etc/network/interface
# cat /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo
inet loopback

# The primary network interface
auto bond0
iface bond0 inet static
address XXX.XXX.XXX.XXX
netmask XXX.XXX.XXX.XXX
gateway XXX.XXX.XXX.XXX

bond-slaves ens1f0 ens1f1
bond-lacp-rate 1
bond-mode 6
bond-miimon 100

auto ens1f0
iface ens1f0 inet manual
bond-master bond0

auto ens1f1
iface ens1f1 inet manual
bond-master bond0

    

4.4 bond 检测

# 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: ens1f0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens1f0
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: f8:f2:1e:39:93:60
Slave queue ID: 0

Slave Interface: ens1f1
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: f8:f2:1e:39:93:61
Slave queue ID: 0

    

5、网络/带宽 测试(简单介绍)

5.1 iperf 服务器端

本文测试的是 TCP 方式下的 网络带宽测试(根据自己需求,也可测试 UTP方式)
# iperf -s

    

5.2 iperf 客户端

## iperf_server_ip iperf 服务端 IP地址
## thread_num 多进程,进程 数量
## time 测试时长(s)
## num 客户端 每次打印信息间隔(s)
# iperf -c {iperf_server_ip}  -P {thread_num} -t {time} -i {num}

    

6、网口流量监测(简单介绍)

    监测 网口 流量 命令 很多,再次 不过多 介绍,一笔带过,后期 编写 文章 详细 描述

## 执行 nmon 命令,再按键 "N"
# nmon

猜你喜欢

转载自blog.51cto.com/11495268/2345761