像流媒體傳輸之類的服務器使用單網卡負載過高,可能造成畫面卡頓情況,爲緩解網絡壓力,特進行雙網卡綁定。
這裏我們將2塊1GB的網卡進行綁定,使其帶寬達到2GB,從而減少網絡擁塞。
1.修改/etc/sysconfig/network-scripts/ifcfg-eth0/1配置文檔,內容如下:
BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes
2.創建一個綁定網絡口的配置文檔/etc/sysconfig/network-scripts/ifcfg-bond0,內容如下:
DEVICE=bond0 BOOTPROTO=static IPADDR=52.110.1.2 NETMASK=255.255.255.0 GATEWAY=52.110.1.1 BORADCAST=52.110.1.255 ONBOOT=yes TYPE=Ethernet
3.修改/etc/modprobe.d/dist.conf,配置綁定模型,配置文件最後加入以下內容:
alias bond0 bonding options bond0 miimon=100 mode=0
#選項 millmon 是指定隔多長時間來進行鏈路監測,單位是ms。
#選項 mode 是表示綁定口的工作模式,有0-7共7種模式,常用的有0和1模式,mode=0表示"round-robin"策略,兩張卡同時工作在負載均衡狀態。mode=1表示"active-backup"策略,兩張卡一用一備的備份狀態。
4. 修改的是/etc/rc.local,負責在系統啓動時將虛擬網卡和兩張物理網卡相綁定,增加以下內容:
echo "ifenslave bond0 eth0 eth1" >>/etc/rc.local
5.重啓網卡,使其生效
service network restart
注意:將networkmanager服務關閉並設置爲開機不啓動 以防止干擾相關的操作
service NetworkManager stop chkconfig NetworkManager off
測試:關閉其中任何一塊綁定的網卡,網絡不受影響。
附:測試網卡接口速度 ethtool
[root@dahuatech ~]# ethtool eth0 Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: No Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on MDI-X: off Supports Wake-on: pumbg Wake-on: g Current message level: 0x00000007 (7) drv probe link Link detected: yes