Chinaunix首页 | 论坛 | 博客
  • 博客访问: 805226
  • 博文数量: 94
  • 博客积分: 1767
  • 博客等级: 上尉
  • 技术积分: 1168
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-13 23:16
个人简介

ha

文章分类

全部博文(94)

文章存档

2014年(2)

2013年(17)

2012年(6)

2011年(15)

2010年(23)

2009年(23)

2008年(8)

我的朋友

分类: 系统运维

2013-11-14 14:00:05

ubuntu快速配置网卡bonding

Create time:08/26/2013 09:01   degree:42   comments:0
转载自:http://itxx.sinaapp.com/blog/content/144

网卡bonding可以带来网络处理能力的提升,网络接口的冗余等.

前提条件:至少两块可用的网卡,下面以简洁的步骤描述如何快速配置bonding:

1.加载内核模块

vi /etc/modules 加入

bonding

配置好后类似以下:

# /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.

loop
lp
rtc
bonding

2.断开网络

stop networking

3.加载模块

modprobe bonding

4.编辑网卡配置,加入bonding

vi /etc/network/interfaces  eth0 eth1设置为bonding模式,编辑好后类似如下:

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

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual
bond-master bond0

auto eth1
iface eth1 inet manual
bond-master bond0

auto bond0
iface bond0 inet static
    address 192.168.1.110
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1
    # load balancing and fault tolerance
    #bond-mode balance-rr
    bond-mode 802.3ad
    bond-miimon 100
    bond-lacp-rate 1
    bond-slaves none
    #bond-downdelay 200
    #bond-updelay 200
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 192.168.1.1

5.启动网络

start networking

注:这里的bond-mode有多种,根据实际情况和需求进行设置:

Mode 0

balance-rr

Round-robin policy: 从第一块可用的slave网卡开始顺序传输数据包.拥有负载均衡和容错的能力。

Mode 1

active-backup

Active-backup policy: 同一时刻只有一块网卡处于工作模式,另外一块仅当active出现故障时才会启用. 

Mode 2

balance-xor

XOR policy: 基于目的mac异或运算传输数据包,提供负载均衡和容错能力.

Mode 3

broadcast

Broadcast policy: 所有数据包要传送至所有slave,具有很高的容错能力.

Mode 4

802.3ad  遵循IEEE 802.3ad 规范.

 

Mode 5

balance-tlb

自适应负载均衡: 流出流量基于当前各slave速率负载. 进入流量由当前active slave接收.如果流入处理失败,由其他slave接替.

Mode 6

balance-alb

自适应负载均衡: 包含tlb和rlb, 流入负载基于arp协商. 

 

参考文档:

其他参考:https://www.kernel.org/doc/Documentation/networking/bonding.txt

阅读(3156) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~