zoukankan      html  css  js  c++  java
  • Linux 链路聚合

    链路聚合

    链路聚合:本实验可以自己通过给虚拟机添加两张网卡自行实验,不需要实验脚本,自己配置网卡接口可能会是eth1和eth2
    题目要求:

    • 此链路使用借口eno1和eno2
    • 此链路在一个接口失效时仍能工作
    • 此链路使用192.168.0.100/255.255.255.0
    • 此链路在系统重启之后保持正常状态

    1、概念

      rhce7 使用teaming实现聚合链路,能够提供网卡绑定之后的网络吞吐性能,并且提供网卡的故障切换处理能力。

      Team是基于一个小型内核驱动实现聚合链路,在用户层提供teamd命令实现链路管理。teamd可以实现以下模式的聚合链路:
      broadcast
      roundrobin         轮询模式
      activebackup     高可用模式
      loadbalance      负载均衡
      lacp                  需要交换机支持lacp协议

    2、执行实验脚本

    执行完成之后发现多了两块网卡,eno1 eno2

    [root@server0 ~]# lab teambridge setup
    Setting up for link aggregation lab ... SUCCESS
    [root@server0 ~]# nmcli device 
    DEVICE TYPE STATE CONNECTION 
    eth0 ethernet connected eth0 
    eno1 ethernet disconnected -- 
    eno2 ethernet disconnected -- 
    lo loopback unmanaged --

    3、配置

    [root@server0 ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}} 
    命令解析:创建一个类型为team的接口,接口的配置文件为team0,产生的设备名叫team0,使用activebackup模式工作
    [root@server0 ~]# nmcli connection modify team0 ipv4.addresses "192.168.0.100/24" ipv4.method manual
    命令解析:为team0网卡配置ip,并且将ip获取方式改为静态(manual)
    [root@server0 ~]# nmcli connection add type team-slave con-name team0-port1 ifname eno1 master team0
    命令解析:建立类型为team-slave的子接口,子接口配置文件为team0-port1,绑定到eno1网卡,主节点为team0
    [root@server0 ~]# nmcli connection add type team-slave con-name team0-port2 ifname eno2 master team0


    查看team0的状态

    [root@server0 ~]# teamdctl team0 state
    setup:
    runner: activebackup     --->表示当前 运行的模式
    ports:
    eno1
    link watches:
    link summary: up
    instance[link_watch_0]:
    name: ethtool
    link: up
    eno2
    link watches:
    link summary: up
    instance[link_watch_0]:
    name: ethtool
    link: up
    runner:
    active port: eno1 --->表示当前使用eno1来收发数据,当eno1断掉之后,切换到eno2继续收发数据。

    测试
    断掉eno1 

    [root@server0 ~]# nmcli device disconnect eno1
    [root@server0 ~]# teamdctl team0 state
    setup:
    runner: activebackup
    ports:
    eno2
    link watches:
    link summary: up
    instance[link_watch_0]:
    name: ethtool
    link: up
    runner:
    active port: eno2 --->可以看到eno1已经不见了,所以用eno2来收发数据

    这时启动eno1,team0不会切换到eno1,会继续使用eno2收发数据,直到eno2断掉,才会切换到eno1继续工作

    4、管理teaming接口配置文件

    (1)查看team0配置文件

    [root@server0 ~]# cat /etc/sysconfig/network-scripts/ifcfg-team0
    DEVICE=team0
    TEAM_CONFIG="{"runner":{"name":"activebackup"}}"
    DEVICETYPE=Team
    BOOTPROTO=none
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    NAME=team0
    UUID=518c7338-1554-4aa7-8171-6bdca5e85366
    ONBOOT=yes
    IPADDR0=192.168.0.100
    PREFIX0=24
    IPV6_PEERDNS=yes
    IPV6_PEERROUTES=yes

    (2)修改team0的配置内容

    将当前正在使用的team配置dump下来保存到/tmp/team0.conf
    [root@server0 ~]# teamdctl team0 config dump >> /tmp/team0.conf
    [root@server0 ~]# cat /tmp/team0.conf
    {
    "device": "team0",
    "mcast_rejoin": {
    "count": 1
    },
    "notify_peers": {
    "count": 1
    },
    "ports": {
    "eno1": {
    "link_watch": {
    "name": "ethtool"
    }
    },
    "eno2": {
    "link_watch": {
    "name": "ethtool"
    }
    }
    },
    "runner": {
    "name": "activebackup"
    }
    }

    (3)将配置配置文件中的activebackup修改为loadbalance(负载均衡模式)

    [root@server0 ~]# vim /tmp/team0.conf 
    ...
    "name": "loadbalance"
    ...

    (4)将修改后的文件重新配置到team0

    [root@server0 ~]# nmcli connection modify team0 team.config /tmp/team0.conf

    (5)修改之后down掉team0,然后重新up

    [root@server0 ~]# nmcli connection down team0 
    [root@server0 ~]# nmcli connection up team0

    (6)还要将team0-port1和team0-port2重新加载

    [root@server0 ~]# nmcli connection up team0-port1
    [root@server0 ~]# nmcli connection up team0-port2

    (7)可以看到模式已经修改成功

    [root@server0 ~]# teamdctl team0 state
    setup:
    runner: loadbalance
    ports:
    eno1
    link watches:
    link summary: up
    instance[link_watch_0]:
    name: ethtool
    link: up
    eno2
    link watches:
    link summary: up
    instance[link_watch_0]:
    name: ethtool
    link: up

    本实验到此结束

    如果有什么建议或者不明白的地方,欢迎评论或者私信我,看到了第一时间回复。

    本人Linux菜鸟,还望各位Linux大佬多多指教。

    附加:nmcli配置网络参数和网络配置文件ifcfg-网卡名对应关系表

    nmcli con modifcfg-*文件
    ipv4.method manual

    BOOTRROTO=none

    ipv4.method auto

    BOOTRROTO=dhcp

    ipv4.address "192.168.0.10/24 192.168.0.1"

    IPAEDDR=192.168.0.10 PREFIX=24 GATEWAY=192.168.0.1

    ipv4.dns 8.8.8.8

    DNS=8.8.8.8

    ipv4.dns-search example.com

    DOMAIN=example.com

    ipv4.ignore-auto-dns true

    PEERNDS=no

    connection.autoconnect yes

    ONBOOT=yes

    connection.id eth0

    NAME=eth0

    connection.interface-name eth0

    DEVICE=eth0

    802-3-ethernet.mac-address...

    HWADDR=...

  • 相关阅读:
    Select 多个表并且相关联转置
    Excel输入公式后只显示公式却不计算如何解决?
    Excel 下来公式 内容却一样
    MySQL数据迁移到SQL Server
    C# Excel 中设置文字对齐方式、方向和换行
    Response.write()弹出窗口的问题!
    ORA-12514 TNS 监听程序当前无法识别连接描述符中请求服务
    Hibernate中连接数据库的配置
    ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
    帝国cms的tags页面url伪静态的设置
  • 原文地址:https://www.cnblogs.com/despotic/p/10772056.html
Copyright © 2011-2022 走看看