OEL6.4(BOND)雙網路卡繫結實戰—附加說明

muxinqing發表於2015-05-24
操作環境
Oracle Linux Server release 6.4
核心
Linux rac1 2.6.39-400.17.1.el6uek.x86_64

[root@RAC-2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0

BOOTPROTO=static

IPADDR=192.168.254.2

NETMASK=255.255.255.0

ONBOOT=yes

TYPE=Ethernet

GATEWAY=192.168.254.1

USERCTL=no

ARPCHECK=no


"/etc/sysconfig/network-scripts/ifcfg-bond0" [New] 17L, 163C written

[root@RAC-2 ~]# cd /etc/sysconfig/network-scripts/

[root@RAC-2 network-scripts]# vi ifcfg-eth1

DEVICE=eth1

BOOTPROTO=none

ONBOOT=yes

USERCTL=no

MASTER=bond0

SLAVE=yes
~
"ifcfg-eth1" 11L, 77C written
[root@RAC-2 network-scripts]# vi ifcfg-eth2
DEVICE=eth2

BOOTPROTO=none

ONBOOT=yes

USERCTL=no

MASTER=bond0

SLAVE=yes
~
"ifcfg-eth2" 11L, 77C written
[root@RAC-2 network-scripts]# vi /etc/modprobe.d/modprobe.conf

alias bond0 bonding

options bond0 miimon=100 mode=1
~
~
"/etc/modprobe.d/modprobe.conf" [New] 4L, 54C written
說明:
miimon是用來進行鏈路監測的,比如:miimon=100,那麼系統每100ms監測一次鏈路連線狀態,如果有一條線路不通就轉入另一條線路;mode的值表示工作模式,他共有0,1,2,3四種模式,常用的為0,1兩種。
mode=0表示load balancing (round-robin)為負載均衡方式,兩塊網路卡都工作。
mode=1表示fault-tolerance (active-backup)提供冗餘功能,工作方式是主備的工作方式,也就是說預設情況下只有一塊網路卡工作,另一塊做備份.


[root@RAC-2 network-scripts]# vi /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
ifenslave bond0 eth2 eth1
~
"/etc/rc.d/rc.local" 8L, 246C written
[root@RAC-2 network-scripts]# ifconfig  bond0 192.168.254.2 up

#[root@rac4 network-scripts]# ifenslave  bond0 eth2 eth1
Illegal operation: The specified slave interface 'eth0' is already a slave


最後重啟伺服器:

[root@rac4 ~]# reboot

從下面BOND網路卡已經啟動了
[root@RAC-2 ~]# ifconfig
bond0     Link encap:Ethernet  HWaddr 08:00:27:E7:1F:5D  
          inet addr:192.168.254.2  Bcast:192.168.254.1  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fee7:1f5d/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:35 errors:0 dropped:15 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2498 (2.4 KiB)  TX bytes:1028 (1.0 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:E7:1F:5D  
          inet addr:192.168.254.2  Bcast:192.168.254.255  Mask:255.255.255.0
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:87 errors:0 dropped:12 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6411 (6.2 KiB)  TX bytes:288 (288.0 b)

eth2      Link encap:Ethernet  HWaddr 08:00:27:99:BE:CC  
          inet addr:192.168.254.2  Bcast:192.168.254.255  Mask:255.255.255.0
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:73 errors:0 dropped:62 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4935 (4.8 KiB)  TX bytes:740 (740.0 b)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:240 (240.0 b)  TX bytes:240 (240.0 b)

下面看當前活動網路卡ech1,狀態是啟動
[root@RAC-2 ~]#  cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:e7:1f:5d
Slave queue ID: 0

Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 08:00:27:99:be:cc
Slave queue ID: 0

七種bond模式說明:
 
第一種模式:mod=0 ,即:(balance-rr) Round-robin policy(平衡掄迴圈策略)
 
特點:傳輸資料包順序是依次傳輸(即:第1個包走eth0,下一個包就走eth1….一直迴圈下去,直到最後一個傳輸完畢),此模式提供負載平衡和容錯能力;但是我們知道如果一個連線或者會話的資料包從不同的介面發出的話,中途再經過不同的鏈路,在客戶端很有可能會出現資料包無序到達的問題,而無序到達的資料包需要重新要求被髮送,這樣網路的吞吐量就會下降
 
第二種模式:mod=1,即: (active-backup) Active-backup policy(主-備份策略)
 
特點:只有一個裝置處於活動狀態,當一個宕掉另一個馬上由備份轉換為主裝置。mac地址是外部可見得,從外面看來,bond的MAC地址是唯一的,以避免switch(交換機)發生混亂。此模式只提供了容錯能力;由此可見此演算法的優點是可以提供高網路連線的可用性,但是它的資源利用率較低,只有一個介面處於工作狀態,在有 N 個網路介面的情況下,資源利用率為1/N
 
第三種模式:mod=2,即:(balance-xor) XOR policy(平衡策略)
 
特點:基於指定的傳輸HASH策略傳輸資料包。預設的策略是:(源MAC地址 XOR 目標MAC地址) % slave數量。其他的傳輸策略可以透過xmit_hash_policy選項指定,此模式提供負載平衡和容錯能力
 
第四種模式:mod=3,即:broadcast(廣播策略)
 
特點:在每個slave介面上傳輸每個資料包,此模式提供了容錯能力
 
第五種模式:mod=4,即:(802.3ad) IEEE 802.3adDynamic link aggregation(IEEE 802.3ad 動態連結聚合)
 
特點:建立一個聚合組,它們共享同樣的速率和雙工設定。根據802.3ad規範將多個slave工作在同一個啟用的聚合體下。
 
外出流量的slave選舉是基於傳輸hash策略,該策略可以透過xmit_hash_policy選項從預設的XOR策略改變到其他策略。需要注意的是,並不是所有的傳輸策略都是802.3ad適應的,尤其考慮到在802.3ad標準43.2.4章節提及的包亂序問題。不同的實現可能會有不同的適應性。
 
必要條件:
 
條件1:ethtool支援獲取每個slave的速率和雙工設定
 
條件2:switch(交換機)支援IEEE 802.3ad Dynamic link aggregation
 
條件3:大多數switch(交換機)需要經過特定配置才能支援802.3ad模式
 
第六種模式:mod=5,即:(balance-tlb) Adaptive transmit load balancing(介面卡傳輸負載均衡)
 
特點:不需要任何特別的switch(交換機)支援的通道bonding。在每個slave上根據當前的負載(根據速度計算)分配外出流量。如果正在接受資料的slave出故障了,另一個slave接管失敗的slave的MAC地址。
 
該模式的必要條件:ethtool支援獲取每個slave的速率
 
第七種模式:mod=6,即:(balance-alb) Adaptive load balancing(介面卡適應性負載均衡)
 
特點:該模式包含了balance-tlb模式,同時加上針對IPV4流量的接收負載均衡(receive load balance, rlb),而且不需要任何switch(交換機)的支援。接收負載均衡是透過ARP協商實現的。bonding驅動截獲本機傳送的ARP應答,並把源硬體地址改寫為bond中某個slave的唯一硬體地址,從而使得不同的對端使用不同的硬體地址進行通訊。

Multiple network card binding Edite /etc/modprobe.d/modprobe.conf

alias bond0 bonding

alias bond1 bonding

options bonding  miimon=100 mode=1 max_bonds=2

OR

alias bond0 bonding

options bonding mode=1 miimon=100

alias bond1 bonding

options bonding mode=1 miimon=100

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

相關文章