linux bonding ubuntu,给ubuntu16.04做bond

所谓bond,就是把多个物理网卡绑定成一个逻辑上的网卡,使用同一个IP工作,在增加带宽的同时也可以提高冗余性,一般使用较多的就是来提高冗余,分别和不同交换机相连,提高可靠性,但有时服务器带宽不够了也可以用作增加带宽。以下是操作步骤:

一、环境准备

1、安装fenslave

它是一款linux下的网卡绑定所需要的负载均衡工具,可以将数据包有效的分配到bonding驱动。

查看软件fenslave是否安装

root@B-OPS-75-3:~# dpkg -l | grep fenslave

ii ifenslave 2.7ubuntu1 all configure network interfaces for parallel routing (bonding)

通过上面的信息可以知道软件已经安装

如果没安装,可以通过apt源安装

root@B-OPS-75-3:~# apt-get install ifenslave -y

2、加载绑定内核模块

root@B-OPS-75-3:~# modprobe bonding

检查 bonding 模块是否正常加载

root@B-OPS-75-3:~# lsmod | grep bonding

bonding 147456 0

3、添加bonding模块开机启动

root@B-OPS-75-3:~# 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 #添加的内容,使该模块开机启动

二、配置网络接口

1、编辑网络配置文件

a、使用简单的主备模式设置,将eth1和eth2作为绑定网卡,绑定的接口为bond0,并将作为eth1主接口:

root@B-OPS-75-3:~# vi /etc/network/interfaces

auto eth1 #要绑定的主网卡

iface enp4s0f0 inet manual

bond-master bond0

bond-primary eth1

auto eth2 #要绑定的备网卡

iface eth2 inet manual

bond-master bond0

auto bond0 #绑定的网卡名

iface bond0 inet static #静态地址

address xx.xx.xx.xx #IP

gateway xx.xx.xx.xx #网关

netmask xx.xx.xx.xx #子网

bond-mode active-backup #模式主备

bond-miimon 100 #miimon是100毫秒监测一次网卡状态,如果有一条线路不通就切换另一条线路。

bond-slaves none

b、使用自适应负载均衡模式(模式6)设置,将eth1和eth2作为绑定网卡,绑定的接口为bond0

root@B-OPS-75-3:~# vim /etc/modprobe.d/bond.conf //添加以下内容

alias bond0 bonding

options bond0 mode=balance-alb miimon=100

root@B-OPS-75-3:~# vim /etc/network/interfaces

auto eth1

iface eth1 inet manual

bond-master bond0

auto eth2

iface eth2 inet manual

bond-master bond0

auto bond0

iface bond0 inet static

address xx.xx.xx.xx

gateway xx.xx.xx.xx

netmask xx.xx.xx.xx

bond-mode 6 #绑定模式为6

bond-miimon 100

bond-slaves eth1 eth2 #绑定的从属的网卡

重启网卡

root@B-OPS-75-3:~# /etc/init.d/networking restart

三、bond的几种模式

bond的模式一共有七中,想要了解的朋友可自行百度,这里就不细说了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值