Chinaunix首页 | 论坛 | 博客
  • 博客访问: 385765
  • 博文数量: 32
  • 博客积分: 2410
  • 博客等级: 大尉
  • 技术积分: 687
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-10 11:34
文章分类
文章存档

2012年(2)

2011年(6)

2010年(6)

2009年(7)

2008年(11)

分类: LINUX

2010-07-07 15:29:05

端口聚合(IEEE802.3ad Port Trunking)
可将2至8个10/100Base-TX端口聚合成一条干路,在全双工工作模式下达到400Mbps-1.6Gbps的带宽。端口聚合技术能充分利用现有设备实现高速数据传递,也可以通过千兆端口聚合技术实现千兆位链路的聚合,最多可以聚合4Gbps的链路带宽。

Linux双网卡绑定的实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是两块网卡具有相同的 IP地址而并行链接聚合成一个逻辑链路工作。其实这项技术在Sun和Cisco中早已存在,被称为Trunking和Etherchannel技术,在 Linux的2.4.x的内核中也采用这这种技术,被称为bonding。bonding技术的最早应用是在集群——beowulf上,为了提高集群节点 间的数据传输而设计的。下面我们讨论一下bonding 的原理,什么是bonding需要从网卡的混杂(promisc)模式说起。我们知道,在正常情况下,网卡只接收目的硬件地址(MAC Address)是自身Mac的以太网帧,对于别的数据帧都滤掉,以减轻驱动程序的负担。但是网卡也支持另外一种被称为混杂promisc的模式,可以接 收网络上所有的帧,比如说tcpdump,就是运行在这个模式下。bonding也运行在这个模式下,而且修改了驱动程序中的mac地址,将两块网卡的 Mac地址改成相同,可以接收特定mac的数据帧。然后把相应的数据帧传送给bond驱动程序处理。 

方案一
具体配置示例如下:
1、[root@storage6 network-scripts]# cat ifcfg-bond0
# Intel Corporation 80003ES2LAN Gigabit Ethernet Controller (Copper)
DEVICE=bond0
BOOTPROTO=static
IPADDR=172.16.100.35
NETMASK=255.255.255.0
ONBOOT=yes
GATEWAY=172.16.100.1
BONDING_MASTER=yes
TYPE=Ethernet
USERCTL=no

[root@storage6 network-scripts]# cat ifcfg-eth0
# Intel Corporation 80003ES2LAN Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
USERCTL=no

[root@storage6 network-scripts]# cat ifcfg-eth1
#IntelCorporation80003ES2LANGigabitEthernetController(Copper)
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
USERCTL=no

2、编辑 /etc/modprobe.conf 文件,加入如下一行内容,以使系统在启动时加载bonding模块,对外虚拟网络接口设备为 bond0
加入下列两行  
alias bond0 bonding  
options bond0 miimon=100 mode=0 
说明:miimon是用来进行链路监测的。 比如:miimon=100,那么系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路;mode的值表示工作模式,他共有0,1,2,3四种模式,常用的为0,1两种。
    mode=0表示load balancing (round-robin)为负载均衡方式,两块网卡都工作。
    mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份.   
bonding只能提供链路监测,即从主机到交换机的链路是否接通。如果只是交换机对外的链路down掉了,而交换机本身并没有故障,那么bonding会认为链路没有问题而继续使用

重启网络服务:service network restart

[root@storage6 network-scripts]# ifconfig
bond0     Link encap:Ethernet  HWaddr 00:A0:D1:E8:65:20
          inet addr:172.16.100.35  Bcast:172.16.100.255  Mask:255.255.255.0
          inet6 addr: fe80::2a0:d1ff:fee8:6520/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:55025978 errors:0 dropped:0 overruns:0 frame:0
          TX packets:55560375 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:34128517375 (31.7 GiB)  TX bytes:57600166665 (53.6 GiB)

eth0      Link encap:Ethernet  HWaddr 00:A0:D1:E8:65:20
          inet6 addr: fe80::2a0:d1ff:fee8:6520/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:27524452 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27788406 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:17091910563 (15.9 GiB)  TX bytes:28812888955 (26.8 GiB)
          Memory:fcde0000-fce00000

eth1      Link encap:Ethernet  HWaddr 00:A0:D1:E8:65:20
          inet6 addr: fe80::2a0:d1ff:fee8:6520/64 Scope:Link
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:27501527 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27771974 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:17036606878 (15.8 GiB)  TX bytes:28787278664 (26.8 GiB)
          Memory:fcdc0000-fcde0000

方案二
配置双网卡聚合(自适应负载均衡)
modprobe bonding miimon=100 mode=6
ifconfig bond0 192.168.4.15 netmask 255.255.255.0 up
ifenslave bond0 eth0 eth1
cat /proc/net/bonding/bond0
此时交换机无需配置,即可实现负载均衡。
阅读(10544) | 评论(0) | 转发(0) |
0

上一篇:epoll

下一篇:rsa可逆加密算法实例

给主人留下些什么吧!~~