说明:
绑定多块网卡为一个虚拟ip,类似csico的etherchannel,实现冗余或负载均衡和增加带宽的功能。
内核需要bonding的支持,察看是否挂在bonding,lsmod命令。默认2.6内核中bonding已经被编译为M的选项,不需重新编译内核。
其实Redhat关于bond,在kernel-doc里有一篇文档,讲述得非常详细,可以先看看/usr/share/doc/kernel-doc-2.6.18/Documentation/networking/bonding.txt
一:不需重起的配置方法。
1 modprobe bonding miimon=100
2 ifconfig bond0 192.168.1.1 netmask 255.255.255.0
3 ifenslave bond0 eth0 eth1
二:重起仍然生效的配置方法一。
1关闭要绑定的物理网卡
修改ifcfg-eth0和ifcfg-eth1的启动项
BOOTPROTO=none
ONBOOT=no
2建立虚拟网卡
在/etc/sysconfig/network-scripts/ 目录下建立 ifcfg-bond0,并修改 /etc/modprobe.conf文件实现开机自动挂载。
/etc/sysconfig/network-scripts/ifcfg-bond0 配置如下:
DEVICE=bond0
IPADDR=192.168.0.193
NETMASK=255.255.255.0
BOOTPROTO=static
ONBOOT=yes
GATEWAY=192.168.0.3
/etc/modprobe.conf 配置如下:
alias eth0 bnx2
alias eth1 bnx2
alias bond0 bonding
options bonding miimon=100 mode=1(miimon是用来进行链路监测的。
比如:miimon=100,那么系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路。模式1为主备模式,模式0为负载均衡与增加带宽的模式)
注:以上为只做一组bonding的方式,如果做多组的话可以更改为以下的方式:
alias eth0 bnx2
alias eth1 bnx2
alias eth2 e1000
alias eth3 e1000
install bond0 /sbin/modprobe -a eth0 eth1 && /sbin/modprobe bonding
alias bond0 bonding
install bond1 /sbin/modprobe -a eth2 eth3 && /sbin/modprobe bonding
alias bond1 bonding
options bonding mode=1 miimon=100 max_bonds=2
最后执行测试, REBOOT确认bond0是否启动,如果启动,配置成功。
查看bonding状态
cat /proc/net/bonding/bond0
Read the rest of this entry »
