|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!实行情况:RedhatEnterpriseLinux5.2VMwareworkstation7
图一 实行情况网卡设置:三块假造网卡,事情在NAT形式
1、设置三个网卡及bond0
[root@redhat5~]#cd/etc/sysconfig/network-scripts
[root@redhat5network-scripts]#ls|grepifcfg
ifcfg-bond0
ifcfg-eth0
ifcfg-eth1
ifcfg-eth2
ifcfg-lo
[root@redhat5network-scripts]#
用vi编纂器编纂ifcfg-eth0,在缘故原由的基本上保保存三个参数的设置便可:DEVICE=eth0,BOOTPROTO=static及ONBOOT=yes,别的的
参数值用#号正文失落或间接删除。
[root@redhat5network-scripts]#viifcfg-eth0
#AdvancedMicroDevices[AMD]79c970[PCnet32LANCE]
DEVICE=eth0
BOOTPROTO=static
#BROADCAST=192.168.249.255
#HWADDR=00:0C:29:42:42:61
#IPADDR=192.168.249.2
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#NETMASK=255.255.255.0
#NETWORK=192.168.249.0
ONBOOT=yes
~
~
~
"ifcfg-eth0"11L,248C
别的的两个网卡eth1与eth2的设置与eth0的一样:
[root@redhat5network-scripts]#catifcfg-eth1
#AdvancedMicroDevices[AMD]79c970[PCnet32LANCE]
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
#HWADDR=00:0c:29:42:42:6b
[root@redhat5network-scripts]#catifcfg-eth2
#AdvancedMicroDevices[AMD]79c970[PCnet32LANCE]
DEVICE=eth2
ONBOOT=yes
BOOTPROTO=static
#HWADDR=00:0c:29:42:42:75
以某个网卡为模板创立bond0的设置文件ifcfg-bond0:
[root@redhat5network-scripts]#cpifcfg-eth0bond0
用vi编纂修正ifcfg-bond0,内容以下,保存DEVICE=bond0,BOOTPROTO=static,IPADDR=192.168.249.2,NETMASK=255.255.2550便可。
[root@redhat5network-scripts]#catifcfg-bond0
#AdvancedMicroDevices[AMD]79c970[PCnet32LANCE]
DEVICE=bond0
BOOTPROTO=static
#BROADCAST=192.168.249.255
#HWADDR=00:0C:29:42:42:61
IPADDR=192.168.249.2
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
NETMASK=255.255.255.0
#NETWORK=192.168.249.0
ONBOOT=yes
2、编纂/etc/modprobe.conf文件
在/etc/modprobe.conf文件中增加两行内容:
aliasbond0bonding
optionsbond0miimon=100mode=1
[root@redhat5/]#cat/etc/modprobe.conf
aliaseth0pcnet32
aliasscsi_hostadaptermptbase
aliasscsi_hostadapter1mptspi
aliasscsi_hostadapter2ata_piix
aliassnd-card-0snd-ens1371
optionssnd-card-0index=0
optionssnd-ens1371index=0
removesnd-ens1371{/usr/sbin/alsactlstore0>/dev/null2>&1||:;};/sbin/modprobe-r--ignore-removesnd-ens1371
aliaseth1pcnet32
aliaseth2pcnet32
aliasbond0bonding
optionsbond0miimon=100mode=1
[root@redhat5/]#
miimon=100暗示网卡形态的检测工夫是100毫秒。mode参数表收集绑定的形式,形式1是三个网卡中只要一个网卡事情,别的的两个做备份。
3、最初一步让绑定失效
servicenetworkrestart对网卡及bond0接口等设置失效
[root@redhat5/]#servicenetworkrestart
Shuttingdowninte***cebond0:[OK]
Shuttingdowninte***ceeth0:[OK]
Shuttingdowninte***ceeth1:[OK]
Shuttingdowninte***ceeth2:[OK]
Shuttingdownloopbackinte***ce:[OK]
Bringinguploopbackinte***ce:[OK]
Bringingupinte***cebond0:[OK]
Bringingupinte***ceeth0:[OK]
Bringingupinte***ceeth1:[OK]
Bringingupinte***ceeth2:[OK]
[root@redhat5/]#
运转ifenslavebond0eth0eth1eth2
[root@redhat5/]#ifenslavebond0eth0eth1eth2
为了让下次重启体系可以主动运转ifenslave下令,要实行上面下令:
[root@redhat5init.d]#echoifenslavebond0eth0eth1eth2>>/etc/rc.local
查验一下:
[root@redhat5/]#cat/etc/rc.local
#!/bin/sh
#
#Thisscriptwillbeexecuted*after*alltheotherinitscripts.
#Youcanputyourowninitializationstuffinhereifyoudont
#wanttodothefullSysVstyleinitstuff.
touch/var/lock/subsys/local
ifenslavebond0eth0eth1eth2
下面这条下令的意义是bond0为主网卡,别的的为从网卡,个中eth0是以后举动的从网卡,即eth0用来通讯。检察bond0信息:
[root@redhat5/]#cat/proc/net/bonding/bond0
EthernetChannelBondingDriver:v3.2.4(January28,2008)
BondingMode:fault-tolerance(active-backup)
PrimarySlave:None
CurrentlyActiveSlave:eth0
MIIStatus:up
MIIPollingInterval(ms):100
UpDelay(ms):0
DownDelay(ms):0
SlaveInte***ce:eth0
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:61
SlaveInte***ce:eth1
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:6b
SlaveInte***ce:eth2
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:75
反省绑定效果,用host机一直地向假造机发送icmp数据包,顺次downeth0、eth1,看看收集是不是还能连通。
图二ping假造机
图三 断开假造机的eth0、eth1的网卡
图四 每断开一个网卡会丢一个icmp数据包
当把eth0、eth1断开后,以后的举动网卡就是eth2了,
[root@redhat5/]#cat/proc/net/bonding/bond0
EthernetChannelBondingDriver:v3.2.4(January28,2008)
BondingMode:fault-tolerance(active-backup)
PrimarySlave:None
CurrentlyActiveSlave:eth2
MIIStatus:up
MIIPollingInterval(ms):100
UpDelay(ms):0
DownDelay(ms):0
SlaveInte***ce:eth0
MIIStatus:down
LinkFailureCount:1
PermanentHWaddr:00:0c:29:42:42:61
SlaveInte***ce:eth1
MIIStatus:down
LinkFailureCount:1
PermanentHWaddr:00:0c:29:42:42:6b
SlaveInte***ce:eth2
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:75
[root@redhat5/]#
4、多网卡绑定,完成负载平衡
修正/etc/modprobe.conf文件,mode=0,把绑定形式修正为负载平衡(round-robin)。
[root@redhat5~]#cat/etc/modprobe.conf
aliaseth0pcnet32
aliasscsi_hostadaptermptbase
aliasscsi_hostadapter1mptspi
aliasscsi_hostadapter2ata_piix
aliassnd-card-0snd-ens1371
optionssnd-card-0index=0
optionssnd-ens1371index=0
removesnd-ens1371{/usr/sbin/alsactlstore0>/dev/null2>&1||:;};/sbin/modprobe-r--ignore-removesnd-ens1371
aliaseth1pcnet32
aliaseth2pcnet32
aliasbond0bonding
optionsbond0miimon=100mode=0
[root@redhat5~]#cat/proc/net/bonding/bond0
EthernetChannelBondingDriver:v3.2.4(January28,2008)
BondingMode:loadbalancing(round-robin)
MIIStatus:up
MIIPollingInterval(ms):100
UpDelay(ms):0
DownDelay(ms):0
SlaveInte***ce:eth0
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:61
SlaveInte***ce:eth1
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:6b
SlaveInte***ce:eth2
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:75
别的形式:
mode=2
[root@redhat5~]#cap/proc/net/bonding/bond0
-bash:cap:commandnotfound
[root@redhat5~]#cat/proc/net/bonding/bond0
EthernetChannelBondingDriver:v3.2.4(January28,2008)
BondingMode:loadbalancing(xor)
TransmitHashPolicy:layer2(0)
MIIStatus:up
MIIPollingInterval(ms):100
UpDelay(ms):0
DownDelay(ms):0
SlaveInte***ce:eth0
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:61
SlaveInte***ce:eth1
MIIStatus:down
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:6b
SlaveInte***ce:eth2
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:75
mode=3
[root@redhat5~]#cat/proc/net/bonding/bond0
EthernetChannelBondingDriver:v3.2.4(January28,2008)
BondingMode:fault-tolerance(broadcast)
MIIStatus:up
MIIPollingInterval(ms):100
UpDelay(ms):0
DownDelay(ms):0
SlaveInte***ce:eth0
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:61
SlaveInte***ce:eth1
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:6b
SlaveInte***ce:eth2
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:75
mode=4
[root@redhat5~]#cat/proc/net/bonding/bond0
EthernetChannelBondingDriver:v3.2.4(January28,2008)
BondingMode:IEEE802.3adDynamiclinkaggregation
TransmitHashPolicy:layer2(0)
MIIStatus:up
MIIPollingInterval(ms):100
UpDelay(ms):0
DownDelay(ms):0
802.3adinfo
LACPrate:slow
ActiveAggregatorInfo:
AggregatorID:1
Numberofports:1
ActorKey:9
PartnerKey:1
PartnerMacAddress:00:00:00:00:00:00
SlaveInte***ce:eth0
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:61
AggregatorID:1
SlaveInte***ce:eth1
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:6b
AggregatorID:2
SlaveInte***ce:eth2
MIIStatus:up
LinkFailureCount:0
PermanentHWaddr:00:0c:29:42:42:75
AggregatorID:3
必要注重的是:当mode=0能够完成负载平衡但不克不及完成容错。这些机制是必要互换机撑持的。好比:IEEE链路聚合协定。
欢迎大家来到仓酷云论坛! |
|