Linux Bonding (合併網卡) 實作 --Jamyy‘s Weblog

来源:百度文库 编辑:神马文学网 时间:2024/04/20 23:41:21
Linux Bonding (合併網卡) 實作
目的
網卡自動備援 增加傳輸頻寬 多網卡負載平衡
實作環境
Fedora Core 3 Linux Realtek RTL8139 PCI Fast Ethernet NIC * 2 (driver: 8139too) LAN: 192.168.0.0/24; Linux Host: 192.168.0.1; Gateway: 192.168.0.254
環境設定
vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.0.1
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
HWADDR=xx:xx:xx:xx:xx:xx
vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
HWADDR=xx:xx:xx:xx:xx:xx
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=myhost
GATEWAY=192.168.0.254
vi /etc/modprobe.conf
alias bond0 bonding
options bond0 miimon=100 mode=1
手動啟用 bonding (或於完成上述步驟後重新啟動電腦)
service network stop
modprobe bonding miimon=100 mode=1
ifconfig bond0 192.168.0.1 netmask 255.255.255.0
ifenslave bond0 eth0 eth1
route add default gw 192.168.0.254 dev bond0
查看 bonding 狀態
cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.0 (January 14, 2004)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: none
Currently Active Slave: eth0
MII Status: up
MII Polling Internal (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:xx
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:xx
bonding modes
數字表示 文字表示 說明
0 balance-rr 負載平衡模式, 需有 switch 設定 (trunk) 支援才能發揮實質效果
具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
1 active-backup 同一時間只有單一 Slave 網卡運作
Active Slave 網卡失效時自動啟用次一順位 Slave 網卡
不需 switch 支援
2 balance-xor *未研究*
3 broadcast 所有 Slave 網卡一齊收送網路封包
具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
4 802.3ad *未研究*
5 balance-tlb 傳出自動負載平衡
傳入由 Current Active Slave 負責
具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
不需 switch 支援及設定
6 balance-alb 傳出及傳入皆自動負載平衡
具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
Slave 網卡 driver 需支援 setting hardware address 功能
不需 switch 支援及設定
備註 - 關於螃蟹卡 (8139too):
無法支援 mode 6 (balance-alb), 錯誤訊息如下
bonding: Error: dev->set_mac_address of dev eth0 failed! ALB mode requires that the base driver support setting the hw address also when the network device‘s interface is open
參考資料
/usr/share/doc/iputils-20020927/README.bondingLinux Ethernet Bonding Driver HOWTO聯成電腦講師專欄: 使用 BONDING 網路功能 by 小州老師
Posted by Jamyy at 2007年03月12日 09:12
Trackback Pings
TrackBack URL for this entry:
http://cha.homeip.net/cgi-bin/mt/mt-tb.cgi/263
Comments
您好 請教一下唷
如何開機自動掛上bonding呢
Posted by: MARK at 2007年03月29日 16:02
您好!
若要開機自動 bonding
編輯以下這些檔案就行了 (fedora & redhat-like distro)
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-*
/etc/modprobe.conf
Posted by: Jamyy at 2007年03月29日 16:13
您好唷
這些檔案 要掛上哪些東西呢??
Posted by: Mark at 2007年04月06日 21:48
不好意思看不太懂您的問題
如果您是指 "需掛載什麼東西" 的話..
只需掛載 "bonding" 這個 kernel module 即可
Posted by: Jamyy at 2007年04月07日 21:38
安安~~
現在只是搞不懂,要編輯哪些東西才能開機啟動
能否請您po出來可以嗎?
Posted by: Mark at 2007年04月17日 20:22
您好, 請編輯以下這些檔案:
/etc/sysconfig/network-scripts/ifcfg-bond0
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/sysconfig/network
/etc/modprobe.conf
編輯內容請參見本文
Posted by: Jamyy at 2007年04月17日 21:12
您好
想請問一下
在bonding mode=6的模式下
我上次有試過mode 6
但是好像只看到一張卡在動
是setting hardware address不支援的關係嗎
要如何得知硬體支不支援呢
有指令可以試嗎
謝謝
Posted by:akong at 2007年04月18日 16:49
您好!
bonding mode 6 真是個令人嚮往的好模式
我也想在網路上找出有什麼網卡可以支援這個模式
不過總是找不出個所以然來
今天突然靈機一動, 到 kernel source (/usr/src/linux/drivers/net)
用這個指令:
grep -l set_mac_address `find ./ -type f`
找出了一堆網卡 driver
我想, 這應該就是答案了吧!
Posted by: Jamyy at 2007年04月18日 17:26
from: http://cha.homeip.net/blog/archives/2007/03/linux_bonding.html#more