环境:
OS: redhat 8.0
1. #cd /etc/sysconfig/network-scripts
# cp ifcfg-eth0 ifcfg-bond0
----------------------------------------------------------------
2 #vi ifcfg-bond0
将第一行改成 DEVICE=bond0
----------------------------------------------------------------
3 # vi /etc/modules.conf
加入两行
alias bond0 bonding
options bond0 miimon=100 mode=1
----------------------------------------------------------------
4 # vi /etc/rc.d/rc.local
加入两行
ifenslave bond0 eth0 eth1
route add -net 192.168.0.0 netmask 255.255.255.0 bond0
----------------------------------------------------------------
5 reboot
重启会看见:
................
Bringing up interface bond0 [color=green]OK[/color]
Bringing up interface eth0 [color=green]OK[/color]
Bringing up interface bond1 [color=green]OK[/color]
----------------------------------------------------------------
6. 检查:
#netstat -r
192.168.0.0 255.255.255.0 0 40 0 0 bond0
192.168.0.0 255.255.255.0 0 40 0 0 eth0
192.168.0.0 255.255.255.0 0 40 0 0 eth1
这时候看看你的网卡后面的灯, 他们闪的频率是一样的.OK.
当#ifdown eth0 时, 转换有5-6秒的延时.
----------------------------------------------------------------
注意:
如果网络不通需要从启bind
# ifdown bind0
#ifup bind0
网卡绑定用在vncserver 或scp中就不灵了
祝大家绑定成功!!!!有问题多交流.
cump 回复于:2003-11-24 16:52:33
绑定好后,有什么用途?
cgweb 回复于:2003-11-24 17:04:55
多网卡之间实现冗于,增强server网络出口带宽......
双眼皮的猪 回复于:2003-11-24 17:12:26
好东东....但能不能把冗余的想关link也搞上来...大家也清楚点....???
cgweb 回复于:2003-11-24 17:16:49
"想关link"指的是什么????
双眼皮的猪 回复于:2003-11-24 17:22:23
哦,不好意思,相关的link.....
cgweb 回复于:2003-11-24 17:29:09
http://www1.ap.dell.com/content/topics/topic.aspx/ap/topics/power/zhcn/ps1q03_bhutani?c=cn&l=zh&s=lca
cgweb 回复于:2003-11-25 12:39:02
ok
好好先生 回复于:2003-11-25 12:49:19
鼓励原创.
david5337 回复于:2003-11-25 14:41:44
不错,好东西!
cgweb 回复于:2003-11-25 15:28:10
今天试了试在rh9.0 rhas3.0 同样适用.
dwq123 回复于:2003-11-26 09:58:28
好,谢谢楼主,顶
zorrozolo 回复于:2003-11-26 13:36:08
我在advanced server 2.1 里安你的方法不行
cgweb 回复于:2003-11-26 13:52:40
说看到那一步不行,屏幕提示信息是什么.
panlm 回复于:2003-11-26 13:57:57
挺
真心求教 回复于:2003-11-26 13:58:17
:oops:
真心求教 回复于:2003-11-26 14:02:05
:D
zorrozolo 回复于:2003-11-26 14:06:01
可能是os版本问题,我在as3下就行了,在as2下报错
[root@ascluster1 root]# /etc/init.d/network start
Setting network parameters: [ OK ]
Bringing up interface lo: [ OK ]
Bringing up interface bond0: bonding device does not seem to be present, delaying bond0 initialization.
[FAILED]
Bringing up interface eth0: [ OK ]
Bringing up interface eth1: [ OK ]
我是用vmware添加两个网卡试的,as3虽然可以但和主机就ping不通了可能是vmware的问题。但as2可能不能这样配,谢谢。
jeffyan 回复于:2003-11-27 23:43:49
how to link cable and swich ?
bb8848 回复于:2003-12-03 18:48:05
有個問題,樓主提到可以增加服務器出口帶寬,我用兩片10M的網卡bond,可是還是隻有10M的速度,請問怎麼回事啊??
bb8848 回复于:2003-12-04 09:17:25
搞定了,
關於雙網卡 [color=red]負載均衡[/color] 和 [color=red]冗余[/color]。
[root@localhost root]# cat /etc/modules.conf
alias eth0 8139too
alias eth1 8139too
alias bond0 bonding
#=========================================#
options bond0 miimon=100 mode=0
#options bond0 miimon=100 mode=1
#=========================================#
alias usb-controller ehci-hcd
alias sound-slot-0 i810_audio
post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L >;/dev/null 2>;&1 || :
pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -S >;/dev/null 2>;&1 || :
alias usb-controller1 usb-uhci
[root@localhost root]#
[color=red]mode=0[/color]雙網卡負載均衡
[color=red]mode=1[/color]雙網卡冗余
++++++++++++
我的網卡配置
[root@localhost root]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.250.55
NETMASK=255.255.255.0
[root@localhost root]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=0.0.0.0
[root@localhost root]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=static
IPADDR=0.0.0.0
[root@localhost root]#
當[color=red]mode=0[/color]時
[root@localhost root]# ifconfig
bond0 Link encap:Ethernet HWaddr 00:0A:EB:20:4A:8F
inet addr:192.168.250.55 Bcast:192.168.250.255 Mask:255.255.255.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:98050 errors:0 dropped:0 overruns:0 frame:0
TX packets:106613 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:91719644 (87.4 Mb) TX bytes:91895765 (87.6 Mb)
eth0 Link encap:Ethernet HWaddr 00:0A:EB:20:4A:8F
inet addr:192.168.250.55 Bcast:192.168.250.255 Mask:255.255.255.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:66340 errors:0 dropped:0 overruns:0 frame:0
TX packets:70755 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:62999539 (60.0 Mb) TX bytes:63440842 (60.5 Mb)
Interrupt:9 Base address:0x4000
eth1 Link encap:Ethernet HWaddr 00:0A:EB:20:4A:8F Media:unknown(auto)
inet addr:192.168.250.55 Bcast:192.168.250.255 Mask:255.255.255.0
UP BROADCAST DEBUG NOTRAILERS RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:31710 errors:0 dropped:0 overruns:0 frame:0
TX packets:35858 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:28720105 (27.3 Mb) TX bytes:28454923 (27.1 Mb)
Interrupt:9 Base address:0x6000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1264 (1.2 Kb) TX bytes:1264 (1.2 Kb)
[root@localhost root]#
當[color=red]mode=1[/color]時
[root@localhost root]# ifconfig
bond0 Link encap:Ethernet HWaddr 00:0A:EB:20:4A:8F
inet addr:192.168.250.55 Bcast:192.168.250.255 Mask:255.255.255.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:151339 errors:0 dropped:0 overruns:0 frame:0
TX packets:122827 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:176177703 (168.0 Mb) TX bytes:100056637 (95.4 Mb)
eth0 Link encap:Ethernet HWaddr 00:0A:EB:20:4A:8F
inet addr:192.168.250.55 Bcast:192.168.250.255 Mask:255.255.255.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:123792 errors:0 dropped:0 overruns:0 frame:0
TX packets:92270 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:152707097 (145.6 Mb) TX bytes:65678127 (62.6 Mb)
Interrupt:9 Base address:0x4000
eth1 Link encap:Ethernet HWaddr 00:0A:EB:20:4A:8F Media:unknown(auto)
inet addr:192.168.250.55 Bcast:192.168.250.255 Mask:255.255.255.0
UP BROADCAST DEBUG NOTRAILERS RUNNING NOARP SLAVE MULTICAST MTU:1500 Metric:1
RX packets:27547 errors:0 dropped:0 overruns:0 frame:0
TX packets:30557 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:23470606 (22.3 Mb) TX bytes:34378510 (32.7 Mb)
Interrupt:9 Base address:0x6000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:14 errors:0 dropped:0 overruns:0 frame:0
TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1088 (1.0 Kb) TX bytes:1088 (1.0 Kb)
[root@localhost root]#
注意這兩行
UP BROADCAST DEBUG NOTRAILERS RUNNING SLAVE MULTICAST MTU:1500 Metric:1
UP BROADCAST DEBUG NOTRAILERS RUNNING NOARP SLAVE MULTICAST MTU:1500 Metric:1
bb8848 回复于:2003-12-04 09:53:07
小弟又做了四塊網卡實驗,除得到以上的結果外。還有....
當[color=red]mode=0[/color]時,四塊網卡負載均衡,拔出非主網卡eth0都不會出現網絡中斷,隻是帶寬下降了。
當[color=red]mode=1[/color]時,四塊網卡冗余,默認是第一塊網卡工作,不管拔出那條網線,系統會按[color=blue]cat /etc/rc.local [/color]中的順序來選擇網卡,
[root@localhost root]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
#mii-tool --advertise=100baseT-FD eth3
ifenslave bond0 eth0 eth1 eth2 eth3
route add -net 192.168.250.0 netmask 255.255.255.0 bond0
[root@localhost root]#
有個怪問題,我做實驗兩台機,一台rh90,一台win2kserver,用d-link 1008d相連,測試帶款兩台同時從對方主機下載一個300m的文件.
發關和接收隻能用到網卡速度的一半,比如,兩邊同時下載,發送接收是18M,如果停掉一邊,速度之和還是18M,真是不明白,請高手釋疑?
xinyv 回复于:2003-12-04 10:09:43
我很想知道怎么能在实现负载均衡以后在实现冗余,请高手释疑。
wulm 回复于:2003-12-04 11:17:23
谢了,俺在你的帮助下也成功了
wjlxsl 回复于:2003-12-04 15:49:50
按楼主的办法。
在7.2上实现了绑定。
[root@firewall /]# ifconfig
bond0 Link encap:Ethernet HWaddr 00:C0:26:F0:12:81
inet addr:192.168.1.222 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:301 errors:0 dropped:4 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:36252 (35.4 Kb)
eth0 Link encap:Ethernet HWaddr 00:C0:26:F0:12:81
inet addr:192.168.1.222 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:344 errors:0 dropped:0 overruns:0 frame:0
TX packets:155 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:34439 (33.6 Kb) TX bytes:18427 (17.9 Kb)
Interrupt:11 Base address:0xe000
eth1 Link encap:Ethernet HWaddr 00:C0:26:F0:12:81 Media:unknown(auto)
inet addr:192.168.1.222 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST DEBUG NOTRAILERS RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:353 errors:0 dropped:0 overruns:0 frame:0
TX packets:154 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:35013 (34.1 Kb) TX bytes:18509 (18.0 Kb)
Interrupt:10
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:561 (561.0 b) TX bytes:561 (561.0 b)
我看到第二块网卡的MAC同eth0一样?
xinyv 回复于:2003-12-05 11:33:11
请问在/etc/modules.conf 中配置中
options bond0 miimon=100 mode=0
其中mode可以付0、1、2、3这些值都有什么用途。
如何测试我现在mode的值是什么。如何测试我加载的模块。
如果单纯要把一个ip帮定在多个网卡上实现冗余,我看用下面的方法比较简单。
touch bonding.sh
chmod 755 bonding.sh
mv bonding.sh /etc/rc.d/
echo '/etc/rc.d/bonding.sh'>;>;/etc/rc.d/rc.local
cat >;/etc/rc.d/bonding<<!
#!/bin/sh
ifdown eth0 eth1 eth2 ……
ifconfig bond0 addr xxx.xxx.xxx.xxx/xx
ifenslave bond0 eth0 eth1 eth2 ……
!
就这样就能实现。我想知道那些miimon=100 是默认的,mode=那些值的用法和如何测试。请高手释疑!
LES28 回复于:2004-02-03 11:12:59
/etc/modules.conf 中options这一行可以不写。系统自动默认为:
mode=0 miimon=0
miimon是用来进行链路监测的。
比如:miimon=100,那么系统每100ms监测一次链路连接状态,如果有一条线路不通就转入另一条线路。
mode的参数可以设置为0,1,2,3
一般情况下都只用到0和1,除非你的网卡不支持miimon。而现在通用的网卡基本上都是支持miimon即链路监测的。
注意:bonding只能提供链路监测,即从主机到交换机的链路是否接通。如果只是交换机对外的链路down掉了,而交换机本身并没有故障,那么bonding会认为链路没有问题而继续使用,这时如果你的mode=0,那么会丢一半的数据包,如果mode=1,那么网络就会全部不通了。
其实具体的文档在内核版本高于2.4的linux中都有。位于/usr/src/linux-2.4.18/Document/network/bonding.txt 。
shfjaxl 回复于:2004-11-26 10:27:02
在HP-UNIX上怎么绑定啊?
|