11/27/2011

設定 Red hat Enterprise Linux bonding 介面.

 

設定Red hat Enterprise Linux bonding 介面流程如下:

  1. 確認主機上至少有兩張網卡.
  2. 編輯或新增4個檔案:
    1. 編輯 /etc/sysconfig/network-scripts/ifcfg-eth0
    2. 編輯 /etc/sysconfig/network-scripts/ifcfg-eth1
    3. 新增 /etc/sysconfig/network-scripts/ifcfg-bond0
    4. 新增 /etc/mdoprobe.d/bonding.conf
  3. 重新啟動網路服務.
  4. 確認 bond0 介面,是否啟用.
  5. 查看目前 bond0,使用之實體網路埠.
  6. 手動切換 bond0,使用之實體網路埠.

我們接著看每個步驟較詳細的設定/檢查方法.

  1. 確認主機至少有兩張網卡.
    [root@XXOOXp ~]# dmesg | egrep 'eth.:'
    e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection
    e1000: eth1: e1000_probe: Intel(R) PRO/1000 Network Connection

  2. 編輯或新增4個檔案:
    1. 編輯 /etc/sysconfig/network-scripts/ifcfg-eth0 的內容.
      [root@XXOOXp network-scripts]# cat ifcfg-eth0
      DEVICE=eth0
      BOOTPROTO=static
      MASTER=bond0
      SLAVE=yes
      ONBOOT=yes

    2. 編輯 /etc/sysconfig/network-scripts/ifcfg-eth1 的內容.
      [root@XXOOXp network-scripts]# cat ifcfg-eth1
      DEVICE=eth1
      MASTER=bond0
      SLAVE=yes
      ONBOOT=yes

    3. 新增 /etc/sysconfig/network-scripts/ifcfg-bond0
      [root@XXOOXp network-scripts]# cat ifcfg-bond0
      DEVICE=bond0
      IPADDR=192.168.75.55
      NETMASK=255.255.255.0
      ONBOOT=yes
      BOOTPROTO=static
      BONDING_OPTS="mode=1 miimon=50"

    4. 新增 /etc/mdoprobe.d/bonding.conf
      [root@XXOOXp modprobe.d]# cat bonding.conf
      alias bond0 bonding

  3. 重新啟動網路服務:
    [root@XXOOXp ~]# service network restart

  4. 確認 bond0 介面,是否啟用.
    [root@XXOOXp ~]# ip addr show bond0
    5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue
        link/ether 00:0c:29:0f:d7:c6 brd ff:ff:ff:ff:ff:ff
        inet 192.168.75.55/24 brd 192.168.75.255 scope global bond0
        inet6 fe80::20c:29ff:fe0f:d7c6/64 scope link
           valid_lft forever preferred_lft forever

  5. 查看目前 bond0,使用之實體網路埠.
    [root@XXOOXp ~]# cat /proc/net/bonding/bond0
    Ethernet Channel Bonding Driver: v3.4.0 (October 7, 2008)

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

    Slave Interface: eth0
    MII Status: up
    Link Failure Count: 0
    Permanent HW addr: 00:0c:29:0f:d7:c6

    Slave Interface: eth1
    MII Status: up
    Link Failure Count: 0
    Permanent HW addr: 00:0c:29:0f:d7:d0
    [root@XXOOXp ~]#

  6. 手動切換 bond0,使用之實體網路埠.
    [root@XXOOXp ~]# ifenslave --change-active bond0 eth1
    [root@XXOOXp ~]# cat /proc/net/bonding/bond0 | egrep 'Currently'
    Currently Active Slave: eth1

參考資料:

Network Card Bonding On CentOS (bonding 不同 mode 的說明)

8.2.2. Channel Bonding Interfaces

23.7.2. Using Channel Bonding

Bonding on Debian

[root@XXOOXp ~]# modinfo bonding

[root@XXOOXp ~]# man modprobe.conf


沒有留言: