1、立即關閉iptables并禁用開機自啟動
[root@mysql01 ~]# /etc/init.d/iptables stop
[root@mysql01 ~]# chkconfig iptables off
2.1 停止NetworkManager
[root@mysql01 ~]# service NetworkManager stop
2.2 開機自啟動關閉
[root@mysql01 ~]# chkconfig NetworkManager off
3、 在/etc/modprobe.d/目錄下建立檔案bonding.conf,配置系統加載 binding 子產品,添加如下内容:
[root@mysql01 ~]# touch /etc/modprobe.d/bonding.conf
alias bond0 bonding
4、 相關網卡配置
4.1、
cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE="bond0"
ONBOOT="yes"
#UUID=0470e854-c231-4f09-8b33-be707e619b1a
NM_CONTROLLED=no
IPADDR=135.125.21.85 #你所設定的IP
NETMASK=255.255.255.0
GATEWAY=135.125.21.254
BONDING_OPTS="mode=1 miimon=100"
BOOTPROTO=none
說明:使用預設的mode=1(active-backup)作為主備關系,miimon是毫秒數,每100毫秒觸發檢測線路穩定性的事件。
4.2、
cat /etc/sysconfig/network-script/ifcfg-eth1
DEVICE="eth1"
#HWADDR="00:0C:29:44:29:84"
MASTER=bond0
SLAVE=yes
4.3、
cat /etc/sysconfig/network-script/ifcfg-eth2
DEVICE="eth2"
#HWADDR="00:0C:29:44:29:8E"
5、 重新開機網卡
[root@mysql01 ~]# service network restart
[root@mysql01 ~]# ifconfig
說明:正常情況下,bond0 eth1 eth2 的 HWaddr 相同
6、附加 Slave 接口到 bond0 ,vi /etc/rc.d/rc.local 使綁定網卡立即生效,添加如下資訊: ifenslave bond0 eth1 eth2
[root@mysql01 ~]# vi /etc/rc.d/rc.local
ifenslave bond0 eth1 eth2
7、測試綁定網絡
# cat /proc/net/bonding/bond0 (檢視網卡綁定模式)
ping 業務ip網關
補充:mode 的模式,一共有7種方式:
=0: (balance-rr) Round-robin policy: (平衡掄循環政策):傳輸資料包順序是依次傳輸,直到最後一個傳輸完畢, 此模式提供負載平衡和容錯能力。
=1: (active-backup) Active-backup policy:(主-備份政策):隻有一個裝置處于活動狀态。 一個宕掉另一個馬上由備份轉換為主裝置。mac位址是外部可見得。 此模式提供了容錯能力。
=2:(balance-xor) XOR policy:(廣播政策):将所有資料包傳輸給所有接口。 此模式提供了容錯能力。
=3:(balance-xor) XOR policy:(平衡政策): 傳輸根據原位址布爾值選擇傳輸裝置。 此模式提供負載平衡和容錯能力。
=4:(802.3ad) IEEE 802.3ad Dynamic link aggregation.IEEE 802.3ad 動态連結聚合:建立共享相同的速度和雙工設定的聚合組。
=5:(balance-tlb) Adaptive transmit load balancing(擴充卡傳輸負載均衡):沒有特殊政策,第一個裝置傳不通就用另一個裝置接管第一個裝置正在處理的mac位址,幫助上一個傳。
=6:(balance-alb) Adaptive load balancing:(擴充卡傳輸負載均衡):大緻意思是包括mode5,bonding驅動程式截獲 ARP 在本地系統發送出的請求,用其中之一的硬體位址覆寫從屬裝置的原位址。就像是在伺服器上不同的人使用不同的硬體位址一樣。
網卡綁定與交換機關系:
網卡 bond mode=0 、 交換機不做配置
網卡 bond mode=1 、 交換機做聚合
網卡 bond mode=4 、 交換機做聚合 + 802.3 AD
網卡綁定解除:
删除ifcfg-bond0,和删除/etc/modprobe.d/bonding.conf
修改ifcfg-eth0和ifcfg-eth0為綁定之前的樣子
rmmod bonding(很重要)
service network restart
文章可以轉載,必須以連結形式标明出處。
本文轉自 張沖andy 部落格園部落格,原文連結: http://www.cnblogs.com/andy6/p/7360049.html ,如需轉載請自行聯系原作者