bond多網絡卡繫結
bond多網絡卡
| |
|port3 port3|
+-----+----+ +-----+---+
| |port2 port2| |
| switch A +---------------------------+ switch B |
| | | |
+-----+----+ +------+---+
|port1 port1|
| +-------+ |
+------------------+ host1+---------------+
eth0 +-------+ eth1
網絡卡繫結技術有助於保證高可用性特性並提供其它優勢以提高網路效能,在這介紹的Linux雙網絡卡繫結實現就是使用兩塊網絡卡虛擬成為一塊網絡卡,這個聚合起來的裝置看起來是一個單獨的乙太網介面裝置,通俗點講就是兩塊網絡卡具有相同的IP地址而並行連結聚合成一個邏輯鏈路工作,這樣即使其中的一塊物理網絡卡出現故障,也不會導致連線中斷。
網絡卡繫結就是多張網絡卡邏輯上作為一張網絡卡用。可分為,負載均衡繫結和冗餘繫結兩種。
1、負載均衡:
# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.0.100
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
NETWORK=192.168.0.0
GATEWAY=192.168.0.254
ONBOOT=yes
BOOTPROTO=static
TYPE=BOND #type指網絡卡型別為bond
BONDING_OPTS="mode=0 miimon=50" #mode指定模式,miimon為探測的時間間隔(毫秒)
2.編輯各網絡卡的配置檔案
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes
MASTER=bond0 #指定master為bond0
SLAVE=yes #是否為附屬
USERCTL=no
# vim /etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO=none
TYPE=Ethernet
DEVICE=eth1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
3、載入核心模組
# vim /etc/modprobe.conf
alias bond0 bonding
options bond0 miimon=50 mode=0 --mode=[0(banance-rr) | 1(active-backup)]
# modprobe bonding
4、重啟服務:
# /etc/init.d/network restart
5、檢視
# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.1 (October 29, 2006)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Link Failure Count: 1
Permanent HW addr: 00:1b:b9:58:8b:b2
Slave Interface: eth1
MII Status: down
Link Failure Count: 0
Permanent HW addr: 00:07:40:6c:ac:c8
如果是7的話需要停止NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl restart network