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 ~]#

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

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐