Chinaunix首页 | 论坛 | 博客
  • 博客访问: 588782
  • 博文数量: 158
  • 博客积分: 2696
  • 博客等级: 少校
  • 技术积分: 1668
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-10 00:49
个人简介

life?is?short?,?play?more!

文章分类

全部博文(158)

文章存档

2021年(1)

2013年(10)

2012年(4)

2011年(11)

2010年(27)

2009年(28)

2008年(52)

2007年(25)

我的朋友

分类: LINUX

2009-03-24 13:34:24

Linux系统以太网卡绑定how

多网卡绑定技术可以实现网卡硬件级别上的负载均衡和失效保护

安装

一般的企业级应用的linux os都已经编译好了bonding模块和ifenslave工具 
============
1 )编译需要的bonding(绑定模块)
---------------------------------------

2 )下载并安装用户空间工具
--------------------------------------
安装iputils工具包

里面包含ifenslave命令


3 )配置您的系统
------------------------

配置此文件/etc/conf.modules (或/etc/modules.conf ) :

添加

alias bond0 bonding

options bond0 miimon=100 mode=1 


现在架设你电脑上有2个网卡,eth0 和 eth1
在/etc/sysconfig/network-scripts 目录里创建这个文件ifcfg-bond0,并编辑里面的内容如下。
DEVICE=bond0
IPADDR=192.168.1.1
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.255
ONBOOT=yes
BOOTPROTO=none
USERCTL=no

在eth0 和 eth1 的配置文件里修改成这样的。
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

好了,同样eth1也需要修改。


运行以下命令
     # ifconfig bond0 192.168.1.1 up
     # ifenslave bond0 eth0 eth1



4 )模块参数。 注意在3步的时候,我们添加了一些option的参数。来看下可以设置的参数都有那些。
--------------------- 

关于mode的参数
mode=0 (balance-rr)
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.

mode=1 (active-backup)
Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.

mode=2 (balance-xor)
XOR policy: Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.

mode=3 (broadcast)
Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.

mode=4 (802.3ad)
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

	Pre-requisites:
	1. Ethtool support in the base drivers for retrieving
	the speed and duplex of each slave.
	2. A switch that supports IEEE 802.3ad Dynamic link
	aggregation.
	Most switches will require some type of configuration
	to enable 802.3ad mode.

mode=5 (balance-tlb)
Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.

	Prerequisite:
	Ethtool support in the base drivers for retrieving the
	speed of each slave.

mode=6 (balance-alb)
Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.
     miimon = 
0就是关闭miilink 检测。时间单位是ms。 就是间隔多长时间检测一次连接的状态。 


     downdelay =

单位毫秒。down一个link(网卡)的延迟时间。

     updelay =

单位毫秒。up一个link(网卡)的延迟时间。


     arp_interval = 

arp检测时间间隔

     arp_ip_target =

如果arp_interval不是0,则填入一个检测的ip地址,用来进行arp 监控。

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