1. 创建bond0文件:

#vim /etc/sysconfig/network/ifcfg-bond0
BOOTPROTO='static'
BROADCAST=''
IPADDR='192.168.74.141/24'
NETMASK='255.255.255.0'
NETWORK=''
STARTMODE='auto'
BONDING_MASTER='yes'
BONDING_SLAVE0='eth0'
BONDING_SLAVE1='eth1'
BONDING_MODULE_OPTS='mode=1 miimon=100 fail_over_mac=1'
ETHTOOL_OPTIONS=''
MTU=''
NAME=''
REMOTE_IPADDR=''
USERCONTROL='no'

解析说明:
mode 0表示为负载均衡模式,两块网卡都工作(需要交换机端口聚合,在SLES 12SP3上用此模式测试未通过)
mode 1表示冗余模式,一块是工作,一块冗余
miimon表示系统检查间隔时间,单位是ms,
fail_over_mac=1 在Vmware里测试时使用,否则Ping会断开

例如:每100ms检查一次,当发现一条线路不通,就转入另一条

2. 修改网卡配置:

#vim /etc/sysconfig/network/ifcfg-eth0
BOOTPROTO='none'             #配置bond时必需将static,dhcp改为none
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR=''                    #配置bond时必需将IP置空
MTU=''
NAME='82545EM Gigabit Ethernet Controller (Copper)'
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='off'              #配置bond时必需将auto改为off
USERCONTROL='no'
 
#vim /etc/sysconfig/network/ifcfg-eth1
BOOTPROTO='none'             #配置bond时必需将static,dhcp改为none
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR=''                    #配置bond时必需将IP置空
MTU=''
NAME='82545EM Gigabit Ethernet Controller (Copper)'
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='off'              #配置bond时必需将auto改为off
USERCONTROL='no'

3. 重启网络服务,或是重启主机操作系统

#service network restart
#shutdown -r 0

4. 查看状态及测试

#ifconfig                    #可以看到bond0已经起来了
#cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

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: 3
Permanent HW addr: 00:0c:29:5f:57:a4
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 3
Permanent HW addr: 00:0c:29:5f:57:ae
Slave queue ID: 0
#ifconfig eth0 down
#ifconfig eth0 up
#ifconfig eth1 down
#ifconfig eth1 up

 

posted on 2017-10-13 13:04  zlg88  阅读(3508)  评论(0编辑  收藏  举报