RHEL7 Network Teaming(网卡绑定)配置与测试

2014-03-13 07:41龙君芳
电脑与电信 2014年9期
关键词:配置文件网卡交换机

龙君芳

RHEL7 Network Teaming(网卡绑定)配置与测试

龙君芳

(广东技术师范学院天河学院,广东 广州 510540)

本文重点介绍Network Teaming的两种模式(轮循与主备)的原理与配置。本文采用命令行设置与修改配置文件两种不同的方法对Network Teaming进行配置,其中用命令行的方式配置了轮循模式,用修改配置文件的方式来配置主备模式。

Network Teaming;轮循;主备

1.引言

现在的服务器至少都有两个网卡,如何同时充分利用这两张网卡,RHEL7推出了它的应用Network Teaming。Network Teaming是将多个网卡绑定在一起,在逻辑上来讲就相当于一个网卡,它可以提高网络的容错与吞吐量。在RHEL7中使用的是Teaming技术,而在RHEL6使用的是Bonding技术。Teaming是一项新的实现技术,不影响老的Bonding技术的应用。配置Teaming有两种方式,第一种是使用nmcli命令,第二种是直接修改配置文件。

2.配置方法及测试

Teaming模式有 broadcast、roundrobin、activebackup、loadbalance、lacp几种,下面介绍最常用的两种模式。

2.1 roundrobin模式

roundrobin模式也称为轮循模式,它是基于每一个包的,当某一台服务器的两个网卡设置为roundrobin模式的Teaming,此时服务器发出的数据包,就会在两个物理网卡上进行轮循,即第一个数据包走第一个网卡,第二个数据包走第二个网卡,第三个数据包走第一个网卡,第四个数据包走第二个网卡,依此轮循。这种模式需要交换机的支持,必须要在交换机上做以太通道。拓扑设计图如1所示:

图1 roundrobin模式拓扑设计图

该模式配置步骤如下:

(1)服务器上的配置

步骤1:查看网卡

[root@localhost~]#ip addr

通过上面的命令,发现有两个网卡,ens33与ens37

步骤2:创建team接口team0,同时设置teaming模式为roundrobin

[root@localhost~]#nmcli connection add type team con-name team0 ifnameteam0 config '{"runner":{"name":"roundrobin"}}'

步骤3:给接口team0设置IP地址

[root@localhost~]#nmcli connection modify team0 ipv4.addresses 192.168.1.1/24

[root@localhost~]#nmcli connection modify team0 ipv4.method manual

步骤4:把物理接口加入到team0

[root@localhost~]#nmcli connection add type team-slave conname team0-port1 ifname ens33 master team0

[root@localhost~]#nmcli connection add type team-slave conname team0-port2 ifname ens37 master team0

(2)查看team0状态

可以看出,teaming的模式为roundrobin,同时有两个物理接口,分别是ens33与ens37,都是up的状态。

[root@localhost~]#teamdctl team0 state

setup:

runner:roundrobin

ports:

ens33

link watches:

link summary:up

instance[link_watch_0]:

name:ethtool

link:up

ens37

link watches:

link summary:up

instance[link_watch_0]:

name:ethtool

link:up

(3)交换机上配置以太通道,可以参考交换机的配置手册

(4)测试

从两方面进行测试,首先测试禁用其中某一块网卡,别一块网卡会不会照常工作,测试如下:

在一台windows主机上ping服务器的时候,加上-t参数,也就是说一直ping下去,然后在服务器上禁用某一个网卡,执行命令:

[root@localhost network-scripts]#nmcli device disconnect ens33,

查看在windows主机上还是能ping通服务器的。

测试的另一方面是看它们之间有没有轮循,可以采用抓包的方式,比如ping四个包,如果第一块网卡上面有两个请求包,第二块网卡上有两个请求包,就说明它们之间有轮循。

2.2 activebackup模式

activebackup是主备模式,不需要交换机的支持,当网卡绑定成这种模式之后,此时一个物理网卡的状态是主的,一个物理网卡的状态是备的,平时是利用主的网卡传输数据包,当主网卡失效之后,备用的网卡就会接管主网卡,进行工作。

拓扑同上,配置步骤如下:

(1)服务器上的配置

步骤1:配置team0的配置文件

[root@localhost~]#cd/etc/sysconfig/network-scripts

[root@localhost network-scripts]#cat ifcfg-team0

DEVICE=team0

TEAМ_CONFIG="{"runner":{"name":"activebackup"}}"

DEVICETYPE=Team

BOOTPROTO=none

NAМE=team0

ONBOOT=yes

IPADDR0=192.168.1.1

PREFIX0=24

步骤2:配置team0-port1与team0-port2

[root@localhost network-scripts]#cat ifcfg-team0-port1

NAМE=team0-port1

DEVICE=ens33

ONBOOT=yes

TEAМ_МASTER=team0

DEVICETYPE=TeamPort

[root@localhost network-scripts]#

[root@localhost network-scripts]#cat ifcfg-team0-port2

NAМE=team0-port2

DEVICE=ens37

ONBOOT=yes

TEAМ_МASTER=team0

DEVICETYPE=TeamPort

步骤3:启动team0

[root@localhost network-scripts]#systemctl restart network

(2)查看teaming

[root@localhost network-scripts]#teamdctl team0 state

setup:

runner:activebackup

ports:

ens33

link:up

ens37

link:up

runner:

active port:ens33

(3)测试

1)可以在另外一台主机来ping此台服务器,当禁用主网卡ens33的时候,另一个备用网卡ens37就会接管工作。

[root@localhost network-scripts]#nmcli device disconnect ens33

[root@localhost network-scripts]#teamdctl team0 state

<输出省略>

active port:ens37

2)启用网卡ens33,为了高可用性,ens37还处于active状态。

[root@localhost network-scripts]#nmcli connection up team0-port1

[root@localhost network-scripts]#teamdctl team0 state

<输出省略>

active port:ens37

3.总结

RHEL7的网卡绑定技术,不仅可以实现冗余,还可以提高网络的吞吐量。而且还有多种模式可以选择,有效地利用了两块网卡。

[1]Otto.接触Linux RedHat7.3[N].电脑报,2012-07-29.

[2]黄秀丽.基于嵌入式Linux的实时性改进的研究与应用[J].辽宁师专学报(自然科学版),2005,(02).

The Configuration and Test of RHEL7 Network Teaming(network card binding)

Long Junfang
(Tianhe College of Guangdong Polytechnic Normal University,Guangzhou 510540,Guangdong)

tract】 This paper focuses on the principle and configuration of two modes of Network Teaming(roundrobin and activebackup).It uses the command line setup and configuration files modification to configure the Network Teaming.The command line setup is used for roundrobin,while the configuration file modification is used for activebackup.

words】 network teaming;roundrobin;activebackup

龙君芳,女,湖南衡阳人,学士,讲师,研究方向:计算机科学与技术。

猜你喜欢
配置文件网卡交换机
部署Linux虚拟机出现的网络故障
互不干涉混用Chromium Edge
基于地铁交换机电源设计思考
Server 2016网卡组合模式
基于Zookeeper的配置管理中心设计与实现
忘记ESXi主机root密码怎么办
修复损坏的交换机NOS
为View桌面准备父虚拟机
使用链路聚合进行交换机互联
挑战Killer网卡Realtek网游专用Dragon网卡