CentOS7的聚合链路

1、环境介绍

[root@rhcc ~]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 
ENERAL.DEVICE:                         ens37
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:04:8C:9B
192.168.137.128/24
192.168.137.0/24
192.168.137.1

GENERAL.DEVICE:                         ens38
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:04:8C:A5
192.168.137.129/24
192.168.137.1
因为是在虚拟机中进行的实验只能进行高可用测试
聚合链路的几种模式:
broadcast 传输所有端口进来的数据包
roundrobin 随机计算发送数据(轮询)
activebackup  高可用性
loadbalance 负载均衡
josn的配置{"runner": {"name":"activebackup"}} ##模式修改只需修改这个格式中的name字段的值

2、几种做聚合链路的方式
2.1 图形化

[root@rhcc ~]# nmtui-edit

图片.png
图片.png
图片.png
JSON配置模式在team0这个虚拟网卡里配置
配置完成后重启网卡

[root@rhcc ~]# systemctl restart network
[root@rhcc ~]# ip a
---
5: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team0 state UP group default qlen 1000
    link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff
6: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team0 state UP group default qlen 1000
    link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff
10: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff
    inet 192.168.137.128/24 brd 192.168.137.255 scope global noprefixroute team0
       valid_lft forever preferred_lft forever
    inet6 fe80::f39f:f544:b69f:48db/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
---

2.2 命令行

第一种
[root@rhcc ~]# man nmcli-examples
找到以下照着模板抄
           $ nmcli con add type team con-name Team1 ifname Team1 config team1-ma
ster-json.conf
           $ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master
 Team1
           $ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master
 Team1
这是我本地的网卡名称
ens37:  link/ether 00:0c:29:04:8c:9b
ens38:  link/ether 00:0c:29:04:8c:a5

[root@rhcc ~]# nmcli con add type team con-name Team1 ifname Team1 config '{"runner":{"name":"activebackup"}}'
[root@rhcc ~]# nmcli con add type ethernet con-name Team1-slave1 ifname ens37 master Team1
[root@rhcc ~]# nmcli con add type ethernet con-name Team1-slave2 ifname ens38 master Team1

第二种
[root@rhcc 1]# pwd
/usr/share/doc/teamd-1.27/example_ifcfgs/1
[root@rhcc 1]# ls
ifcfg-eth1  ifcfg-eth2  ifcfg-team_test0
这里是team的模板配置文件,直接复制到网卡的配置文件目录修改修改
cd /etc/sysconfig/network-scripts/
   18  ls
   19  mv ifcfg-eth1 ifcfg-ens37
   20  mv ifcfg-eth2 ifcfg-ens38
   21  vim ifcfg-ens37
   22  vim ifcfg-ens38
   23  vim ifcfg-team_test0 
   24  systemctl restart network
[root@rhcc network-scripts]# cat ifcfg-ens37;cat ifcfg-ens38
DEVICE="ens37"
DEVICETYPE="TeamPort"
ONBOOT="yes"
TEAM_MASTER="team_test0"
DEVICE="ens38"
DEVICETYPE="TeamPort"
ONBOOT="yes"
TEAM_MASTER="team_test0"
[root@rhcc network-scripts]# cat ifcfg-team_test0 
DEVICE="team_test0"
DEVICETYPE="Team"
ONBOOT="yes"
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=192.168.137.128
GATEWAY=192.168.137.1
TEAM_CONFIG='{"runner": {"name": "roundrobin"}}'

5: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team_test0 state UP group default qlen 1000
    link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff
6: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team_test0 state UP group default qlen 1000
    link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff
7: team_test0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff
    inet 192.168.137.128/24 brd 192.168.137.255 scope global noprefixroute team_test0

3、总结
链路聚合主要是备份网卡,实现网卡交互工作,避免网卡单点故障,提高系统的可靠性。其中除了做热备份(activebackup)连接冗余,其他的模式是需要交换机做[EtherChannel (PAgP and LACP) 以太通道]

简书链接
END

posted @ 2018-11-07 06:47  听_风~  阅读(2101)  评论(0编辑  收藏  举报