Linux

리눅스(centos) 본딩(bonding)

Naan 2013. 8. 6. 21:21
320x100

랜카드 2개가 장착되어 있는 시스템에 본딩을 사용할수 있다. 

윈도우는 티밍, 리눅스는 본딩 기술이다.


가상 이더넷(bond0) 설정

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0

BOOTPROTO=none

ONBOOT=yes

IPADDR=192.168.0.10

NETMASK=255.255.255.0

GATEWAY=192.168.0.1

DNS1=168.126.63.1

DNS1=168.126.63.2

USERCTL=no

NM_CONTROLLED=no

BONDING_MASTER=yes

BONDING_OPTS="mode=balance-alb miimon=100"

# IP를 자동할동으로 사용할 경우 IP 항목 모두 삭제 후 BOOTPROTO=dhcp 로 설정해주면 된다.


eth0 설정
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
HWADDR=xx:xx:xx:xx:xx:xx
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
#USERCTL=no
NM_CONTROLLED=no

eth1 설정
[root@localhost ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
eth0 파일을 복사 했으니 수정해서 DEVICE-eth0을 eth1로 수정하자

네트워크 설정
[root@localhost ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost
NETWORKING_IPV6=no
GATEWAYDEV=bond0

마지막 bonding.conf 설정
[root@localhost ~]# vi /etc/modprobe.d/bonding.conf
alias bond0 bonding

# bond 설정은 여러가지가 있다. 티밍하고 비슷하다.
0 balance-rr
1 active-backup(
2 balance-xor
3 Broadcast
4 802.3ad
5 balance-tlb(TLB) 
6 balance-alb(ALB) 

모든 설정이 끝났다.
[root@localhost ~]# service network restart
Shutting down interface bond0:                             [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:                               [  OK  ]

[root@localhost ~]# ifconfig

bond0     Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx

          inet addr:192.168.0.10  Bcast:192.168.0.255  Mask:255.255.255.0

          inet6 addr: fe80::21e:67ff:fe7a:1295/64 Scope:Link

          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1

          RX packets:59662 errors:0 dropped:0 overruns:0 frame:0

          TX packets:6382 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:14628553 (13.9 MiB)  TX bytes:643393 (628.3 KiB)


eth0      Link encap:Ethernet  HWaddr 00:1E:67:7A:12:95

          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1

          RX packets:12823 errors:0 dropped:0 overruns:0 frame:0

          TX packets:790 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:1189785 (1.1 MiB)  TX bytes:115101 (112.4 KiB)

          Interrupt:19 Memory:c2400000-c2420000


eth1      Link encap:Ethernet  HWaddr 00:1E:67:7A:12:95

          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1

          RX packets:46839 errors:0 dropped:0 overruns:0 frame:0

          TX packets:5592 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:13438768 (12.8 MiB)  TX bytes:528292 (515.9 KiB)

          Interrupt:16 Memory:c2300000-c2320000


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:41 errors:0 dropped:0 overruns:0 frame:0

          TX packets:41 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:4224 (4.1 KiB)  TX bytes:4224 (4.1 KiB)


빨간색을 보면 eth0, eth1은 SLAVE bond0 은 MASTER 로 변경된것을 볼수 있다.


구동 상태를 보러면
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:x1
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: xx:xx:xx:xx:xx:x2
Slave queue ID: 0



arp 구동중에 있다면
mac이 수시로 변경하고 있다고 메세지가 뜰것이다.
bond0, eth0, eth1 항목에 USERCTL=no 없애주자.

또 재부팅시 본딩 모듈이 정상적으로 로드가 안될경우가 빈번하게 발생이된다.
혹시 모르니 
[root@localhost ~]# vi /etc/rc.local
modprobe bonding
service network restart
를 넣어주자


320x100