weijie0717

一、配置环境

centos 系统。网卡1口和2口做链路聚合。    交换机网口 6口和7口。

二、服务器操作步骤

  centos 6

  1.创建一个channel bonding interface

#vi /etc/sysconfig/network-scripts/ifcfg-bond0
添加如下几行:
GATEWAY=192.168.10.1
DNS1=202.106.0.20
DEVICE=bond0
BOOTPROTO=none
NETMASK=255.255.255.0
TYPE=Ethernet
IPADDR=192.168.10.100
ONBOOT=yes
USERCTL=no

也可以使用 setup 命令进入网卡配置模式,添加一块行的网卡: <New Device>  --> Ethernet--> Name :bond0 --> Device:bond0  ……保存后-->进入bond0的配置文件,将ONBOOT参数改为yes。

2.修改网卡em1和em2 配置

DEVICE=em1  ## 网卡em1:DEVICE 参数为em1   网卡em2:DEVICE 参数为em2
ONBOOT=no
TYPE=Ethernet
MASTER=bond0
BOOTPROTO=none
USERCTL=no
SLAVE=yes
IPV6INIT=no

3.编辑bond0.conf配置文件,及配置bond模式

创建bond.config配置文件:

vi /etc/modprobe.d/bond0.conf
添加如下行:
alias  bond0 bonding

options bond0 miimon=100 mode=1

miimon 是链路监测的时间间隔单位是毫秒,miimon=100的意思就是,每100毫秒检测网卡和交换机之间是否连通,如不通则使用另外的链路。

重启网卡服务:service network restart  (在交换机也做好channel后再重启网卡服务,这样可以和服务器不断开连接

如果还是看不到bond0, 关闭 NetworkManager服务。重启网卡,再次查看。

注:
mode的值表示工作模式,他共有0,1,2,3,4,5,6这7种模式,常用的为0,1两种。
mode=0表示load balancing (round-robin)为负载均衡方式,两块网卡都工作。
mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份.
mode=2表示balance-x,提供负载均衡和冗余功能。
mode=3表示broadcast,这个模式提供容错性。
mode=4表示802.3ad,提供了ethtool的迅速,以及使用了802.3ad模式
mode=5表示balance-tlb,自动适应负载均衡,自动切换故障。在此基础上Ethtool支持驱动。
mode=6表示在5模式的基础上优化了arp的广播信息。

bonding模式介绍和所需条件详见:

http://blog.chinaunix.net/uid-49097-id-78251.html

 centos 7 配置聚合

  bond 配置文件

TYPE=Bond
BOOTPROTO=none
IPV6INIT=no
NAME=bond0
DEVICE=bond0
ONBOOT=yes
IPADDR=x.x.x.x
PREFIX=24
GATEWAY=x.x.x.1
DNS1=202.106.0.20
BONDING_OPTS="mode=0 miimon=100"

 

  ifcfg-emx 配置文件  

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eno1
UUID=01a82869-cf9a-41e5-862d-871b3b764da9
DEVICE=eno1
ONBOOT=yes
#添加以下两行即可
MASTER=bond0 
SLAVE=yes

 

三、交换机下的配置:

(config)#interface range gigabitEthernet 0/6 -7
(config-if-range)#switchport access vlan 10 
(config-if-range)#channel-protocol lacp
(config-if-range)#channel-group 3 mode active
(config)#interface port-channel 3
(config-if)#switchport access vlan 10

 

 

四、拆除bond网卡

  Centos 7:

    # rmmod bonding;systemctl restart network;sleep 5;systemctl restart network    

  Centos 6:

    # rmmod bonding;service network restart;sleep 5;service network restart

    

 

 

 

 

    

分类:

技术点:

相关文章: