2014年10月1日 星期三

Ubuntu 12.04LTS Bonding 設定

  1. OS: Ubuntu 12.04 LTS x86_64
  2. NIC:
    • Motherboard wired port (eth0)
    • Motherboard wired port (eth1)
  3. 安裝套件

    • aptitude install ifenslave-2.6

    設定 /etc/network/interface

    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet manual
    bond-master bond0
    
    auto eth1
    iface eth1 inet manual
    bond-master bond0
    
    auto bond0
    iface bond0 inet manual
    address <your ip>
    netmask <your netmask>
    gateway <your gateway ip>
    bond-slaves none
    bond-mode 6
    bond-miimon 100
    
    • 這邊要注意一下 bond-mode 有六種, 推薦用 balance-alb 6
    • 這樣子即可順利把 eth0 eth1 eth2 綁在 bond0 上

    觀察bond狀態

    • cat /proc/net/bonding/bond0

    檢查網卡支不支援 bonding

    安裝套件

    • aptitude install net-tools

    觀察網卡狀態

  4. 設定DNS
    sudo vim /etc/resolv.conf
    ########################
    nameserver 168.95.192.1
    nameserver 168.95.1.1
    ########################
    • mii-tool
    • 如果顯示
      eth0: negotiated 1000baseT-HD flow-control, link ok
      eth1: negotiated 1000baseT-HD flow-control, link ok
      
    • 反之即不支援, 有可能會再舊款網卡或速率不一的網卡發生
  5. 有0~6底下這幾種模式可以設定


    mode=0 (balance-rr)
    負載平衡模式(Round-robin policy), 需有 switch 設定 (port trunk,或是 Link Aggregation ) 支援才能發揮實質效果,具容錯功能, 其中一張網卡失效仍可持續運作。運作模式就是所有綁定的網卡皆會依序的被使用到。
    Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
        
    mode=1 (active-backup)
    同一時間只有單一網卡運作,需設定主要(primary)與次要網卡,當主要網卡失效時自動啟用次要網卡,不需 switch 支援。
    Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.
        
    mode=2 (balance-xor)
    XOR policy: Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.


    mode=3 (broadcast)
    所有 Slave 網卡一齊收送網路封包具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
    Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance. 

    mode=4 (802.3ad)
    802.3ad是比較正規的做法,需 switch 支援及設定。參考資料1參考資料2
    若有兩張網路卡,則進來流量為2000M出去流量為2000M,具容錯功能。ALA (Adapter Link Aggregation)

    IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.
        
    需求:
    Ethtool support in the base drivers for retrieving the speed and duplex of each slave.
    A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will require some type of configuration to enable 802.3ad mode. 


    mode=5 (balance-tlb)
    傳出自動負載平衡,傳入由次要網卡負責,具容錯功能, 其中一張次要網卡失效仍可持續運作,不需 switch 支援及設定  
    Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.
    需求: Ethtool support in the base drivers for retrieving the speed of each slave. 
        
    mode=6 (balance-alb)
    傳出及傳入皆自動負載平衡具容錯功能, 其中一張 Slave 網卡失效仍可持續運作;Slave 網卡 driver 需支援 setting hardware address 功能,不需 switch 支援及設定。   

    若兩張網路卡設成ALB時,進來流量為1000M出去流量為2000M這時候無論接往何種交換器或集線器都可支援,ALB包含容錯功能如果一張網卡故障另一張依然運作,現在INTEL可以做到8張網卡併頻寬

    Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.

沒有留言:

張貼留言