centos 6.X 聚合鏈路
0、查看NetworkManager服務,停止NetworkManager服務。不做這一步很可能出問題
service NetworkManager status
service NetworkManager stop
1、修改三類文件
/etc/sysconfig/network-scripts/下的ifcfg-*文件
/etc/modprobe.conf 文件 redhat 6.8 : /etc/modprobe.d/bond0.conf
/etc/init.d/rc.local 文件
2、編輯虛擬網口配置文件 ,記住此文件復制的時候要把MAC地址去掉,去掉UUID
vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.111
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
3、編輯各網卡的配置文件
vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=none
TYPE=Ethernet
DEVICE=em1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
vi /etc/sysconfig/network-scripts/ifcfg-eth1
BOOTPROTO=none
TYPE=Ethernet
DEVICE=em2
ONBOOT=yes
MASTER=bond0
SLAVE=yes
4、修改/etc/modprobe.conf centos 6.5 是/etc/modprobe.d/bonding.conf redhat6.8 是/etc/modprobe.d/bond0.conf
最后兩行加入
alias bond0 bonding
options bond0 miimon=100 mode=6
// 如果有多個bond配置文件,可按如下方式添加
alias bond1 bonding
options bond1 miimon=100 mode=6
注:
(1)、miimon 是鏈路監測的時間間隔單位是毫秒,miimon=100的意思就是,每100毫秒檢測網卡和交換機之 間是否連通,如不通則使用另外的鏈路。
(2)、mode=0 表示負載均衡方式,兩塊網卡都工作,需要交換機作支持
mode=1 表示冗余方式,網卡只有一個工作,一個出問題啟用另外的
mode=6 表示負載均衡方式,兩塊網卡都工作,不需要交換機作支持
5、修改/etc/rc.d/rc.local,加入以下內容 ,配置了modprobe.conf 可能不再需要配置rc.local
modprobe bonding miimon=100 mode=0 // 也有加入 ifenslave bond0 eth0 eth1 這種形式
6、service network restart // 查看虛擬接口是否起來
reboot // 查看是否開機啟動