生產環境中linux bonding 主備模式slave網卡切換的方法

原文作者:http://dawei2015.blog.51cto.com/140637/1714977


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

整個過程沒有出現丟包,斷網



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章