- 論壇徽章:
- 0
|
Linux Channel Bonding可以支持把多個網絡適配器集合在一起, 當作一個網絡適配器來使用。在 Linux 下,網卡的高可用性是通過 MII 或者 ETHTOOL 的狀態(tài)監(jiān)測來實現(xiàn)的,所以,需要檢查系統(tǒng)中的網絡適配器是否支持 MII 或者ETHTOOL 的連狀態(tài)監(jiān)測。可以用命令 "ethtool eth0" 來檢查,如果顯示的 "Link detected:" 信息與實現(xiàn)的連接狀態(tài)一致,就沒有問題。如果系統(tǒng)中的網絡適配器不支持 MII 或者 ETHTOOL 狀態(tài)監(jiān)測,當連接失效時,系統(tǒng)就不能檢測到,同時,在 bonding 驅動加載時,會記錄一條不支持 MII 和 ETHTOOL 的警告信息。
環(huán)境: Red Hat Enterprise Linux 4 Update1
1.加載bonding模塊(Red Hat Enterprise Linux 4 Update1中內核中包含bonding模塊)
我們需要在modprobe.conf文件中加入兩行,這樣才可以在設置了 bond 設置后,系統(tǒng)啟動的時候自動加載 bonding 的驅動程序
install bond0 /sbin/modprobe -a eth0 eth1 && /sbin/modprobe bonding
options bonding mode=0 miimon=100
這里指定eth0,eth1為兩個需要綁定的網卡。
如:
#vi /etc/modprobe.conf
alias eth0 e1000
alias eth1 e1000
install bond0 /sbin/modprobe -a eth0 eth1 && /sbin/modprobe bonding
options bonding mode=6 miimon=100
如果需要綁定多個網卡,那么設置為:
alias eth0 e1000
alias eth1 e1000
alias eth2 tg3
alias eth3 tg3
install bond0 /sbin/modprobe -a eth0 eth1 && /sbin/modprobe bonding
install bond1 /sbin/modprobe -a eth2 eth3 && /sbin/modprobe bonding
options bonding mode=6 miimon=100 max_bonds=2
其中:
miimon 是指多久時間檢查網絡一次,單位是ms(毫秒),其意義是假設其中有一條網絡斷線,會在0.1秒內自動備援
mode 共有七種模式(0~6)
mode=0:負載均衡模式,有自動備援,但需要"Switch"支持和設定。
mode=1:自動備援模式,其中一條線若斷線,其他線路將會自動備援。
mode=6:負載均衡模式,有自動備援,不需要"Switch"支持和設定。
max_bonds 為bonging的數(shù)量
2.配置bonding
#cd /etc/sysconfig/network-scripts
#vi ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
TYPE=Ethernet
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
在 bond 中的所有網絡適配器的腳本中,都要有 SLAVE 和 MASTER 的定義。例如,如果要讓eth0和eth1成為bond0的成員,它們對應的配置文件(ifcfg-eth0和ifcfg-eth1)就要仿照下面的內容進行更改:
如:
#vi ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
#vi ifcfg-eth1
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
3.重新啟動網絡
#service network restart
4.驗證bonging狀態(tài)
# ifconfig
bond0 Link encap:Ethernet HWaddr 00:0F:1F:6B:5E:96
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.252.0
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:19552 errors:0 dropped:0 overruns:0 frame:0
TX packets:2011 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2156066 (2.0 Mb) TX bytes:236358 (230.8 Kb)
eth0 Link encap:Ethernet HWaddr 00:0F:1F:6B:5E:96
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.252.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:9787 errors:0 dropped:0 overruns:0 frame:0
TX packets:1006 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1078288 (1.0 Mb) TX bytes:119413 (116.6 Kb)
Interrupt:28
eth1 Link encap:Ethernet HWaddr 00:0F:1F:6B:5E:96
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.252.0
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:9765 errors:0 dropped:0 overruns:0 frame:0
TX packets:1005 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1077778 (1.0 Mb) TX bytes:116945 (114.2 Kb)
Interrupt:29
# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.0 (January 14, 2004)
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:0f:1f:6b:5e:96
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0f:1f:6b:5e:97
本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u/815/showart_348105.html |
|