0.首先关闭NetworkManager ,因为它会与network冲突。
/etc/init.d/NetworkManager stop chkconfig NetworkManager off
1.编辑/etc/sysconfig/network-scripts/ ifcfg-bond0、ifcfg-eth0、ifcfg-eth1
[[email protected] network-scripts]# vim ifcfg-bond0 DEVICE=bond0 BOOTPROTO=static IPADDR=10.0.0.211 NETMASK=255.255.255.0 GATEWAY=10.0.0.253 ONBOOT=yes USERCTL=no [[email protected] network-scripts]# vim ifcfg-eth0 DEVICE=eth0 ONBOOT=yes BOOTPROTO=none MASTER=bond0 SLAVE=yes USERCTL=no [[email protected] network-scripts]# vim ifcfg-eth1 DEVICE=eth1 ONBOOT=yes BOOTPROTO=none MASTER=bond0 SLAVE=yes USERCTL=no
第二步,修改modprobe相关设定文件,并加载bonding模块:
创建一个加载bonding的专属设定文件/etc/modprobe.d/bonding.conf
[[email protected] ~]# vi /etc/modprobe.d/bonding.conf #追加 alias bond0 bonding options bonding mode=6 miimon=200
2.加载模块(重启系统后就不用手动再加载了)
[[email protected] ~]# modprobe bonding
3.确认模块是否加载成功:
[[email protected] ~]# lsmod | grep bonding bonding 100065 0
第三步,重启一下网络,然后确认一下状况:
[[email protected] ~]# /etc/init.d/network restart [[email protected] ~]# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.5.0 (November 4, 2008) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: eth0 MII Status: up MII Polling Interval (ms): 200 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth0 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:16:36:1b:bb:74 Slave Interface: eth1 MII Status: up Link Failure Count: 0 Permanent HW addr: 00:16:36:1b:bb:80 [[email protected] ~]# ifconfig | grep HWaddr bond0 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74 eth0 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74 eth1 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74
从上面的确认信息中,我们可以看到3个重要信息:
1.现在的bonding模式是active-backup
2.现在Active状态的网口是eth0
3.bond0,eth1的物理地址和处于active状态下的eth0的物理地址相同,这样是为了避免上位交换机发生混乱。
任意拔掉一根网线,然后再访问你的服务器,看网络是否还是通的。
由于存储的操作系统会与系统自带的新的NetworkManager冲突,需将其设置为关闭状态。
/etc/init.d/NetworkManger stop chkconfig NetworkManager stop
时间: 2024-10-06 15:40:18