2009年12月8日 星期二

HA-NIC Bonding設定

HA-NIC Bonding設定 (兩張網卡服務一個IP)

  1. 查看load進來的module有那些,是否有bonding這個module
    1.  #lsmod | grep bond
  2. 生出一張ifcfg-bond0
    1. []# vi /etc/sysconfig/network-scripts/ifcfg-bond0
      DEVICE=bond0
      ONBOOT=yes
      BOOTPROTO=none
      IPADDR=140.137.217.155
      NETMASK=255.255.255.0
      GATEWAY=140.137.217.254
      USERCTL=no
  3. 修改ifcfg-eth0 (不要保留IP的設定)
    1. []# cat /etc/sysconfig/network-scripts/ifcfg-eth0
      DEVICE=eth0
      USERCTL=no
      ONBOOT=yes
      BOOTPROTO=none
      MASTER=bond0
      SLAVE=yes
  4. 修改ifcfg-eth1(不要保留IP的設定)
    1.  []# cat /etc/sysconfig/network-scripts/ifcfg-eth1
      DEVICE=eth1
      USERCTL=no
      ONBOOT=yes
      BOOTPROTO=none
      MASTER=bond0
      SLAVE=yes
  5. 修改/etc/modprobe.conf
    1. []# vi /etc/modprobe.conf
      #add 2 lines in the end
      alias bond0 bonding
      options bond0 mode=0 miimon=100
      (miimon 是提供 bonding module 要多久透過 MII 的介面檢查網路卡狀態,100 表示 100 milliseconds。)
  6. 啟動bonding
    1.  [TESTING] Enabling bonding
      []# modprobe bonding
      (#rmmod bonding--->如果要移除boonding重測,要執行這個指令)
  7. 查看bonding是否有成功
    1. []# cat /proc/net/bonding/bond0
      Ethernet Channel Bonding Driver: v3.2.4 (January 28, 2008)

      Bonding Mode: load balancing (round-robin)
      MII Status: up
      MII Polling Interval (ms): 0
      Up Delay (ms): 0
      Down Delay (ms): 0

      Slave Interface: eth0
      MII Status: up
      Link Failure Count: 0
      Permanent HW addr: 00:0c:29:8c:7c:7e

      Slave Interface: eth1
      MII Status: up
      Link Failure Count: 0
      Permanent HW addr: 00:0c:29:8c:7c:88
  8. 重啟網路服務
    1.  []# service network restart
  9. 查看是否bond0取得IP位址,eth0和eth1變成slave
    1. []# ifconfig
      bond0     Link encap:Ethernet  HWaddr 00:0C:29:8C:7C:7E
                inet addr:140.137.217.155  Bcast:140.137.217.255  Mask:255.255.255.0
                inet6 addr: fe80::20c:29ff:fe8c:7c7e/64 Scope:Link
                UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
                RX packets:8965 errors:0 dropped:0 overruns:0 frame:0
                TX packets:827 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:0
                RX bytes:1077529 (1.0 MiB)  TX bytes:122763 (119.8 KiB)

      eth0      Link encap:Ethernet  HWaddr 00:0C:29:8C:7C:7E
                UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
                RX packets:5012 errors:0 dropped:0 overruns:0 frame:0
                TX packets:750 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:602470 (588.3 KiB)  TX bytes:108566 (106.0 KiB)
                Interrupt:67 Base address:0x2000

      eth1      Link encap:Ethernet  HWaddr 00:0C:29:8C:7C:7E
                UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
                RX packets:3953 errors:0 dropped:0 overruns:0 frame:0
                TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
                collisions:0 txqueuelen:1000
                RX bytes:475059 (463.9 KiB)  TX bytes:14197 (13.8 KiB)
Note:
1.從windows測試時,會有arp的問題
2.bonding的mode有很多種,狀況不同
數字表示      文字表示      說明
0     balance-rr    
‧負載平衡模式, 需有 switch 設定 (trunk) 支援才能發揮實質效果
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
1     active-backup    
‧同一時間只有單一 Slave 網卡運作
‧Active Slave 網卡失效時自動啟用次一順位 Slave 網卡
‧不需 switch 支援
5     balance-tlb     ‧傳出自動負載平衡
‧傳入由 Current Active Slave 負責
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
‧不需 switch 支援及設定
6     balance-alb     ‧傳出及傳入皆自動負載平衡
‧具容錯功能, 其中一張 Slave 網卡失效仍可持續運作
‧Slave 網卡 driver 需支援 setting hardware address 功能
‧不需 switch 支援及設定

沒有留言:

張貼留言