歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> 實戰網卡bond

實戰網卡bond

日期:2017/3/6 9:44:41   编辑:學習Linux

實戰網卡bond


實戰網卡bond


一、什麼是網卡bond

所謂bond,就是把多個物理網卡綁定成一個邏輯上的網卡,使用同一個IP工作,在增加帶寬的同時也可以提高冗余性,一般使用較多的就是來提高冗余,分別和不同交換機相連,提高可靠性,但有時服務器帶寬不夠了也可以用作增加帶寬。
ethernet_bond
二、網卡bond的模式

網卡綁定mode共有七種(0~6) bond0、bond1、bond2、bond3、bond4、bond5、bond6。 常用的有三種:

mode=0:平衡負載模式,有自動備援,但需要”Switch”支援及設定。

mode=1:自動備援模式,其中一條線若斷線,其他線路將會自動備援。

mode=6:平衡負載模式,有自動備援,不必”Switch”支援及設定。

我就我的一次bonding經歷,來給大家分享一下,如何做網卡bond,我這次做的是bond6,在centos6.0上完成。

三、網卡bond前期准備

1.由於服務器網卡比較多,邏輯順序與物理順序不一定一致。首先要確定哪幾塊網卡布置了網線,一般是有兩塊網卡對應兩根網線,分別連接不同的交換機。
查看所有網卡

$lspci|grep net

ethernet_bond_1

查看網卡2的信息,Link detected:yes表示有網線插入

$ethtool eth2

ethernet_bond_2

如果Link detected:no 的話,嘗試用命令ifconfig eth2 up,如果用ethtool查看任然為no的話,才能說明此網卡確實沒有網線插入。

2.注意如果ifcfg-bond0的配置文件如果是從其他網卡配置文件拷貝過來的,HWADDR地址一定要刪除,DEVICE名字要改。

3.NetworkManager要關閉,建議臨時和永久都關閉一下。

$chkconfig NetworkManager off$service NetworkManager stop

四、更改要bond網卡的配置文件

eth2,eth3為bond前的網卡名稱,bond0為bond後的網卡名稱,我們需要對這三個配置文件做更改。

eth2:

$vi /etc/sysconfig/network-scripts/ifcfg-eth2 DEVICE=eth2 HWADDR=44:A8:42:25:7C:FE BOOTPROTO=none ONBOOT=yes SLAVE=yes MASTER=bond0 TYPE=Ethernet

eth3:

$vi /etc/sysconfig/network-scripts/ifcfg-eth3 DEVICE=eth3 HWADDR=44:A8:42:25:7D:01 BOOTPROTO=none ONBOOT=yes SLAVE=yes MASTER=bond0 TYPE=Ethernet

bond0:

$vi /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 BOOTPROTO=static ONBOOT=yes IPADDR=100.100.100.100 NETMASK=255.255.255.0 GATEWAY=100.100.100.1 TYPE=Ethernet

五、配置模式為bond6

$vi /etc/modprobe.d/dist.conf

在最後添加下面2行

 alias bond0 bonding options bond0 miimon=100 mode=6

也可以用下面的命令添加

$sed -i '$a alias bond0 bonding' /etc/modprobe.d/dist.conf$sed -i '$a options bond0 miimon=100 mode=6' /etc/modprobe.d/dist.conf

六、重啟網絡服務

$service network restart

ethernet_bond_3
七、用nload查看流量

$vim /root/.bash_profile
export PATH alias nload='nload -m -s 5 -u m -t 2000 bond0 eth2 eth3'
$source /root/.bash_profile
$nload

ethernet_bond_4



轉載地址:http://www.linuxprobe.com/

http://xxxxxx/Linuxjc/1134327.html TechArticle

Copyright © Linux教程網 All Rights Reserved