Team多网卡绑定
team支持的模式:
broadcast:每个网卡都传送数据包
roundrobin:每个网卡轮询方式传送数据
activebackup:网卡之间有主备,主传送数据包,备的不传送,主网卡down了,备才传送
loadbalance:监控流量并使用哈希函数,使得每个网卡传送的数据包达到相等
lacp:需要借助交换机,实现高级的负载均衡
1.查看示例文件:
[root@localhost ~]# cd /usr/share/doc/teamd/example_configs/
[root@localhost example_configs]# ll
2.创建team_dev设备和team_con会话
[root@localhost ~]# nmcli c add type team con-name team_con ifname team_dev config '{"runner":{"name":"activebackup","hwaddr_policy":"by_active"}}'
3.查看创建好的team_con会话
[root@localhost ~]# nmcli c show
NAME UUID TYPE DEV>
team_con 05cece6a-1326-407b-8eda-196d9503c4a1 team tea>
virbr0 bb271c61-6361-49d1-84e7-f8351096fc96 bridge vir>
team_con_2 03c2d929-7e08-488a-891e-5794558c3b30 ethernet ens>
ens160 01b71119-1239-43fd-80e6-ccc2b2d9f7c8 ethernet -- >
rhce 63a3ff6c-04d6-4877-926a-8473b18419b4 ethernet -- >
rhce_auto e46841da-caea-45a7-9b2d-388274240725 ethernet -- >
team_con_1 f0c01e71-ef48-48e2-a4e1-28639de72890 ethernet -- >
Wired connection 1 e08eb043-c76b-3e94-be9d-1a689f4981ac ethernet -- >
4.修改team_con会话的IP地址和网关
[root@localhost ~]# nmcli c modify team_con ipv4.addresses 192.168.231.131/24
[root@localhost ~]# nmcli c modify team_con ipv4.gateway 192.168.231.2
[root@localhost ~]# nmcli c modify team_con ipv4.dns 8.8.8.8
5.更改IP地址获取方式为手动
[root@localhost ~]# nmcli connection modify team_con ipv4.method manual
6.添加设备到team_dev, type:team-slave
[root@localhost ~]# nmcli c add type team-slave con-name team_con_1 ifname ens160 master team_dev
[root@localhost ~]# nmcli c add type team-slave con-name team_con_2 ifname ens224 master team_dev
7.激活:先激活team-slave,再激活team
1. nmcli c up team_con_1
2. nmcli c up team_con_2
3. nmcli c up team_con
#激活主会话时远程连接软件会卡掉为正常现象
IP a查看ens160,ens224的mac地址是否不一致
8.查询team连接的状态
[root@localhost ~]# teamdctl team_dev state
setup:
runner: activebackup
ports:
ens160
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens160
9.验证:切换
[root@localhost ~]# nmcli device disconnect ens160
[root@localhost ~]# teamdctl team_dev state
setup:
runner: activebackup
ports:
ens160
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens224
电脑终端ping虚拟网卡:
PS C:\Users\Administrator> ping 192.168.231.131
正在 Ping 192.168.231.131 具有 32 字节的数据:
来自 192.168.231.131 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.231.131 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.231.131 的回复: 字节=32 时间=1ms TTL=64
来自 192.168.231.131 的回复: 字节=32 时间=1ms TTL=64
192.168.231.131 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 1ms,平均 = 0ms
测试主备切换ping百度
root@localhost ~]# ping www.baidu.com
PING www.wshifen.com (103.235.46.39) 56(84) bytes of data.
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=1 ttl=128 time=55.1 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=2 ttl=128 time=61.6 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=3 ttl=128 time=97.3 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=4 ttl=128 time=65.4 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=5 ttl=128 time=86.3 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=6 ttl=128 time=110 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=7 ttl=128 time=133 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=8 ttl=128 time=154 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=9 ttl=128 time=69.8 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=10 ttl=128 time=87.2 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=11 ttl=128 time=106 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=12 ttl=128 time=73.9 ms
可以看出在第6次ICMP有所波动