1. 程式人生 > >linux下多網卡綁定

linux下多網卡綁定

linux負載均衡interface服務器iodelay

假定將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。

在modprobe.conf文件中,

miimon參數用來監測網卡物理連接,建議至少設為100

mode參數用來設置綁定模式

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. 具體內容如下:

[[email protected] network-scripts]# pwd
/etc/sysconfig/network-scripts
[[email protected]
/* */ network-scripts]# cat ifcfg-bond0 DEVICE=bond0 BOOTPROTE=static ONBOOT=yes IPADDR=192.*.*.* NETMASK=255.255.255.0 USERTCL=no GATEWAY=192.*.*.*
[[email protected] network-scripts]# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERTCL=no
MASTER=bond0
SLAVE=yes
[[email protected]
/* */ network-scripts]# cat ifcfg-eth1 DEVICE=eth1 BOOTPROTO=none ONBOOT=yes TYPE=Ethernet USERTCL=no MASTER=bond0 SLAVE=yes
[[email protected] network-scripts]# cat ifcfg-eth2
DEVICE=eth2
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERTCL=no
MASTER=bond0
SLAVE=yes
[[email protected] network-scripts]# cat ifcfg-eth3
DEVICE=eth3
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERTCL=no
MASTER=bond0
SLAVE=yes

(3)查看bond0的狀態

[[email protected] ~]# more /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.3-rh (June 8, 2005)
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
802.3ad info
LACP rate: slow
Active Aggregator Info:
        Aggregator ID: 1
        Number of ports: 4
        Actor Key: 17
        Partner Key: 480
        Partner Mac Address: 00:12:f2:cd:68:00
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:1e:0b:73:56:26
Aggregator ID: 1
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:1e:0b:73:56:a2
Aggregator ID: 1
Slave Interface: eth2
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:1e:0b:d5:34:d2
Aggregator ID: 1
Slave Interface: eth3
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:1e:0b:d5:34:d0
Aggregator ID: 1

然後在交換機(這裏的交換機是Foundry)端做TRUNK

將同一臺服務器的多個網卡捆綁成一條邏輯的線路來使用,提高服務器與交換機之間的帶寬,並且能夠負載均衡多個網卡上的流量,以及多個網卡之間的冗余當其中一個網卡壞了其它的網卡會平分壞網卡上的流量 ,並不影響服務器與交換機之間的數據轉發。註 如果交換機配置為trunk 那麽服務器段也要做相應的配置 trunk 才能被正確的使用

  [email protected]_SX_1600#show trunk 
Configured trunks:
Trunk ID: 897
Hw Trunk ID: 6
Ports_Configured: 4
Primary 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: 901
Hw Trunk ID: 11
Ports_Configured: 4
Primary Port Monitored: Jointly
Ports         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 已經生效


然後在交換機(這裏的交換機是Foundry)端做TRUNK

將同一臺服務器的多個網卡捆綁成一條邏輯的線路來使用,提高服務器與交換機之間的帶寬,並且能夠負載均衡多個網卡上的流量,以及多個網卡之間的冗余當其中一個網卡壞了其它的網卡會平分壞網卡上的流量,並不影響服務器與交換機之間的數據轉發。註 如果交換機配置為trunk 那麽服務器段也要做相應的配置 trunk 才能被正確的使用

  [email protected]_SX_1600#show trunk
Configured trunks:
Trunk ID: 897
Hw Trunk ID: 6
Ports_Configured: 4
Primary 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: 901
Hw Trunk ID: 11
Ports_Configured: 4
Primary Port Monitored: Jointly
Ports         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 已經生效

在modprobe.conf文件中,

miimon參數用來監測網卡物理連接,建議至少設為100

mode參數用來設置綁定模式

0負載均衡(round robin策略)

1 active/backup模式,同一時間只有一塊網卡使用。

2負載均衡(xor算法)

3廣播模式

4 802.3ad模式,lagp協議,帶寬翻倍。

模式不能寫錯


本文出自 “11726068” 博客,謝絕轉載!

linux下多網卡綁定