實戰網路卡bond

大雄45發表於2022-06-01

一、什麼是網路卡bond

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

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

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

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

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

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

三、網路卡bond前期準備

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

$lspci|grep net

實戰網路卡bond實戰網路卡bond

檢視網路卡2的資訊,Link detected:yes表示有網線插入

$ethtool eth2

實戰網路卡bond實戰網路卡bond

如果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

實戰網路卡bond實戰網路卡bond
七、用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

實戰網路卡bond實戰網路卡bond

本文地址:


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69955379/viewspace-2898360/,如需轉載,請註明出處,否則將追究法律責任。

相關文章