Intro of NIC bonding
- NIC bonding就是把兩個(或以上)的ports組合成同一個IP,與上面的IP aliasing剛好相反。在Windows的世界常聽見的是teaming,而在Cisco的世界比較常見trunking這個說法。幸運的是只要你安裝的是本世紀才發行的Linux,kernel都會包含bonding的核心模組,你唯一需要注意的是系統裡是否有ifenslave這隻工具,在使用bonding前系統必須擁有他才能成功bond。
- NIC bonding所期望達成的目標就是頻寬合併(Aggregation),根據不同模式分別提供不同的狀態:負載平衡(load balance)、即時備援(hot redundancy),以及一個簡單監控bonding狀態的工具。
- 觀念上,每張NIC在bonding之後都稱之為slave,組合後的bond為master;對核心來說參與封包傳送的裝置不再是eth0,而是bond0;不過底層的運作還是由ethx處理,bond0其實只是個虛擬裝置,因此如果透過wireshark擷取封包,是無法成功擷取"bond0"的封包的。 (附註:參與bonding的ports可以來自不同NIC,因為底層的工作實際上還是由各自的driver負責;如果你遇到bonding上的問題,建議先使用多ports的NIC比較好釐清問題所在。)
- NIC bonding共有七種模式,有些使用標準的IEEE 802.3,也採用IEEE的802.3ad/802.1ax的標準,也就是Link Aggregation Control Protocol(LACP)。Linux底下的NIC bonding實作在Layer 2(Data-Link Layer),根據Linux Ethernet Bonding Driver HOWTO的說明,NIC bonding的七種模式如下:
- 無論你用哪一套Linux,都無法使用bonding在Network Manager上。在Redhat裡,可以定義NM_CONTROLLER=no而不需真的關閉NetworkManager,但是在Debian/SuSE你必須老實的關閉Network Manager,畢竟server的網路環境哪需要用到Network Manager呢?
Mode | Name | Interpretation | Load Balancing | Fault Tolerance |
---|---|---|---|---|
0 | Round-Robin (balance-rr) | 所有參與bonding的NIC輪流擔任封包的傳送(沒有Active Slave的觀念),但同一時間只有一張NIC真正有作用。普通switch即可啟用。 | YES | YES |
1 | Active-Backup (active-backup) | 參與bonding的NIC只有一張有作用(Active Slave),其餘都處於備援狀態;當其中一張NIC失效後,另一張網卡(slave)才會取而代之。普通switch即可啟用。 | NO | YES |
2 | XOR (balance-xor) | XOR算是mode0的進化版:當主機進行多個連線時,同一個NIC會負責同一個來源位置--也就是盡可能讓同一張NIC負責同一個位置越久越好。普通switch即可啟用。 | YES | YES |
3 | Broadcast (broadcast) | 封包以廣播的方式丟給所有的NIC,所有的NIC也同時接收/傳送所有封包。這個mode擁有最快速的的fault tolerance。普通switch即可啟用。 | NO | YES |
4 | IEEE 802.3ad Dynamic Link Aggregation (802.3ad) | 使用這個業界標準的模式擁有真正的outgoing/incoming balancing,只是不僅NIC driver需要支援ethtool設定,還需要支援802.3ad/802.1ax的switch才行。 | YES | YES |
5 | Adaptive Transmit Load Balancing (balance-tlb) | 這個模式只有outgoing traffic擁有load balancing,incoming只有其中一張NIC負責。當負責incoming的那張NIC失效時,另一個slave才會負責incoming traffice。此模式常用於file/mail server。雖然普通switch即可使用,但是driver必須支援ethtool設定才行。 | NO | YES |
6 | Adaptive Load Balancing (balance-alb) | 利用ARP協商達成每張NIC的incoming balancing--即outcoming balance+incoming balancing。只要普通的switch就能達此要求。也是大部分中小企業主機所選擇的模式。不過driver除了需要支援ethtool之外,還必須能動態改變MAC位置才行。 | YES | YES |
以下幾個重要的options,參考自Linux Ethernet Bonding Driver HOWTO
Bonding Options | Expression |
---|---|
miimon | MII的監控頻率(以millisecond為單位)。當其中一張NIC失效時,MII能多快發現並把工作交給下一張NIC。HOW-TO的建議值為100,預設值為0。 |
arp_interval | ARP的監控頻率(以millisecond為單位)。功能相當於miimon,HOW-TO的建議值為100,預設值為0。設定此變數還必須設定arp_ip_target。 |
arp_ip_target | 指定ARP要監控的IP。此值必須在有指定arp_interval且該值>0才有意義。這個變數會以arp_interval指定的頻率發出請求至指定的位置以決定連線狀態是否正常。多個ip以,作分隔。 |
mode | 就是上表。指定mode可以寫數字或是簡稱,例如mode=4等同於mode=802.3ad。未指定時預設值為0(balance-rr) |
downdelay | MII監控下,從發現異常到關閉所需的時間(以millisecond為單位)。 |
updelay | MII監控下,從發現恢復正常到啟用所需的時間(以millisecond為單位)。 |
lacp_rate | 僅適用於mode=4,定義了群組發送LACPDU的時間。slow/0代表30秒發送一次(預設值),fast/1則會每秒發送一次。例如lacp_rate=fast。 |
藉由觀察/proc/net/bonding/bond0來得知bonding狀態:
- Mode 0(balance-rr)
- Mode 1(active-backup)
- Mode 2(balance-xor)
- Mode 3(broadcast)
- Mode 4(802.3ad)
- Mode 5(balance-tlb)
- Mode 6(balance-alb)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d8
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d9
Slave queue ID: 0
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d8
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d9
Slave queue ID: 0
Bonding Mode: load balancing (xor)
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d8
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d9
Slave queue ID: 0
Bonding Mode: fault-tolerance (broadcast)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d8
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d9
Slave queue ID: 0
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
802.3ad info
LACP rate: slow
Min links: 0
Aggregator selection policy (ad_select): stable
Active Aggregator Info:
Aggregator ID: 2
Number of ports: 1
Actor Key: 17
Partner Key: 1
Partner Mac Address: 00:00:00:00:00:00
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d8
Aggregator ID: 1
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d9
Aggregator ID: 2
Slave queue ID: 0
Bonding Mode: transmit load balancing
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d8
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 84:34:97:11:00:d9
Slave queue ID: 0
Bonding Mode: adaptive load balancing Primary Slave: None Currently Active Slave: eth0 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 200 Down Delay (ms): 200 Slave Interface: eth0 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 84:34:97:11:00:d8 Slave queue ID: 0 Slave Interface: eth1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 84:34:97:11:00:d9 Slave queue ID: 0
Share |
沒有留言:
張貼留言