Hướng dẫn cấu hình bonding 2 card mạng rhel centos năm 2024
Network Bonding hiểu một cách đơn giản là cấu hình 2 hay nhiều Card mạng chạy song song nhau, hỗ trợ nhau hay nói cách khác là cân bẳng tải và đảm bảo tính sẵn sàng cao cho Server, nếu 1 trong 2 card bị Down thì dịch vụ trên Server vẫn chạy bình thường bằng các Card mạng khác. Hãy theo dõi thông tin dưới đây cùng Bizfly Cloud để biết rõ hơn nhé! Show Các Mode của Bonding: mode=0 (Balance Round Robin) mode=1 (Active backup) mode=2 (Balance XOR) mode=3 (Broadcast) mode=4 (802.3ad) mode=5 (Balance TLB) mode=6 (Balance ALB) VLAN là một từ viết tắt của Virtual Local Area Network. Trên cùng 1 Interface chúng ta có thể config nhiều VLAN ID cùng một lúc. Hướng dẫn cấu hình bonding 2 card mạng và sử dụng vlan IDStep 1: Chuẩn bị các gói cài đặt cần thiết# apt-get update # apt-get install build-essential ifenslave ethtool vlan Step 2: Load modul 8021q# modprobe 8021q Step 3: Load module bonding --> Áp dụng đối với server bonding# echo "bonding" >> /etc/modules # echo "8021q" >> /etc/modules Step 4: Enable packet forwarding for IPv4# vi /etc/sysctl.conf net.ipv4.ip_forward=1 Step 5: Cấu hình các thông số cho Bond, chọn chế độ chạy cho Bond
# alias bond0 bonding # options bonding mode=4 arp_interval=100 miimon=100 xmit_hash_policy=1 lacp_rate=1
# alias bond0 bonding # options bonding mode=4 miimon=100 Note: - Bond0: Tên của Bond được tạo ra. - Miimon: Xác định mức độ thường xuyên, tính bằng milli giây, bond được kiểm tra nếu nó vẫn đang hoạt động. Network bonding cho phép bạn cấu hình 2 card mạng chạy loadbalacing và HA với nhau, nếu 1 trong 2 card bị down thì dịch vụ dẫn chạy bình thường. Tính năng loadbalacing cho phép tăng tốc độ truyển dữ liệu trên card mạng, dữ liệu sẽ được chạy trên 2 card để share tải và tăng tốc độ chuyền dữ liệu. Các mode của Bonding ModePolicyHow it worksFault ToleranceLoad balancing0Round Robincác gói dữ liệu truyền và nhận theo tuần tự từng card mộtNoYes 1Active Backup (active-backup)Một NIC chạy trong khi một NIC ở trạng thái backup, khi một NIC down, NIC kia tự kích hoạt, hỗ trợ X86YesNo 2XOR [exclusive OR] (balance-xor) In this mode the, the MAC address of the slave NIC is matched up against the incoming request’s MAC and once this connection is established same NIC is used to transmit/receive for the destination MAC.YesYes 3Broadcast broadcastCác gói tin truyền tới được gởi đến tất cả các slaveYesNo 4Dynamic Link Aggregation 802.3adaggregated NICs act as one NIC which results in a higher throughput, but also provides failover in the case that a NIC fails. Dynamic Link Aggregation requires a switch that supports IEEE 802.3ad.YesYes 5Transmit Load Balancing (TLB) balance-tlbThe outgoing traffic is distributed depending on 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.YesYes 6Adaptive Load Balancing (ALB) balance-albUnlike Dynamic Link Aggregation, Adaptive Load Balancing does not require any particular switch configuration. Adaptive Load Balancing is only supported in x86 environments. The receiving packets are load balanced through ARP negotiation. Chuyển đến thư mục chứa các file cấu hình của mạng trong centos cd /etc/sysconfig/network-scripts/ Tạo mới một file cấu hình cho card bond vi ifcfg-bond0 DEVICE=bond0 IPADDR=192.168.200.13 NETMASK=255.255.255.0 GATEWAY=192.168.200.2 NM_CONTROLLED=no BOOTPROTO=none ONBOOT=yes USERCTL=no nhấn ESC :wq! Chỉnh sữa file của card nic0 vi ifcfg-eth0 DEVICE=eth0 USERCTL=no ONBOOT=yes NM_CONTROLLED=no MASTER=bond0 SLAVE=yes BOOTPROTO=none # sed 's/eth0/eth1/' ifcfg-eth0 > ifcfg-eth1 nhấn ESC :wq! vi ifcfg-eth1 // sữa lại file DEVICE=eth0 USERCTL=no ONBOOT=yes NM_CONTROLLED=no MASTER=bond0 SLAVE=yes BOOTPROTO=none # sed 's/eth0/eth1/' ifcfg-eth0 > ifcfg-eth1 nhấn ESC :wq! vi /etc/modprobe.d/bonding.conf // tạo file và nhập nôi dụng như dưới alias bond0 bonding options bond0 mode=5 miimon=100 downdelay=200 updelay=200 // phần mode lựa chọn như bản ở trên phụ thuộc nhu cầu service network restart ifconfig [root@localhost network-scripts]# ifconfig \\ kiểm tra bond0 Link encap:Ethernet HWaddr 00:0C:29:D6:1F:45 inet addr:172.16.200.13 Bcast:172.16.200.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fed6:1f45/64 Scope:Link UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:272 errors:0 dropped:0 overruns:0 frame:0 TX packets:104 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:32066 (31.3 KiB) TX bytes:6984 (6.8 KiB) eth0 Link encap:Ethernet HWaddr 00:0C:29:D6:1F:45 inet addr:172.16.200.13 Bcast:172.16.200.255 Mask:255.255.255.0 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:144 errors:0 dropped:0 overruns:0 frame:0 TX packets:92 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:20877 (20.3 KiB) TX bytes:5364 (5.2 KiB) eth1 Link encap:Ethernet HWaddr 00:0C:29:D6:1F:45 inet addr:172.16.200.13 Bcast:172.16.200.255 Mask:255.255.255.0 UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:128 errors:0 dropped:0 overruns:0 frame:0 TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:11189 (10.9 KiB) TX bytes:1620 (1.5 KiB) [root@localhost network-scripts]# cat /proc/net/bonding/bond0 \\ kiểm tra [root@localhost network-scripts]# ethtool 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): 200 Down Delay (ms): 200 Slave Interface: eth0 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 1 Permanent HW addr: 00:0c:29:d6:1f:45 Slave queue ID: 0 Slave Interface: eth1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 1 Permanent HW addr: 00:0c:29:d6:1f:4f Slave queue ID: 0 |