linux 网卡 负载,Linux多网卡负载均衡 : bond

一、新建bond0虚拟设备

vi /etc/sysconfig/network-scripts/ifcfg-bond0

输入

DEVICE=bond0 BOOTPROTO=none ONBOOT=yes NETWORK=192.168.1.0 #网段 NETMASK=255.255.255.0 # 掩码 IPADDR=192.168.1.2 # 指定IP USERCTL=no GATEWAY=192.168.1.1 # 网关 TYPE=Ethernet

二、修改所有真实网卡的配置

vi /etc/sysconfig/network-scripts/ifcfg-eth0 vi /etc/sysconfig/network-scripts/ifcfg-eth1 ....

内容修改为:

DEVICE=eth0 # 这里填写对应的设备名称 BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes USERCTL=yes

三、将bond0加入modprobe

vi /etc/modprobe.conf

加入

alias bond0 bonding options bond0 miimon=100 mode=0

四、加入启动命令

vi /etc/rc.d/rc.local

加入

ifenslave bond0 eth0 eth1

其中eth0、eth1为真实网卡名称,按照实际情况填写

五、重启系统后即可启动负载均衡式的bond

第三步选项说明:miimon=100每100毫秒 (即0.1秒) 检查一次网络

mode=0共有七种模式,常用的模式是0和1mode=0 : 负载均衡模式,所有网卡一起使用,峰值=所有网卡带宽的总和,当某个网卡故障,仅降低带宽,不影响其他网卡mode=1 : 热备模式,即一块网卡运行,其他待命,当运行的网卡故障,其他网卡顶上

查看bond0状态:

cat /proc/net/bonding/bond0

若某个网卡的MII Status=down,表示该网卡无法连接网络此时应检查:1、网线是否插好2、网线是否损坏3、网卡配置是否正确4、网卡是否没插好5、网卡是否损坏

PS: 使用bond时,所有网卡接口都需用网线接上交换机和路由器

附录:英文解释

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.

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.

附录:实操记录

待整理。

转自:http://blog.chinaunix.net/uid-16728139-id-3200499.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值