分类: LINUX
2008-11-23 16:36:51
某合作商提供的服务器是双千兆网卡,可是交换机没有电口的1000M,都是100M的,服务器流量也超过了100M,只能采用两块网卡聚合。交换机端无需做特殊设置。
1.增加虚拟网卡:
vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
BROADCAST=172.16.1.255
IPADDR=172.16.1.2
NETMASK=255.255.255.0
ONBOOT=yes
2.修改原来物理网卡设置:
网卡1
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
网卡2
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=dhcp
3.增加虚拟网卡模块
vi /etc/modprobe.conf
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会认为链路没有问题而继续使用
本案例中使用mode=0的配置来做负载均衡提高系统性能,增大并发带宽。
4.加入到开机自动运行
vi /etc/rc.d/rc.local
加入两行
ifenslave bond0 eth0 eth1
route add -net 172.16.1.254 netmask 255.255.255.0 bond0
重启系统后能看到3块网卡,其中bond0的流量是eth0+eth1的总和。
查看bond0虚拟网卡
cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.1.2 (January 20, 2007)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:1e:4f:23:cb:49
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:1e:4f:23:cb:4b
ps:用cacti监控bond0的流量时,获取到bond0的带宽是10M而已,需要在cacti里边将其修改为1000M