Ubuntu Bonding(16.04网卡绑定)
UbuntuBonding(网卡绑定)
绑定,也称为端口聚合或链路聚合,意味着将多个网络接口(NIC)组合到单个链路,从而提供高可用性,负载平衡,最大吞吐量或这些组合。
注意bonding只能提供链路监测,即从主机到交换机的链路是否接通。如果只是交换机对外(如防火墙等)的链路down掉了,而交换机本身并没有故障,那么bonding会认为链路没有问题而继续使用。
一、安装网卡绑定所需要的负载均衡软件fenslave,它是一款linux下的负载均衡工具,可以将数据包有效的分配到bonding驱动。
1、查看软件fenslave是否安装
root@ubuntu:~# dpkg -l | grep fenslave
ii  ifenslave    2.7ubuntu1    all      configure network interfaces for parallel routing (bonding)
通过上面的信息可以知道软件已经安装
2、如果没安装,可以通过apt源安装,有外网就用外网源,没有的话用本地DVD源。
root@ubuntu:~# apt-get install ifenslave
三、检查 bonding 模块是否正常加载
root@ubuntu:~# lsmod | grep bonding 
bonding               147456  0
root@ubuntu:~#
四、添加bonding模块开机启动,编辑/etc/modules配置文件如下
root@ubuntu:~# vi /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
bonding       #添加的内容,使该模块开机启动
root@ubuntu:~#
五、配置网络接口
1、确保您的网络已关闭:
root@ubuntu:~# systemctl stop  networking.service
2、然后加载绑定内核模块:
root@ubuntu:~# modprobe bonding     #如果上面查看模块时已经加载,这里可以不执行
3、编辑网络配置文件
root@ubuntu:~# vi /etc/network/interfaces
举例1:要使用简单的主备模式设置,将enp4s0f0和enp4s0f1作为绑定网卡,绑定的接口为bond0,并将作为enp4s0f0主接口:
绑定前需要先通过ifconfig -a 命令查看可以的网卡,配置文件如下:
--------------------------------------------------------------------------
# enp4s0f0 is manually configured, and slave to the "bond0" bonded NIC
auto enp4s0f0                      #要绑定的主网卡
iface enp4s0f0 inet manual
    bond-master bond0
    bond-primary enp4s0f0
# enp4s0f1 ditto, thus creating a 2-link bond.
auto enp4s0f1                      #要绑定的备网卡
iface enp4s0f1 inet manual
    bond-master bond0
# bond0 is the bonding NIC and can be used like any other normal NIC.
# bond0 is configured using static network information.
auto bond0                        #绑定的网卡名
iface bond0 inet static           #静态地址
    address 192.168.3.30          #IP
    gateway 192.168.3.1           #网关
    netmask 255.255.255.0         #子网
    bond-mode active-backup       #模式主备
    bond-miimon 100               #miimon是100毫秒监测一次网卡状态,如果有一条线路不通就切换另一条线路。
    bond-slaves none
-------------------------------------------------------------------------
举例2 :要使用自适应负载均衡模式(模式6)设置,将enp4s0f0和enp4s0f1作为绑定网卡,绑定的接口为bond0,
配置文件如下:
# enp4s0f0 is manually configured, and slave to the "bond0" bonded NIC
auto enp4s0f0
iface enp4s0f0 inet manual
    bond-master bond0
# enp4s0f1 ditto, thus creating a 2-link bond.
auto enp4s0f1
iface enp4s0f1 inet manual
    bond-master bond0
# bond0 is the bonding NIC and can be used like any other normal NIC.
# bond0 is configured using static network information.
auto bond0
iface bond0 inet static
    address 13.181.3.30
    gateway 13.181.3.254
    netmask 255.255.255.0
    bond-mode 6                       #绑定模式为6
    bond-miimon 100
    bond-slaves  enp4s0f0  enp4s0f1    #绑定的从属的网卡
------------------------------------------------------------------------------
六、启动网卡
root@ubuntu:~# systemctl start networking.service
七、查看bond0的工作情况
root@ubuntu:~# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)           #bond模式为主备
Primary Slave: enp4s0f0 (primary_reselect always)
Currently Active Slave: enp4s0f0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: enp4s0f0
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 50:5d:ac:49:08:3f
Slave queue ID: 0
Slave Interface: enp4s0f1
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 50:5d:ac:49:08:40
Slave queue ID: 0
root@ubuntu:~#
八、bonding一共有7种工作模式(mode):
0:(balance-rr) Round-robin policy: (平衡轮询策略):传输数据包顺序是依次传输,直到最后一个传输完毕,此模式提供负载平衡和容错能力。
1:(active-backup) Active-backup policy:(活动备份策略):只有一个设备处于活动状态。一个宕掉另一个马上由备份转换为主设备。mac地址是外部可见得。此模式提供了容错能力。
2:(balance-xor) XOR policy:(平衡策略):传输根据[(源MAC地址xor目标MAC地址)mod设备数量]的布尔值选择传输设备。 此模式提供负载平衡和容错能力。
3:(broadcast) Broadcast policy:(广播策略):将所有数据包传输给所有设备。此模式提供了容错能力。
4:(802.3ad) IEEE 802.3ad Dynamic link aggregation. IEEE 802.3ad 动态链接聚合:创建共享相同的速度和双工设置的聚合组。此模式提供了容错能力。每个设备需要基于驱动的重新获取速度和全双工支持;如果使用交换机,交换机也需启用 802.3ad 模式。
5:(balance-tlb) Adaptive transmit load balancing(适配器传输负载均衡):通道绑定不需要专用的交换机支持。发出的流量根据当前负载分给每一个设备。由当前设备处理接收,如果接受的设 备传不通就用另一个设备接管当前设备正在处理的mac地址。
6:(balance-alb) Adaptive load balancing: (适配器负载均衡):包括mode5,由 ARP 协商完成接收的负载。bonding驱动程序截获 ARP在本地系统发送出的请求,用其中之一的硬件地址覆盖从属设备的原地址。就像是在服务器上不同的人使用不同的硬件地址一样。
Ubuntu Bonding(16.04网卡绑定)的更多相关文章
- Ubuntu server 16.04安装,无网卡驱动解决
		
因为使用一个软件必须要在ubuntu server 16.04上安装,因此先在裸机上安装ubuntu server 16.04,具体信息: 镜像版本:ubuntu-16.04.6-server-amd ...
 - Ubuntu Server 16.04修改IP、DNS、hosts
		
本文记录下Ubuntu Server 16.04修改IP.DNS.hosts的方法 -------- 1. Ubuntu Server 16.04修改IP sudo vi /etc/network/i ...
 - Ubuntu Server 16.04.1系统安装
		
一.Ubuntu Server 16.04.1系统安装 Ubuntu分为桌面版(desktop)和服务器版(Server),下面为大家介绍服务器版本Ubuntu Server 16.04.1的详细安装 ...
 - Raspberry 2B && Ubuntu mate 16.04 && *** 完美透明代理
		
Raspberry 2B && Ubuntu mate 16.04 && *** 完美透明代理 关键词:Raspberry 2B, Ubuntu mate 16.04 ...
 - 从零到一,利用kubeadm在ubuntu server 16.04 64位系统离线安装kubernetes v1.10.0
		
说明 初步接触kubernets,记录学习过程 本教程目的利用kubeadm在ubuntu server 16.04 64位系统离线安装kubernets v1.10.0 环境信息 节点IP地址 角色 ...
 - ubuntu kylin 16.04系统的基本安装
		
系统版本:ubuntu kylin 16.04 硬件状况:500G HDD+120G SSD 已安装操作系统:WIN 10专业版(craked) ——WIN 10系统是装在SSD的第一个盘符内的.以前 ...
 - Ubuntu Server 16.04下ASP.NET Core Web Api + MySql + Dapper在 Jexus、nginx 下的简单测试
		
一.环境及工具 1.服务器 VirtualBox5.1.4 安装 Ubuntu Server 16.04 amd64 MySql Ver 14.14 Distrib 5.6.21 Jexus 5.8. ...
 - Ubuntu Server 14.04升级Ubuntu Server 16.04
		
Ubuntu Server 14.04升级Ubuntu Server 16.04 :转 http://blog.csdn.net/chszs 1.终端下执行命令 $ sudo apt-get upda ...
 - [原创]在HP DL380 G7服务器上部署基于Ubuntu Server 16.04 和 VirtualBox的云平台
		
对于一线开发人员来说,一提到虚拟机平台,往往会让人联想到在价格昂贵的服务器上部署VMware vSphere之类软件来实现. 笔者作为一个资深码农,也是一直梦寐着在自己家中打造一个真正的家庭私有云,秒 ...
 
随机推荐
- List Slider
			
http://www.jssor.com/download-jssor-slider-development-kit.html
 - Python学习第二天-编写购物车
			
需求:1.启动程序后,让用户输入工资,然后打印商品列表 2.允许用户根据商品编号购买商品 3.用户选择商品后,检测余额是否够,够就直接扣款,不够就提醒 ...
 - MySQL中锁详解(行锁、表锁、页锁、悲观锁、乐观锁等)
			
原文地址:http://blog.csdn.net/mysteryhaohao/article/details/51669741 锁,在现实生活中是为我们想要隐藏于外界所使用的一种工具.在计算机中,是 ...
 - iOS之数据请求NSURLConnection
			
iOS之数据请求NSURLConnection NSString *lcsUrl = @"http://192.168.1.1:8080/lcsUrl"; //假设网址中有汉字.须 ...
 - 经常使用传感器协议1:CJ/T-188 水表协议解析1
			
本文以实例说明CJ/T-188水表协议的解析过程,下面数据未经特殊说明,均指十六进制. 数据发送: FE FE FE FE 68 10 44 33 22 11 00 33 ...
 - Hadoop入门进阶步步高(二)-文件夹介绍
			
二.Hadoop文件夹结构 这里重点介绍几个文件夹bin.conf及lib文件夹. 1.$HADOOP_HOME/bin文件夹 文件名 说明 hadoop 用于运行hadoop脚本命令,被hadoop ...
 - zzulioj--1778-- 和尚特烦恼4——有多少战斗力(gcd)
			
1778: 和尚特烦恼4--有多少战斗力 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 259 Solved: 123 SubmitStatusWe ...
 - python中对单例模式的理解
			
class Foo(object): instance = None def __init__(self): pass def process(self): ' @classmethod #版本1单例 ...
 - BZOJ 3130 二分+网络流
			
思路: 不被题目忽悠就是思路 二分一下max 判一下等不等于最大流 搞定 7 9 1 1 2 3 1 3 3 2 3 3 3 4 2 3 5 2 3 6 1 4 7 2 5 7 2 6 7 2 这里有 ...
 - BZOJ 4552 排序 Heoi2016
			
记得当年省选的时候 这道题连暴力都没写对(尴尬ing) (当年天真的认为sort是左闭右闭的hhhhhh) 思路: 首先 二分答案 线段树 首先二分答案,然后需要知道进行m次排序后p位置上的数字是否大 ...