Linux网络链路聚合

teamd的作用和模式

teamd的作用

网络组队(聚合链路)是一种以逻辑方式将NIC链接到一起,从而实现故障转移或者吞吐量的方法。
组队是一种新的实现方式,提供了更好的性能,并且由于其模块化设计,因此可扩展性更强

teamd的模式

teamd :可以实现以下模式的聚合链路
roundrobin :以轮循的模式传输所有端口的包
activebakup :主备模式这是一个故障迁移程序,监控链接更改并选择活动的端口进行传输
loadbalance :监控流量并使用哈希函数以尝试在选择传输端口的时候达到完美均衡
broadcast : 广播容错,设备通过所有端口传输数据包

配置teamd

1、创建主备

//修改两天虚拟机的主机名
[root@node1 ~]# hostnamectl hostname server1.example.com
[root@node2 ~]# hostnamectl hostname server2.example.com

//查看网卡
[root@server1 ~]# nmcli connection show 
NAME                UUID                                  TYPE      DEVICE 
ens160              42fc3592-6a69-39f3-be2a-3da649116af2  ethernet  ens160 
lo                  2868d5f7-8863-494f-a79c-845aaaf291d0  loopback  lo     
Wired connection 1  ea64c62f-d0b5-3036-9036-6065df203b9c  ethernet  --     
Wired connection 2  84b41ec0-b984-33a4-90da-d22846235428  ethernet  --

//删除网卡
[root@server1 ~]# nmcli connection delete Wired\ connection\ 1
Connection 'Wired connection 1' (ea64c62f-d0b5-3036-9036-6065df203b9c) successfully deleted.
[root@server1 ~]# nmcli connection delete Wired\ connection\ 2
Connection 'Wired connection 2' (84b41ec0-b984-33a4-90da-d22846235428) successfully deleted.
[root@server1 ~]# nmcli connection show 
NAME    UUID                                  TYPE      DEVICE 
ens160  42fc3592-6a69-39f3-be2a-3da649116af2  ethernet  ens160 
lo      2868d5f7-8863-494f-a79c-845aaaf291d0  loopback  lo   

NAME : 链接名称
UUID : 网卡唯一标识
TYPE : 网卡类型
DEVICE : 设备名称(真实网卡名称) 

//创建组队
[root@server1 ~]# nmcli connection add con-name team0  type team ifname team0 config '{"runner": {"name": "activebakup"}}'

 con-name	// 添加链接名称
 type		// 添加网卡类型
 ifname		// 添加设备名称(真实网卡名称) 
 config		// 添加teamd的模式
 runner		// 运行teamd的模式
 name		// 添加teamd的聚合链路类型

//配置team0的IP地址
[root@server1 ~]# nmcli connection modify team0 ipv4.addresses 192.168.0.1/24 ipv4.method manual connection.autoconnect yes

//添加网卡
[[root@server1 ~]# nmcli connection add con-name team0-ens192 ifname ens192  type team-slave master team0
Connection 'team0-ens192' (bb637d04-d19e-4812-afa5-c518eb5300bc) successfully added.
[root@server1 ~]# nmcli connection add con-name team0-ens224 ifname ens224  type team-slave master team0
Connection 'team0-ens224' (679900c9-c1dd-49df-9052-c7098181a1c3) successfully added.
[root@server1 ~]# nmcli connection up team0  //激活
// 先添加的网卡为主其他为备

// 查看
[root@server1 ~]# teamdctl team0 state
setup:
  runner: activebackup
ports:
  ens192
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
  ens224
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: ens192


2、创建网桥

//查看网卡
[root@server1 ~]# nmcli connection show 
NAME                UUID                                  TYPE      DEVICE 
ens160              42fc3592-6a69-39f3-be2a-3da649116af2  ethernet  ens160 
lo                  2868d5f7-8863-494f-a79c-845aaaf291d0  loopback  lo     
Wired connection 1  ea64c62f-d0b5-3036-9036-6065df203b9c  ethernet  --     
Wired connection 2  84b41ec0-b984-33a4-90da-d22846235428  ethernet  --

//删除网卡
[root@server1 ~]# nmcli connection delete Wired\ connection\ 1
Connection 'Wired connection 1' (ea64c62f-d0b5-3036-9036-6065df203b9c) successfully deleted.
[root@server1 ~]# nmcli connection delete Wired\ connection\ 2
Connection 'Wired connection 2' (84b41ec0-b984-33a4-90da-d22846235428) successfully deleted.
[root@server1 ~]# nmcli connection show 
NAME    UUID                                  TYPE      DEVICE 
ens160  42fc3592-6a69-39f3-be2a-3da649116af2  ethernet  ens160 
lo      2868d5f7-8863-494f-a79c-845aaaf291d0  loopback  lo  

//创建桥接
[root@server2 ~]# nmcli connection add con-name bridge0  type bridge ifname bridge0 
Connection 'bridge0' (c87ac0b0-803f-49c0-a2ac-012e06f0698c) successfully added.
[root@server2 ~]# nmcli connection show 
NAME     UUID                                  TYPE      DEVICE  
ens160   42fc3592-6a69-39f3-be2a-3da649116af2  ethernet  ens160  
bridge0  c87ac0b0-803f-49c0-a2ac-012e06f0698c  bridge    bridge0 
lo       6a41e5d7-8b4c-4f4f-9905-4066c5fe5758  loopback  lo

//配置IP
[root@server2 ~]# nmcli connection modify bridge0 ipv4.addresses 192.168.1.1/24 ipv4.method manual connection.autoconnect yes

//添加网卡
[root@server2 ~]# nmcli connection add con-name brideg0-ens161 ifname ens192  type bridge-slave master brideg0
[root@server2 ~]# nmcli connection add con-name brideg0-ens256 ifname ens256 type bridge-slave master brideg0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值