SUSE-IPMP官方文档
首先,我们需要备份:/etc/init.d/network 文件
#cp /etc/init.d/network /etc/init.d/network_bak
再次:我们需要修改/etc/init.d/network,将start 选项的最后加上如下语句:
sleep 10s 使设备启动的时候,暂停执行下面的语句,使网卡的硬件设备能更顺利加载,如果不加入该句有可能在执行之后,网卡并不能真正的加载导致网络不通!
modprobe bonding miimon=100 mode=balance-rr #mode=balance-rr 为负载均衡,mode=active-backup miimon=100每100毫秒检测一次网络是否通畅,没有这参数IPMP是不会自动切换的!
为互备
ifconfig bond0 <ip_addr> netmask <net_mask> broadcast <broadcast> #填上你需要配置浮动IP的IP,子网掩码和广播
route add -host <gateway_ip_addr> dev bond0 #为bonding 的网卡添加
route add default gw <gateway_ip_addr> #添加默认路由
ifenslave bond0 eth2
ifenslave bond0 eth3 #为bonding 的网卡添加实际物理设备
最后:在stop 选项的最前面加上:
ifenslave -d bond0 eth2
ifenslave -d bond0 eth3 #从bonding 的网卡中删除实际物理设备
ifconfig bond0 down #停止bond0
然后重起网络
>/etc/init.d/network restart
就可以在HA 的服务配置中使用bond0 作为网络接口了。
样例如下:
sleep 10s
modprobe bonding miimon=100 mode=active-backup
ifconfig bond0 172.17.192.62 netmask 255.255.255.0 broadcast 172.17.192.255
route add -host 172.17.192.1 dev bond0
ifenslave bond0 eth0
ifenslave bond0 eth1
;;
stop)
ifenslave -d bond0 eth0
ifenslave -d bond0 eth1
ifconfig bond0 dow