« 使用 SME Server 建置中小企業級伺服器 | 首頁 | 改造 La Fonera: Repeater + Access Point »
2007年03月12日
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=novi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
HWADDR=xx:xx:xx:xx:xx:xxvi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
HWADDR=xx:xx:xx:xx:xx:xxvi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=myhost
GATEWAY=192.168.0.254vi /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): 0Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:xxSlave 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.bonding
- Linux 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
1.請問一下intel MT SERVER的網卡可以支援acer server主機內建網卡嗎?至於intel的網卡驅動在linux中的是什麼代號呢?
2.使用mode6後另一張網卡會不會完全無反應(連線燈都不會亮)。
Posted by: ckt at 2007年05月06日 03:26
1. 以 Intel EtherExpressPro (PCI PRO/100) 網卡為例, 它的 driver name 是 eepro100
若您指的是 Intel PRO/1000 MT Server 網卡的話, 請參考這個網址:
http://support.intel.com/support/network/adapter/pro100/21397.htm
2. 只要線有通, 連線指示燈都會亮著
Posted by: Jamyy at 2007年05月07日 14:03
Mode 4
http://www.geego.com.tw/tech/tech_word/20060821/index.htm#
Posted by: Anonymous at 2007年10月11日 12:20
您好
想請問一下,我按照您所說的方式設定,為什麼執行service network restart 會出現bond0使用eth0的HWaddr,並且叫我修改eth0的MAC address,以避免干擾。謝謝!
Posted by: Chris at 2007年10月16日 22:02
我是直接執行 "手動啟用 bonding" 這個步驟之後, 執行 service network restart 才發生如您所說的問題
若是這樣的話, 請先執行 modprobe -r bonding 卸載 bonding 模組後, 再執行 service network restart 就不會發生這種問題了
Posted by: Jamyy at 2007年10月18日 10:32
1.如果bonding成功,那要怎麼測試知道它throughput
2.可以用兩台電腦對接用cross over線,看許多文章好像都提到要用switch
Posted by: loveworld at 2007年11月14日 17:16
1. 最簡單的方式就是用 FTP 傳輸大檔來測試囉
2. 那個 switch 可不是一般的 switch hub 哦, 是要支援 trunk 功能的 switch (請參考: http://tw.knowledge.yahoo.com/question/?qid=1306062706515)
Posted by: Jamyy at 2007年11月15日 10:43