RHCE练习题 4.配置链路聚合 四种方法

前端之家收集整理的这篇文章主要介绍了RHCE练习题 4.配置链路聚合 四种方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

题目 配置链路聚合


在server0和desktop0之间按一下要求配置:
- 此链路使用接口eth1和eth2
- 此链路在一个接口失效时仍然能工作
- 此链路在server0使用下面的地址 192.168.0.101/255.255.255.0
- 此链路在desktop0使用下面的地址 192.168.0.102/255.255.255.0
- 此链路在系统重启之后依然保持正常状态

接口现况

[root@server0 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 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
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:00:00:0b brd ff:ff:ff:ff:ff:ff
    inet 172.25.0.11/24 brd 172.25.0.255 scope global dynamic eth0
       valid_lft 17060sec preferred_lft 17060sec
    inet6 fe80::5054:ff:fe00:b/64 scope link
       valid_lft forever preferred_lft forever
4: eth1: <BROADCAST,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 26:d4:ed:35:28:b8 brd ff:ff:ff:ff:ff:ff
6: eth2: <BROADCAST,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 9a:4f:bb:1d:db:17 brd ff:ff:ff:ff:ff:ff

操作

操作要在server0和desktop0上均配置。但是以下只用server0做演示。方法都一样的。


方法1 nmcli Command-Line 工具

  • 添加一个team类型的接口,配置名叫team0,接口名叫team0,JSON配置,由于需要一个接口失效的时候,依然能工作,所以指定的是 activebackup。

    [root@server0 ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}
  • 将eth1和eth2添加进,team0。

[root@server0 ~]# nmcli connection add type team-slave con-name team0-eth1 ifname eth1 master team0
[root@server0 ~]# nmcli connection add type team-slave con-name team0-eth2 ifname eth2 master team0
[root@server0 ~]# nmcli connection modify team0 ipv4.method manual ipv4.addresses '192.168.0.101/24'
  • 重启网络服务 systemctl restart network

方法2 nmtui

  • [root@server0 ~]# nmtui -> [Edit a connection] -> [Add] -> Team -> [create]
    - 创建一个team类型接口

  • profile name => team0
    - 配置名

  • Device => * team0*
    - 设备名

  • TEAM Slaves [Add] -> Ethernet -> [create] #添加从网卡eth1
    - profile name => team0-eth1
    - Device => eth1
    - [OK]

  • TEAM Slaves [Add] -> Ethernet -> [create] #添加从网卡eth2
    - profile name => team0-eth2
    - Device => eth2
    - [OK]

  • JSON configuration -> [Add] => {"runner":{"name":"activebackup"}}
    - 添加JSON配置

  • IPv4 CONFIGURATION => Manual -> [show] #配置IP
    - [Add] -> Addresses => 192.168.0.101/24

  • [ok]

  • [root@server0 ~]# systemctl restart network 重启网络服务生效

操作截图


方法3 nm-connection-editor GUI图形界面配置

其实和nmtui配置大同小异。就是界面不太一样。懒得重复,不赘述.
需要支持xdmcp服务。1. linux ssh连接的时候加 -X选项 2. windows用Xmanager 3. 直接进图形化的操作系统操作。

  • [root@server0 ~]# nm-connection-editor 打开图形化界面



方法4 直接新建配置文件

  • 新建一个team的配置文件[root@server0 ~]# vim /etc/sysconfig/network-scripts/ifcfg-team0

    NAME=team0          #配置名
    DEVICE=team0        #设备名
    DEVICETYPE=Team     #网卡类型
    TEAM_CONFIG="{\"runner\":{\"name\":\"activebackup\"}}"       #JSON配置
    BOOTPROTO=none         #不启用
    IPADDR0=192.168.0.101  #配置IP
    PREFIX0=24             #掩码
    ONBOOT=yes             #开机启用
  • 添加从网卡eth1配置 [root@server0 ~]# cat /etc/sysconfig/network-scripts/ifcfg-team0-eth1

    NAME=team0-eth1
    DEVICE=eth1
    BOOTPROTO=none #其实这里就是dhcp也无所谓,只要DEVICETYPE类型是teamport 就获取不了IP
    ONBOOT=yes
    TEAM_MASTER=team0
    DEVICETYPE=TeamPort
  • 添加从网卡eth2配置 [root@server0 ~]# cat /etc/sysconfig/network-scripts/ifcfg-team0-eth2

    NAME=team0-eth2
    DEVICE=eth2
    BOOTPROTO=none 
    ONBOOT=yes
    TEAM_MASTER=team0
    DEVICETYPE=TeamPort
  • [root@server0 ~]# systemctl restart network 重启网络服务

如果存在eth1和eth2其它配置文件,建议删除,以免引起冲突。

检验 ip addrteamdctl <team name> state

#查看网卡状态
[root@server0 ~]# ip addr
1: lo: <LOOPBACK,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:00:00:0b brd ff:ff:ff:ff:ff:ff
    inet 172.25.0.11/24 brd 172.25.0.255 scope global dynamic eth0
       valid_lft 21404sec preferred_lft 21404sec
    inet6 fe80::5054:ff:fe00:b/64 scope link
       valid_lft forever preferred_lft forever
4: eth1: <BROADCAST,LOWER_UP> mtu 1500 qdisc pfifo_fast master team0 state UP qlen 1000
    link/ether 26:d4:ed:35:28:b8 brd ff:ff:ff:ff:ff:ff
6: eth2: <BROADCAST,LOWER_UP> mtu 1500 qdisc pfifo_fast master team0 state UP qlen 1000
    link/ether 26:d4:ed:35:28:b8 brd ff:ff:ff:ff:ff:ff
9: team0: <BROADCAST,LOWER_UP> mtu 1500 qdisc noqueue state UP
    link/ether 26:d4:ed:35:28:b8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.101/24 brd 192.168.0.255 scope global team0
       valid_lft forever preferred_lft forever
    inet6 fe80::3cca:85ff:fe6e:a8e8/64 scope link
       valid_lft forever preferred_lft forever
# 查看team0详细状态
[root@server0 ~]# teamdctl team0 state
setup:
  runner: activebackup
ports:
  eth1
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
  eth2
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
runner:
  active port: eth1

补充 常用的网卡绑定模式

类型 描述
activebackup 自动备援模式
loadbalance 负载均衡模式
roundrobin 轮换模式
原文链接:https://www.f2er.com/javaschema/283425.html

猜你在找的设计模式相关文章