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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章