linux下多網卡綁定 假定將eth0,eth1,eth2,eth3綁定成bond0, 步驟如下:(1) #vi /etc/modprobe.conf, 添加如下2行: alias bond0 bonding options bonding miimon=100 mode=4 當mode=0時,交換器相應連接埠不需要做trunk,但是從節點上ping網關(192.*.*.*)有較大的延時。解決此問題的辦法是把mode改成4,同時配置交換器相應連接埠開啟鏈路彙總並捆綁為trunk。 www.2cto.com 在modprobe.conf檔案中,miimon參數用來監測網卡物理串連,建議至少設為100mode參數用來設定繫結模式0 負載平衡(round robin策略)1 active/backup模式,同一時間只有一塊網卡使用。2 負載平衡(xor演算法)3 廣播模式4 802.3ad模式,lagp協議,頻寬翻倍。模式不能寫錯 這裡很容易出現不穩定的情況,多半是這裡模式選擇錯了,所以在實施的時候需要小心,把模式確定了,然後在動手。 (2)修改/etc/sysconfig/network-scripts/目錄下的ifcfg-bond0, ifcfg-eth0, ifcfg-eth1,ifcfg-eth2,ifcfg-eth3. 具體內容如下:[root@io102 network-scripts]# pwd/etc/sysconfig/network-scripts[root@io102 network-scripts]# cat ifcfg-bond0DEVICE=bond0BOOTPROTE=staticONBOOT=yesIPADDR=192.*.*.*NETMASK=255.255.255.0USERTCL=noGATEWAY=192.*.*.*[root@io102 network-scripts]# cat ifcfg-eth0DEVICE=eth0BOOTPROTO=noneONBOOT=yesTYPE=EthernetUSERTCL=noMASTER=bond0SLAVE=yes[root@io102 network-scripts]# cat ifcfg-eth1DEVICE=eth1BOOTPROTO=noneONBOOT=yesTYPE=EthernetUSERTCL=noMASTER=bond0SLAVE=yes[root@io102 network-scripts]# cat ifcfg-eth2DEVICE=eth2BOOTPROTO=noneONBOOT=yesTYPE=EthernetUSERTCL=noMASTER=bond0SLAVE=yes[root@io102 network-scripts]# cat ifcfg-eth3DEVICE=eth3BOOTPROTO=noneONBOOT=yesTYPE=EthernetUSERTCL=noMASTER=bond0SLAVE=yes www.2cto.com (3)查看bond0的狀態[root@io102 ~]# more /proc/net/bonding/bond0Ethernet Channel Bonding Driver: v2.6.3-rh (June 8, 2005)Bonding Mode: IEEE 802.3ad Dynamic link aggregationMII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0802.3ad infoLACP rate: slowActive Aggregator Info: Aggregator ID: 1 Number of ports: 4 Actor Key: 17 Partner Key: 480 Partner Mac Address: 00:12:f2:cd:68:00Slave Interface: eth0MII Status: upLink Failure Count: 0Permanent HW addr: 00:1e:0b:73:56:26Aggregator ID: 1Slave Interface: eth1MII Status: upLink Failure Count: 0Permanent HW addr: 00:1e:0b:73:56:a2Aggregator ID: 1Slave Interface: eth2MII Status: upLink Failure Count: 0Permanent HW addr: 00:1e:0b:d5:34:d2Aggregator ID: 1Slave Interface: eth3MII Status: upLink Failure Count: 0Permanent HW addr: 00:1e:0b:d5:34:d0Aggregator ID: 1
然後在交換器(這裡的交換器是Foundry)端做TRUNK將同一台伺服器的多個網卡捆綁成一條邏輯的線路來使用,提高伺服器與交換器之間的頻寬,並且能夠負載平衡多個網卡上的流量,以及多個網卡之間的冗餘當其中一個網卡壞了其它的網卡會平分壞網卡上的流量 ,並不影響伺服器與交換器之間的資料轉寄。注 如果交換器配置為trunk 那麼伺服器段也要做相應的配置 trunk 才能被正確的使用 BR-telnet@YJY_SX_1600#show trunk Configured trunks:Trunk ID: 897Hw Trunk ID: 6Ports_Configured: 4Primary Port Monitored: Jointly Ports 15/1 15/2 15/3 15/4 Port Names none none none none Port_Status enable enable enable enable Monitor off off off off Rx Mirr Port N/A N/A N/A N/A Tx Mirr Port N/A N/A N/A N/A Monitor Dir N/A N/A N/A N/A Trunk ID: 901Hw Trunk ID: 11Ports_Configured: 4Primary Port Monitored: JointlyPorts 15/5 15/6 15/7 15/8 Port Names none none none none Port_Status enable enable enable enable Monitor off off off off Rx Mirr Port N/A N/A N/A N/A Tx Mirr Port N/A N/A N/A N/A Monitor Dir N/A N/A N/A N/A
查看如上的紅色標註資訊 連接埠狀態是enable 本組trunk 包括 15/5 15/6 15/7 15/8 這4個連接埠 本組trunk 已經生效 www.2cto.com 然後在交換器(這裡的交換器是Foundry)端做TRUNK將同一台伺服器的多個網卡捆綁成一條邏輯的線路來使用,提高伺服器與交換器之間的頻寬,並且能夠負載平衡多個網卡上的流量,以及多個網卡之間的冗餘當其中一個網卡壞了其它的網卡會平分壞網卡上的流量,並不影響伺服器與交換器之間的資料轉寄。注 如果交換器配置為trunk 那麼伺服器段也要做相應的配置 trunk 才能被正確的使用 BR-telnet@YJY_SX_1600#show trunkConfigured trunks:Trunk ID: 897Hw Trunk ID: 6Ports_Configured: 4Primary Port Monitored: JointlyPorts 15/1 15/2 15/3 15/4 Port Names none none none none Port_Status enable enable enable enable Monitor off off off off Rx Mirr Port N/A N/A N/A N/A Tx Mirr Port N/A N/A N/A N/A Monitor Dir N/A N/A N/A N/A Trunk ID: 901Hw Trunk ID: 11Ports_Configured: 4Primary Port Monitored: JointlyPorts 15/5 15/6 15/7 15/8 Port Names none none none none Port_Status enable enable enable enable Monitor off off off off Rx Mirr Port N/A N/A N/A N/A Tx Mirr Port N/A N/A N/A N/A Monitor Dir N/A N/A N/A N/A 查看如上的紅色標註資訊 連接埠狀態是enable 本組trunk 包括 15/5 15/6 15/7 15/8 這4個連接埠 本組trunk 已經生效 www.2cto.com 在modprobe.conf檔案中,miimon參數用來監測網卡物理串連,建議至少設為100mode參數用來設定繫結模式0 負載平衡(round robin策略)1 active/backup模式,同一時間只有一塊網卡使用。2 負載平衡(xor演算法)3 廣播模式4 802.3ad模式,lagp協議,頻寬翻倍。模式不能寫錯