共计 1561 个字符,预计需要花费 4 分钟才能阅读完成。
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 ~]#
整个过程没有出现丢包,断网
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2015-11/125369.htm
![post-qrcode](https://www.xgss.net/wp-content/uploads/2023/07/二维码-微信公众号256x256.jpg)