Bonding 이란?

Linux kernel 내장된 기술로 2개 이상의 Network Interface Card를 논리적으로 하나의 interface 로 묶어서 NIC의 물리적 장애에 대응하거나나 처리량을 늘리는 기술이다.

bonded 된 NIC 의 동작 방식은 mode의 설정에 달려 있다.

bonding kernel module 을 이용하여 bonding 된 NIC는 channel bonding interface 라고 불리운다.


RHEL6 에서 bonding 설정이 변경이 되었으므로 RHEL6 기준으로 bonding 설정하는 법을 정리해 본다.

기본 설정

  1. channel bonding interface 설정은 /etc/sysconfig/network-scripts/ifcfg-bondN 파일을 통해 설정한다. N 은 bonding interface 의 숫자로 변경한다. 보통 0 으로 해주면 된다.

    /etc/sysconfig/network-scripts/ifcfg-bond0 예제

    DEVICE=bond0
    IPADDR=192.168.1.100
    NETMASK=255.255.255.0
    GATEWAY=192.168.1.1
    DNS1=192.168.1.1
    ONBOOT=yes
    BOOTPROTO=none
    USERCTL=no
    BONDING_OPTS=""
    CODE

     

  2. BONDING_OPTS 설정은 bonding이 정상적으로 구성된후에 설정하는게 좋으므로 일단 "" 로 넣는다.

  3. 실제 bonding 수행할 NIC 를 bonding interface에 바인딩해야 한다. 기존 NIC 설정에 MASTER, SLAVE 지시자를 추가하면 된다. 다음은 ifcfg-eth0 에 적용한 예이며 ifcfg-eth1 에도 같은 설정을 추가하면 된다.


    /etc/sysconfig/network-scripts/ifcfg-eth0

    DEVICE=eth0
    BOOTPROTO=none
    ONBOOT=yes
    MASTER=bond0
    SLAVE=yes
    USERCTL=no
    CODE
  4. bonding kernel module 이 loading 되도록 modprobe 설정을 변경한다. 
    RHEL6 에서는 modprobe.conf 이 deprecated 되었으므로 /etc/modprobe.conf 에 했던 설정은 /etc/modprobe.d/ 밑에 개별 파일로 설정해 주면 된다. ( Ex: ipv6 설정은 /etc/modprobe.d/ipv6.conf 에 지정) - 관련 자료 - Where is /etc/modprobe.conf in Red Hat Enterprise Linux 6?)

    /etc/modprobe.d/bonding.conf

    alias bond0 bonding
    CODE
  5. service network restart 로 network  을 재시작한다.
  6. ifconfig  로 bonding interface 가 보이는지 확인한다.

    ifconfig bond0

    bond0     Link encap:Ethernet  HWaddr 00:0C:29:65:13:5E  
              inet addr:192.168.0.231  Bcast:192.168.0.255  Mask:255.255.255.0
              inet6 addr: fe80::20c:29ff:fe65:135e/64 Scope:Link
              UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
              RX packets:68590 errors:0 dropped:0 overruns:0 frame:0
              TX packets:39766 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:93621577 (89.2 MiB)  TX bytes:2786599 (2.6 MiB)
    CODE

bonding option  설정

Linux는 bonding 설정이 바뀌어도 kernel module reloading 없이 반영이 가능하다.
이 기능은 kernel objects 를 directory 와 file 로 mapping 시키는 s
ysfs virtual file system 이 설정되었을때 동작한다. (/proc file system 과 유사하다). 

sysfs 는 /etc/fstab 에 정의되어 있으며 /sys 에 자동으로 mount 된다.

  1. 존재하는 본딩 인터페이스 확인을 위해 sysfs 를 조회한다.

    ~]# cat /sys/class/net/bonding_masters
    bond0
    BASH
  2. bonding 설정 변경은 /sys/class/net/bond<N>/bonding/ 에서 개별 설정 파일을 수정하면 된다. 

    1. Ex: to enable MII monitoring on bond0 with a 1 second interval

      echo 1000 > /sys/class/net/bond0/bonding/miimon
      CODE

  3. 설정 변경을 위해 먼저 interface 를 중지해야 한다.

    ifconfig bond0 down
    CODE
  4. bonding mode 를 변경한다. (예. mode 를 balance-alb 로 설정)

    bonding 을 balance-alb mode 로 설정

    echo balance-alb > /sys/class/net/bond0/bonding/mode 
    CODE
  5. 설정이 끝났으면 bonding interface 를 up 한다.

    ifconfig bond0 up
    CODE
  6. 설정한 옵션이 잘 동작하는지 확인하고 적절한 bonding 옵션을 찾았으면 /etc/sysconfig/network-scripts/ifcfg-bondN 의 BONDING_OPTS  에 추가하여 부팅시마다 적용되게 설정한다.


  • bonding module 에서 사용가능한 parameter 는 modinfo bonding 으로 확인할 수 있다.
  • 가장 많이 사용할 mode 옵션은 다음과 같은 파라미터가 사용가능하다.
    • balance-rr or 0 — Sets a round-robin policy for fault tolerance and load balancing. Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available.
    • active-backup or 1 — Sets an active-backup policy for fault tolerance. Transmissions are received and sent out via the first available bonded slave interface. Another bonded slave interface is only used if the active bonded slave interface fails.
    • balance-xor or 2 — Sets an XOR (exclusive-or) policy for fault tolerance and load balancing. Using this method, the interface matches up the incoming request's MAC address with the MAC address for one of the slave NICs. Once this link is established, transmissions are sent out sequentially beginning with the first available interface.
    • broadcast or 3 — Sets a broadcast policy for fault tolerance. All transmissions are sent on all slave interfaces.
    • 802.3ad or 4 — Sets an IEEE 802.3ad dynamic link aggregation policy. Creates aggregation groups that share the same speed and duplex settings. Transmits and receives on all slaves in the active aggregator. Requires a switch that is 802.3ad compliant.
    • balance-tlb or 5 — Sets a Transmit Load Balancing (TLB) policy for fault tolerance and load balancing. The outgoing traffic is distributed according to the current load on each slave interface. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed slave.
    • balance-alb or 6 — Sets an Active Load Balancing (ALB) policy for fault tolerance and load balancing. Includes transmit and receive load balancing for IPV4 traffic. Receive load balancing is achieved through ARP negotiation.


참고 자료