1. RHEL4多bond配置
系統版本:Red Hat Enterprise Linux AS release 4 (Nahant Update 6)
網卡數量:4塊
添加兩個bond配置文件(以bond0爲例):
[root@localhost~]# cd /etc/sysconfig/network-scripts/
[root@localhostnetwork-scripts]# cp ifcfg-eth0 ifcfg-bond0
[root@localhostnetwork-scripts]# vim ifcfg-bond0
DEVICE=bond0/bond1
BOOTPROTO=static
IPADDR=192.168.14.70
NETMASK=255.255.0.0
GATEWAY=192.168.0.1
ONBOOT=yes
修改網卡配置文件(以eth0爲例):
[root@localhost network-scripts]#vim ifcfg-eth0
DEVICE=eth0/ethX
BOOTPROTO=static
HWADDR=52:54:00:9A:C5:BD(防止網卡飄移,可註銷)
ONBOOT=yes
MASTER=bond0/bond1
SLAVE=yes
修改內核模塊配置文件:
[root@localhost ~]# vim/etc/modprobe.conf
添加:
alias bond0 bonding
alias bond1 bonding
options bonding mode=1 miimon=100 max_bonds=2
重啓網卡:
[root@localhost ~]# service network restart
查看bond是否加載成功(以bond0爲例):
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v2.6.3-rh (June 8,2005)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0--------目前bond0運行在eth0上
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up--------------------網卡在bond中的狀態
Link Failure Count: 0
Permanent HW addr: 52:54:00:9a:c5:bd
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 52:54:00:5c:d8:0f
測試:
通過手動down同一bond中的一塊網卡,查看是否作切換,使用命令:ping IP
2、RHEL5多bond配置
系統版本:Red Hat Enterprise Linux Server release 5.5 (Tikanga)
網卡數量:4塊
添加兩個bond配置文件(以bond0爲例):
[root@localhost ~]# cd/etc/sysconfig/network-scripts/
[root@localhostnetwork-scripts]# cp ifcfg-eth0 ifcfg-bond0
[root@localhostnetwork-scripts]# vim ifcfg-bond0
DEVICE=bond0/bond1
BOOTPROTO=static
ONBOOT=yes
TYPE=Bond
IPADDR=192.168.15.3
NETMASK=255.255.0.0
修改網卡配置文件(以eth0爲例):
[root@localhost network-scripts]#vim ifcfg-eth0
DEVICE=eth0/ethX
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0/bond1
SLAVE=yes
修改內核模塊配置文件:
[root@localhost ~]# vim /etc/modprobe.conf
添加:
alias bond0 bonding
alias bond1 bonding
options bondingmode=1 miimon=100 max_bonds=2
查看bond是否加載成功、測試請參考RHEL4多bond配置操作
3、RHEL6多bond配置
系統版本:Red HatEnterprise Linux Server release 6.3 (Santiago)
網卡數量:4塊
添加兩個bond配置文件(以bond0爲例):
[root@localhost ~]# cd/etc/sysconfig/network-scripts/
[root@localhostnetwork-scripts]# cp ifcfg-eth0 ifcfg-bond0
[root@localhost network-scripts]# vim ifcfg-bond0
DEVICE="bond0"/bond1
BOOTPROTO="static"
ONBOOT="yes"
TYPE="Bond"
NM_CONTROLLED="no"
IPADDR="192.168.15.1"
NETMASK="255.255.0.0"
BONDING_MASTER="yes"
BONDING_OPTS="mode=1 miimon=100"
RHEL6默認支持如RHEL5、4那樣將bond寫入加載模塊的文件,但標準方法只需添加以上帶邊框的兩個參數在bond配置文件中,所以/etc/modprobe.conf需要手動創建。
修改網卡配置文件(以eth0爲例):
DEVICE="eth0"/ethX
BOOTPROTO="none"
HWADDR="52:54:00:9D:F5:4F"
ONBOOT="yes"
UUID="531f548f-c4e8-4cb1-a39b-86732a665a95"
MASTER=bond0
SLAVE="yes"
查看bond是否加載成功、測試請參考RHEL4多bond配置操作
拓展:
millmon=100,表示每100ms監測一次鏈路鏈接狀態。
Linux多網卡bond常用的有三種:
mode=0:平衡負載模式,有自動備援,但需要”Switch”支援及設定。
mode=1:自動備援模式,其中一條線若斷線,其他線路將會自動備援。
mode=6:平衡負載模式,有自動備援,不必”Switch”支援及設定。
從RHEL6.4開始高可用集羣支持模塊0、1和2。
mode=2:平衡策略模式,基於指定的傳輸HASH策略傳輸數據包。
將鏈路狀態監測配置爲arp請求監測:
當負載均衡發生主備切換時,主網卡向原來的主負載均衡發送arp請求,由於floating-ip已經漂移到新的主設備上,原來的主設備不會迴應服務器的arp請求,服務器arp請求超時後,主備網卡發生切換。服務器雙網卡綁定檢測方式更改如下:
RHEL4\5在/etc/modprobe.conf文件中添加
options bonding mode=1 arp_interval=60 arp_ip_target=IP
arp_interval=100 表示100毫秒發送一次arp請求
arp_ip_target=IP 表示主網卡發出arp請求IP
RHEL6中直接在網卡配置文件添加:
BONDING_MASTER=yes
BONDING_OPTS="mode=1arp_interval=100 arp_ip_target=IP"