Hướng dẫn cấu hình BONDING NETWORK CARD trên CENTOS 6 / RHEL 6

BONDING NETWORK CARD CENTOS​​ 6​​ / RHEL 6

Mục đích:

Bonding card để tăng băng thông sử dụng cho server ví dụ bond 2 card 1Gb thành 1 line 2Gb.

Bonding card để tăng HA cho hệ thống mạng.

Ở mô hình mạng Lab trên server có 2 card​​ eth0 và eth1. (các bạn có thể sử dụng các phần mềm ảo hoá như Vmware Work station, Vmware ESXI, Hyper -V, Virtural Box…)

OS: Centos 6 hoặc RHEL 6​​ 

Bond card name: bond0

 

Step:1 Create the bond file ( ifcfg-bond0 ) and specify the ip address, netmask & gateway

# vi /etc/sysconfig/network-scripts/ifcfg-bond0

 

DEVICE=bond0

IPADDR=192.168.1.9

NETMASK=255.255.255.0

GATEWAY=192.168.1.1

TYPE=Bond

ONBOOT=yes

NM_CONTROLLED=no

BOOTPROTO=static

Step:2 Edit the files of eth0 & eth1 and make sure you enter the master and slave entry, as shown below

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

 

DEVICE=eth0

HWADDR=08:00:27:5C:A8:8F

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=no

MASTER=bond0

SLAVE=yes

 

# vi /etc/sysconfig/network-scripts/ifcfg-eth1

 

DEVICE=eth1

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=no

MASTER=bond0

SLAVE=yes

Step:3 Create the Bond file(bonding.conf)

# vi /etc/modprobe.d/bonding.conf

alias bond0 bonding

options bond0 mode=1 miimon=100

Different Modes used in bonding.conf file .

  • balance-rr or 0 — round-robin mode for fault tolerance and load balancing.

  • active-backup or 1 — Sets active-backup mode for fault tolerance.

  • balance-xor or 2 — Sets an XOR (exclusive-or) mode for fault tolerance and load balancing.

  • broadcast or 3 — Sets a broadcast mode for fault tolerance. All transmissions are sent on all slave interfaces.

  • 802.3ad or 4 — Sets an IEEE 802.3ad dynamic link aggregation mode. Creates aggregation groups that share the same speed & duplex settings.

  • balance-tlb or 5 — Sets a Transmit Load Balancing (TLB) mode for fault tolerance & load balancing.

  • balance-alb or 6 — Sets an Active Load Balancing (ALB) mode for fault tolerance & load balancing.

Step:4 Now Restart the network Service

# service network restart

Using below command to  Check the bond Interface

root@localhost ~]# ifconfig bond0

​​ bond0     Link encap:Ethernet  HWaddr 08:00:27:5C:A8:8F

​​ inet addr:192.168.1.9  Bcast:192.168.1.255  Mask:255.255.255.0

​​ inet6 addr: fe80::a00:27ff:fe5c:a88f/64 Scope:Link

​​ UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1

​​ RX packets:6164 errors:0 dropped:0 overruns:0 frame:0

​​ TX packets:1455 errors:0 dropped:0 overruns:0 carrier:0

​​ collisions:0 txqueuelen:0

​​ RX bytes:482336 (471.0 KiB)  TX bytes:271221 (264.8 KiB

Step:5 Verify the Status of bond interface.

[root@localhost ~]# cat /proc/net/bonding/bond0  

​​ Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

 

Bonding Mode: fault-tolerance (active-backup)

​​ Primary Slave: None

​​ Currently Active Slave: eth0

​​ 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: 08:00:27:5c:a8:8f

​​ Slave queue ID: 0

 

Slave Interface: eth1

​​ MII Status: up

​​ Speed: 1000 Mbps

​​ Duplex: full

​​ Link Failure Count: 0

​​ Permanent HW addr: 08:00:27:7f:04:49

​​ Slave queue ID: 0

 

Lưu ý:

Lưu ý 1: Cấu hình như trên là mode 1: active passive. không tăng được băng thông mà chỉ HA.

Để vừa HA và vừa tăng băng thông thì cần cấu hình như sau:

Cấu hình mode 4 trên server và mode active trên switch

Lưu ý 2:​​ Khi cấu hình như trên thì để chuyển mode bonding sẽ cần phải reboot lại server để không phải reboot lại server cần add thêm câu lệnh sau:

BONDING_OPTS="mode=0 miimon=100"

Vào card bond0 sau đó gõ ifdown bond0 và ifup bond0 thì sẽ được. hoặc có thể gõ lệnh service network restart.​​ 

Lưu ý 3:​​ Khi​​ gõ lệnh trên trong card network bond0 thì không cần phải tạo file /etc/modprobe.d/bonding.conf

 

Các lệnh kiểm tra

Kiểm tra trạng thái mode bond

cat /proc/net/bonding/bond0

Thay đổi trạng thái mode bond nhưng phải reboot trong file

/etc/modprobe.d/bonding.conf

Tất cả cấu hình sẽ được ghi vào file:

etc/sysconfig/network-scripts/ifcfg-bond0

 

Cảm ơn các bạn đã theo dõi!

BÀI VIẾT CÙNG CHUYÊN MỤC