一个专业运
维技术分享!

linux bonding 主备模式slave网卡切换的方法

linux bonding 主备模式slave网卡切换的方法

    我们有时候做演练或测试,测试bonding slave网卡切换,或者疑是因为一块网卡有问题,想切换到另外一块slave网卡,通常情况下,我们可能采用ifdown eth0或ifconfig eth0 down的方法来切换到另外一块网卡,但是这种方法在 生产环境中可能出现网络及系统告警或者可能丢包,也可能也存在一些风险。

下面介绍一种方法,不需要ifdown网卡就能切换,比较适合于在生产环境中正在提供业务的linux服务器,比如出现了丢包,或者有闪断、网络慢或者日志有网络报错,怀疑是此网卡硬件或固件有问题,想切换到另外一块slave网卡,而又不想断网出现监控系统告警,业务中断等对业务高可用要求比较高的情况。

# ifenslave -c bond0 eth1 将一个物理接口eth1作为active接口

不建议# ifenslave -d bond0 eth0    //从bond0中删除掉eth0

如下所示(适用于主备模式)

[root@redhat ~]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:5a:9d:28
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:5a:9d:32
Slave queue ID: 0
[root@redhat ~]# ifenslave -c bond0 eth1
[root@redhat ~]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:5a:9d:28
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:5a:9d:32
Slave queue ID: 0
[root@redhat ~]# 

整个过程没有出现丢包,断网



微信扫描下方的二维码阅读本文

赞(5) 打赏
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。小柳实验室 » linux bonding 主备模式slave网卡切换的方法

相关推荐

  • 暂无文章

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏