# 链路聚合

链路聚合(网卡绑定)

  • 链路聚合(7系列起),也叫聚合连接、网卡组队、网卡绑定(5、6系列)。
  • 链路聚合:由多块(两块足够)网卡 team-slave 一起组建而成的虚拟网卡 team ,常见配置方式:轮询(roundrobin)、热备份(activebackup)、负载均衡(loadbalance)等。
    • 热备份:主网卡故障后,备份网卡成为主网卡,原先的主网卡修复后成为新的备份网卡。
  • 配置链路聚合需要的软件:teamdNetworkManager-team(是软件NetworkManager的插件,服务NetworkManager.service
  • 步骤:装包、重启服务——》创建链路聚合网卡——》添加组成链路聚合网卡的真实网卡——》配置链路聚合网卡——》删除干扰的网卡配置文件——》重启
  • 命令:
    • man teamd.conf:查找链路聚合的示例。例如热备份:"runner": {"name": "activebackup"
    • nmcli connection add type team ifname 自定义链路聚合网卡名 con-name 链路聚合网卡别名 config '{"runner": {"name": "activebackup"}}':创建链路聚合网卡,热备份方式。
    • nmcli connection add type team-slave ifname 网卡本名 con-name 网卡别名 master 链路聚合网卡别名:指定提供链路聚合网卡功能的真实网卡。
    • teamdctl 链路聚合网卡名 state:查看链路聚合网卡的状态。可以查看使用真实网卡。
    • nmcli device show 链路聚合网卡别名:详细信息。
// 链路聚合:需要两张没有配置IP地址的网卡(处于同一个网络):关机——》增加网卡硬件——》开机——》链路聚合配置——》启用网卡
创建一台虚拟机team,配置网卡命名规则,关机增加网卡硬件,两张网卡选择同一个网络(例如192.168.88.0网络),开机,重启
虚拟机team:
[root@team ~]# ifconfig eth0 | head -2
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.88.184  netmask 255.255.255.0  broadcast 192.168.88.255
[root@team ~]# ifconfig eth1 | head -2
    eth1: flags=4098<BROADCAST,MULTICAST>  mtu 1500
            ether 52:54:00:89:31:6c  txqueuelen 1000  (Ethernet)
// 装包、启服务
[root@team ~]# yum repoinfo			
[root@team ~]# yum install -y teamd NetworkManager-team			// 配置NetworkManager-team的依赖包含NetworkManager
[root@team ~]# systemctl enable NetworkManager.service			// 大多数Linux已安装NetworkManager并开机自启
[root@team ~]# systemctl restart NetworkManager.service			// 一定要重启服务
// 配置链路聚合
[root@team ~]# nmcli connection show
    NAME         UUID                                  TYPE      DEVICE 
    System eth0  5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03  ethernet  eth0   
[root@team ~]# nmcli connection delete System\ eth0 
[root@team ~]# man teamd.conf		// 输入/examples查找示例,复制`"runner": {"name": "activebackup"}}`
[root@team ~]# nmcli connection add type team ifname team0 con-name team0 config '{"runner": {"name": "activebackup"}}'
[root@team ~]# nmcli connection add type team-slave ifname eth0 con-name team0-1 master team0
[root@team ~]# nmcli connection add type team-slave ifname eth1 con-name team0-2 master team0
[root@team ~]# nmcli connection modify team0 ipv4.method manual ipv4.address 192.168.88.154/24 autoconnect yes
[root@team ~]# nmcli connection show
    NAME     UUID                                  TYPE      DEVICE 
    team0    3645c543-f167-4410-a8f2-f9b4490aba03  team      team0  
    team0-1  e07c3d15-f6cf-4c78-a234-3544455469f7  ethernet  eth0   
    team0-2  28d06030-e479-4241-933d-6791b2f9bbf0  ethernet  --     
[root@team ~]# rm -f /etc/sysconfig/network-scripts/ifcfg-{eth0,eth1}
[root@team ~]# reboot
// 重启后查看
[root@team ~]# teamdctl team0 state
    setup:
      runner: activebackup
    ports:
      eth0
        link watches:
          link summary: up
          instance[link_watch_0]:
            name: ethtool
            link: up
            down count: 0
      eth1
        link watches:
          link summary: up
          instance[link_watch_0]:
            name: ethtool
            link: up
            down count: 0
    runner:
      active port: eth1								// 当前由eth1网卡提供服务
[root@team ~]# ping 192.168.88.254					// ping通真机
[root@team ~]# nmcli connection down team0-2		// 主网卡故障后由备份网卡提供服务
[root@team ~]# ping 192.168.88.254					// ping通真机
[root@team ~]# nmcli connection up team0-2			// 原先的主网卡恢复后成为新的备份网卡
[root@team ~]# teamdctl team0 state
    setup:
      runner: activebackup
    ports:
      eth0
        link watches:
          link summary: up
          instance[link_watch_0]:
            name: ethtool
            link: up
            down count: 0
      eth1
        link watches:
          link summary: up
          instance[link_watch_0]:
            name: ethtool
            link: up
            down count: 0
    runner:
      active port: eth0								// 当前由eth0网卡提供服务
[root@team ~]# nmcli connection show				
    NAME     UUID                                  TYPE      DEVICE 
    team0    3645c543-f167-4410-a8f2-f9b4490aba03  team      team0  
    team0-1  e07c3d15-f6cf-4c78-a234-3544455469f7  ethernet  eth0   
    team0-2  28d06030-e479-4241-933d-6791b2f9bbf0  ethernet  eth1 
[root@team ~]# ifconfig 
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            ether 52:54:00:a9:53:63  txqueuelen 1000  (Ethernet)
            RX packets 15  bytes 806 (806.0 B)
            RX errors 0  dropped 3  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            ether 52:54:00:a9:53:63  txqueuelen 1000  (Ethernet)
            RX packets 591  bytes 36756 (35.8 KiB)
            RX errors 0  dropped 515  overruns 0  frame 0
            TX packets 7  bytes 390 (390.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 24  bytes 1600 (1.5 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 24  bytes 1600 (1.5 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    team0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500						// 链路聚合网卡
            inet 192.168.88.154  netmask 255.255.255.0  broadcast 192.168.88.255	// IP地址
            ether 52:54:00:a9:53:63  txqueuelen 1000  (Ethernet)
            RX packets 5  bytes 190 (190.0 B)
            RX errors 0  dropped 5  overruns 0  frame 0
            TX packets 7  bytes 390 (390.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值