Redhat 网卡绑定

说在前面的话

在实际生产中,为了服务的高可用性。通常都要做网卡绑定。通常见的有以下四种,但最长用的为activebackup模式。

捆绑类型 效果
Broadcast 传输来自所有端口的包
roundrobin 以轮循的模式传输所有端口的包
activebackup 主备模式这是一个故障迁移程序,监控链接更改并选择活动的端口进行传输
loadbalance 监控流量并使用哈希函数以尝试在选择传输端口的时候达到完美均衡

简单配置

向虚拟机添加两块网卡:eth0和eth1。将其绑定为bound1,模式为activebackup

1、向虚拟主机添加两块网卡,备用。
添加网卡

2、配置网卡

#创建bound1。这个conf比较烦,你可以先写{"":{"":""}},然后往里面填runner,name等
nmcli connection add con-name bound1 ifname bound1 type team config '{"runner":{"name":"activebackup"}}'


#将eth0 eth1添加到bound1中
nmcli connection add con-name bound1-slave1 ifname eth0 type team-slave master bound1
nmcli connection add con-name bound1-slave2 ifname eth1 type team-slave master bound1


#修改bound1网卡信息
nmcli connection modify bound1 ipv4.addresses 192.168.0.111/24 ipv4.gateway 192.168.0.1 ipv4.method manual connection.autoconnect yes


#启动网卡
nmcli connection up bound1-slave1 && nmcli connection up bound1-slave2 && nmcli connection up bound1

3、查看结果

teamdctl bound1 state
在这里插入图片描述

模拟一个网卡坏掉:

nmcli connection down bound1-slave1

模拟网卡坏掉

注意当之前的master起来之后,它是没办法抢占的。
恢复网卡

简单吧。就到了,容我先去出点儿东西。觉得之前的好多都没整理,我得加把油。

猜你喜欢

转载自blog.csdn.net/GhostRaven/article/details/85224922