CentOS6でbondingを設定した時の備忘録です。

■説明
ここでは、「eth0」「eth1」を利用してNICの冗長化(bonding)を行います。
冗長化した仮想NICは「bond0」とします。

■OS
CentOS6 64bit

(1)bondingモジュールの設定ファイルを作成

[root@example ~]# vi /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 mode=1 primary=eth0 miimon=500
※設定値については、参考文献を参照してください。

(2)NICの設定
[root@example ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
SLAVE=yes
HWADDR=00:0C:29:64:B3:B5

[root@example ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
SLAVE=yes
HWADDR=00:0c:29:64:b3:bf
※ちなみにNICデバイスの情報は以下にあります。
[root@example ~]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:64:b3:b5", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:64:b3:bf", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

(3)bond0の設定
[root@example ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROT=none
ONBOOT=yes
IPADDR=192.168.0.97
BROADCAST=192.168.0.255
NETWORK=192.168.0.0
NETMASK=255.255.255.0

(4)ネットワークの再起動
[root@example ~]# service network restart
インターフェース bond0 を終了中:                           [  OK  ]
ループバックインターフェースを終了中                       [  OK  ]
ループバックインターフェイスを呼び込み中                   [  OK  ]
インターフェース bond0 を活性化中:                         [  OK  ]

(5)bond0の確認
[root@example ~]# ifconfig
bond0     Link encap:Ethernet  HWaddr 00:0C:29:64:B3:B5
          inet addr:192.168.0.97  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: 2408:c8:1fff:659:20c:29ff:fe64:b3b5/64 Scope:Global
          inet6 addr: fe80::20c:29ff:fe64:b3b5/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:163 errors:0 dropped:0 overruns:0 frame:0
          TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:15070 (14.7 KiB)  TX bytes:4322 (4.2 KiB)

eth0      Link encap:Ethernet  HWaddr 00:0C:29:64:B3:B5
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:83 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7650 (7.4 KiB)  TX bytes:4476 (4.3 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:64:B3:B5
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:82 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7540 (7.3 KiB)  TX bytes:0 (0.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:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

(6)動作確認
eth0をダウンさせてもpingが届くこと

eth0をアップし、eth1をダウンさせてもpingが届くこと

(7)状態確認
正常な状態
[root@example ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.5.0 (November 4, 2008)

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

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:64:b3:b5

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:64:b3:bf

eth0がダウンしている場合
[root@example ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.5.0 (November 4, 2008)

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

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:64:b3:bf
※「eth0」が表示されない。「Currently Active Slave」が「eth1」になっている。
[root@example ~]# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   1000baseT/Full
                                10000baseT/Full
        Supports auto-negotiation: No
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Speed: Unknown!
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: off
        MDI-X: Unknown
        Supports Wake-on: uag
        Wake-on: d
        Link detected: no
※「Link detected」が「no」になっている。

参考文献
1.http://www-06.ibm.com/jp/linux/tech/doc/attachments/000c97b9_bonding_guide_rhel5_v1_1.pdf (IBMのbonding設定資料)
2.http://it.jfe-tec.jp/column/tech_column/column_linuxn/000104.html


9月 19, 2011 at 5:48 pm by 黒ぶちメガネ
Category: Linux, 冗長化