首页 » Linux笔记 » centos6.5端口聚合教程亲测可用

centos6.5端口聚合教程亲测可用

 

centos6.5

1多网卡绑定可以有0-6共七种模式。

mode=0 多端口轮询发送数据包

mode=1 主备模式

mode=2 基于Hash算法发送数据包

mode=3 在每个slave接口上传输每个数据包,此模式提供了容错能力

mode=4 创建一个聚合组,它们共享同样的速率和双工设定,需要交换机配合

mode=5 不需要任何特别的switch(交换机)支持的通道bonding。在每个slave上根据当前的负载(根据速度计算)分配外出流量

mode=6 针对IPV4做了优化

2加载bonding模块

modprobe --first-time bonding

************这里我用bond0测试***********

3,配置虚拟端口bond0

[root@localhost network-scripts]# vi ifcfg-bond0

DEVICE=bond0

BOOTPROTO=none

ONBOOT=yes

IPADDR=192.168.0.200

NETMASK=255.255.255.0

GATEWAY=192.168.0.1

DNS1=8.8.8.8

[root@localhost network-scripts]# vi ifcfg-eth0

DEVICE=eth0

HWADDR=52:54:00:17:34:4D

TYPE=Ethernet

UUID=18e63b61-aee2-4b5a-bb85-05b63811cb59

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

[root@localhost network-scripts]# vi ifcfg-eth1

DEVICE=eth1

HWADDR=52:54:00:23:31:51

TYPE=Ethernet

UUID=070ee9db-9502-4d32-9598-7bf8a6462eb0

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

4,修改modprobe相关设定文件

[root@localhost ~]# vi /etc/modprobe.d/bonding.conf

alias bond0 binding

options bond0 miimon=100 mode=1

5,重启网卡

[root@localhost ~]# service network restart

Shutting down interface bond0: [ OK ]

Shutting down loopback interface: [ OK ]

Bringing up loopback interface: [ OK ]

Bringing up interface bond0: Determining if ip address 192.168.0.200 is already in use for device bond0...

[ OK ]

6,查看bonud工作状况

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

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

Bonding Mode: load balancing (round-robin)

MII Status: up

MII Polling Interval (ms): 0

Up Delay (ms): 0

Down Delay (ms): 0

Slave Interface: eth0

MII Status: up

Speed: Unknown

Duplex: Unknown

Link Failure Count: 0

Permanent HW addr: 52:54:00:17:34:4d

Slave queue ID: 0

Slave Interface: eth1

MII Status: up

Speed: Unknown

Duplex: Unknown

Link Failure Count: 0

Permanent HW addr: 52:54:00:23:31:51

Slave queue ID: 0

7,查看网卡IP

[root@localhost ~]# ip add

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000

link/ether 52:54:00:17:34:4d brd ff:ff:ff:ff:ff:ff

3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000

link/ether 52:54:00:17:34:4d brd ff:ff:ff:ff:ff:ff

4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP

link/ether 52:54:00:17:34:4d brd ff:ff:ff:ff:ff:ff

inet 192.168.0.200/24 brd 192.168.0.255 scope global bond0

inet6 fe80::5054:ff:fe17:344d/64 scope link tentative dadfailed

valid_lft forever preferred_lft forever

测试,随便down掉eth0或者eth1其中一块网卡,依然可以上网

成功啦!!!!

(测试中遇到多服务器重启后,bond消失,解决方法是开机启动中加载模块)

vi /etc/rc.d/rc.local

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

#加载模块

modprobe --first-time bonding

原文链接:centos6.5端口聚合教程亲测可用,转载请注明来源!

0