UNIX/ubuntu

우분투 본딩 옵션 (다른 계열 리눅스 포함)

99iberty 2013. 7. 15. 13:58

 

http://onecellboy.tistory.com/279

 

 

참고:

http://damduc.tistory.com/256
http://blog.daum.net/donfig/3163924
http://newstars.tistory.com/201
http://blog.naver.com/PostView.nhn?blogId=xrodie&logNo=10043856773
http://kldp.org/node/124067
http://community.365managed.com/?document_srl=1112
http://www.ciokorea.com/m/news/6/11672/%EA%B8%B0%EA%B3%A0%20%7C%20802.11ac%EC%9D%98%20%EC%9E%A5%EB%8B%A8%EC%A0%90%EA%B3%BC%20%EB%B6%88%ED%8E%B8%ED%95%9C%20%EC%A7%84%EC%8B%A4
http://cafe.daum.net/redhat/DK8S/10?docid=1HjQ8DK8S1020090724131640
http://lesstif.tistory.com/262
http://idccc.com/wordpress/archives/165
http://neonis.tistory.com/9 - mode 0 테스트한 결과도 있음
http://gmyoul.tistory.com/entry/%EC%9A%B0%EB%B6%84%ED%88%ACubuntu%EC%97%90%EC%84%9C-%EB%84%A4%ED%8A%B8%EC%9B%8C%ED%81%AC-%EB%B3%B8%EB%94%A9bonding-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0
http://rafi.inha.ac.kr/~wbstory/tc/wbstory/69
http://backdrift.org/howtonetworkbonding - bonding 설정 (모든 리눅스 버전에 대해 써있다.)
http://www.cyberciti.biz/howto/question/static/linux-ethernet-bonding-driver-howto.php - 본딩 드라이브 옵션값 의미 써있음
http://shibaboy.com/?tag=link-aggregation - link aggregation 설명
http://wp.goodchois.kr/devtip/archives/332 - NIC 티빙(설명이 좋다.)


Bonding 이란?

NIC 카드 이중화로 여러 NIC카드를 논리적으로 묶어 대역폭을 늘리거나 가용성을 위해 사용하는 방법이다.

리눅스에서는 Bonding, 윈도우에서는 Teaming, 시스코에서는 EtherChannel이라고 부른다.

표준은 Link Aggregation 이라고 한다.

몇몇 본딩 모드는 스위치의 EtherChannel 기능이 지원 되어야 한다. EtherChannel 이 off되어 있거나 지원하지 않는다면 몇몇 본딩 모드는 사용할 수 없거나 기능이 떨어진다.


Bonding mode

  • mode 0 : Round-robin
    첫번째 가능한 슬레이브부터 마지막까지 순차적으로 전송한다. 이 모드는 부하분산과 failover를 제공한다.
    active-active,
    이론상 슬레이브 수만큼의 배수대로 대역폭을 확장가능한다.
    스위치에서 지원한다면 hashing 없이 load balancing 된다.
  • mode 1 : Active-backup
    bond에서 하나의 슬레이브만 활성화된다. 다른 슬레이브는 standby 상태로 대기하다. 활성중이 슬레이브가 fail 된 경우 standby 슬레이브가 활성화 된다.
    대역폭은 활성화된 슬레이브의 대역폭을 갖는다. primary를 직접설정하지 않으면 failback 되지 않는다.
  • mode 2 : balance-xor (load balancing + failover)
    0과 비슷하지만 xor연산을 이용하여 목적지 Mac과 근원지 Mac을 이용하여 분배한다. ( (출발지 mac XOR 목적지mac) modula 슬레이브 개수 )
    fault tolerance load balancing 을 위한 XOR 으로 설정한다. 이 방식은 인터페이스가 slave 네트워크 카드들의 하나에 대한 Mac address imcoming request Mac address를 연결하는 방식이다.

  • mode 3 : broadcast (failover)
    모든 슬레이브 인터페이스로 전송한다. 이것은 failover를 제공한다(mirror). 하나의 슬레이브만큼 대역폭을 갖는다. 특별한 상황에서 사용한다. 그 특별한 경우는 랜카드가 절대로, 절대로 죽어서는 안되고 패킷이 절대로 절대로 없어지면 안되는 서버에 사용된다.
    스위치의 지원이 필요없다.

  • mode 4 : 802.3ad (link aggregation)
    switch aggregation group을 생성해야한다. (switch 802.3ad 를 지원해야한다.)
    같은 속도와 duplex 설정을 공유하는 aggregation group을 만들어야한다. /수신은 active aggregator 안에서 모든 슬레이브에서 수행된다. 이론상 슬레이브 수만큼의 배수대로 대역폭을 확장가능한다.

  • mode 5 : balance-tlb
    스위치의 지원이 필요없다.

  • mode 6 : balance-alb
    mode 4 즉 802.3ad 를 스위치가 지원하지 않는다면 이 모드인 mode 6를 사용하면된다.
    스위치의 지원이 필요없다.


  • Require switch supports modes
    1. mode 0 (balance-rr) - 트래픽은 hashing 없이 load balancing 된다.
    2. mode 4 (802.3ad) - 기본적으로 해당 모드는 스위치에서 지원 off되어 있다.
    3. mode 2 (balance-xor) - 받는 쪽의 receiver에 의하여 트래픽은 hashed되고 balancing 된다.

  • Generic modes (switch의 지원없이도 kernel과 driver를 통해 자체적 구동이 가능)
    1. mode 3 (broadcast)
    2. mode 5 (balance-tlb)
    3. mode 6 (balance-alb)


참고

본딩을 하기 위해서는 서버뿐만 아니라 스위치에서도 설정이 필요하며, mode 1인 active-backup은 굳이 스위치의 설정은 별도로 필없없다. 시스코 스위치에서 본딩을 하여 대역폭 확장을 확실히 하기위해서는 mode 0 가 아닌 mode 4(시스코에서는 LACP) 를 써야한다.

본딩은 리눅스 커널에서 본딩 기능이 지원되어야하고 최적의 성능을 위해서는 스위치가 EtherCannel 이 지원되어야한다.



설정

Ubuntu

모듈 설치

apt-get install ifenslave


인터페이스 추가

$vi /etc/network/interfaces

auto bond0
iface bond0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
#broadcast xxx.xxx.xxx.xxx
post-up ifenslave bond0 eth0 eth1


모듈 설정

$vi /etc/modprobe.d/aliases.conf # 딴 이름이어도 된다.

alias bond0 bonding
options bonding mode=4 miimon=100

#bonding 뒤의 값들은 옵션이다.
#miimon 은 해당 밀리초마다 인터페이스를 체크한다는 의미이다.
#mode 는 자신이 원하는 모드 번호를 넣으면 됩니다. 예제는 mode 4라고 가정했습니다.
#모듈 옵션은 http://www.cyberciti.biz/howto/question/static/linux-ethernet-bonding-driver-howto.php 을 보아라.
#modinfo bonding 으로도 모듈의 정보를 볼 수 있다.


시스템 재부팅시 본딩 모듈이 로드되지 않아 네트워크가 다운되는 경우가 있는데 이경우 /etc/rc.local 을 수정하거나 /etc/modules 에 모듈을 추가하는 방법이있다. 둘중 하나만 쓰면된다. 참고로 /etc/modules 에다가 설정하는 것이 의미상 맞는것 같다.


$vi /etc/modules

modules mode=4 miimon=100 lacp_rate=1

#bonding 뒤의 값들은 옵션이다.
#mode 값은 자신의 본딩 모드 번호를 넣으면된다. 예제는 mode 4 라고 가정했습니다.
#lacp_rate 는 LACPDU 패킷을 전송하기 위해 링크 파트너를 요청하는 옵션이다. 1 은 1초마다 요청하는 것이고 0은 30초마다 요청하는 것이다. 고성능을 위해서는 1 즉 fast 가 좋다.

$vi /etc/rc.local

modprobe bonding mode=4

#시스템 부팅시 최초한번 실행되는 스크립트이다. /etc/modules 가 쓰기 싫다면 이거 사용하면된다.
#mode 값은 자신의 본딩 모드 번호를 넣으면된다. 예제는 mode 4 라고 가정했습니다.


aliases.conf 수정
# 모듈 이름의 별명을 붙이는 것이다. 아래 예제과 같이 작성하면 modprobe bond0 라고 하면 modprobe bonding 과 같은 의미이다.
# 모듈을 자동으로 올리게도 한다.
#자세한 설명은
http://linux.die.net/man/5/modprobe.d 참조하라.

#
# 꼭 aliases.conf 가 아닌 다른 이름으로해도된다. 예를들어 bonding.conf 라고해도 된다.

$vi /etc/modprobe.d/aliases.conf

alias bond0 bonding
options bonding mode=4 miimon=100


시스템 재부팅

$sudo reboot

#/etc/init.d/networking restart 명령어로 네트워크만 재시작 해줄경우 bonding 구성이 안될수 있다. 이때는 시스템을 재부팅해야한다.



기타

#bonding 구성확인
$cat /proc/net/bonding/bond0


#bonding 인터페이스 확인
$ifconfig


#bonding 모듈 로드확인
$ lsmod | grep bonding


#bonding 인터페이스 up
$ifconfig bond0 up
$ifup bond0


#라우팅 테이블 확인
$route -n


#ubuntu 10.04 버전 이후로는 /etc/network/intervaces 에 대해 아래의 문법도 지원한다.
auto eth0
iface eth0 inet manual
bond-master bond0

auto eth1
iface eth1 inet manual
bond-master bond0

auto bond0
iface bond0 inet static
address xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx

bond-mode 802.3ad
bond-miimon 100
bond-lacp-rate 4
bond-slaves none