您的位置:首页 > Web前端

银河麒麟操作系统上配置Bond(二)使用ifenslave方式

2017-08-02 11:49 579 查看
银河麒麟操作系统上使用ifenslave配置Bond

ifenslave是一款Linux下的负载均衡工具,银河麒麟操作系统也支持该工具。

一、安装ifenslave
$ sudo apt-get install ifenslave
二、配置bonding
在/etc/modules 文件末添加一行内容:bonding,设置 bonding 模块开机自动加载;
$ sudo vim /etc/modules
修改后的modules文件如下:
# /etc/modules: kernel modules toload at boot time.
#
# This file contains the names ofkernel modules that should be loaded
# at boot time, one per line. Linesbeginning with "#" are ignored.
bonding
2. 执行ifconfig -a查看系统所有网口,选择两个接口做bonding,比如enp1s0f1、enp1s0f2
3. 创建/etc/modprobe.d/bonding.conf文件,内容如下:
options bonding mode=1 miimon=100
其中mode=1,表示是 (active-backup)Active-backup policy:(主-备份策略):只有一个设备处于活动状态。一个宕掉另一个马上由备份转换为主设备。mac地址是外部可见的。此模式提供了容错能力。 miimon是毫秒数,每100毫秒触发检测线路稳定性的事件。 4. 加载bonding模块。执行
$ sudo modprobebonding查看模块是否加载成功:$ lsmod| grepbonding 5. 配置链路聚合名为bond0,聚合后使用的IP地址为192.168.100.155和16位掩码:
$ sudo ifconfigbond0 192.168.100.155 netmask 255.255.0. 6. 配置bond0使用的网络接口
$ sudo ifenslavebond0 enp1s0f1 enp1s0f2 7. 为了 bond0 开机重启后可以继续使用,写入配置文件
$ sudo vim/etc/network/interfaces添加bond0相应的配置,autobond0及以后为新添加的内容,修改完成后的文件内容为:# interfaces(5)file used by ifup(8) and ifdown(8)auto loiface lo inetloopback auto bond0iface bond0 inetstaticaddress192.168.100.155netmask255.255.0.0gateway192.168.1.254dns-nameservers192.168.0.53post-upifenslave bond0 enp1s0f1 enp1s0f2pre-downifenslave -d bond0 enp1s0f1 enp1s0f2配置完成后,重启服务器。 8. 重新启动reboot服务器后,测试拔出任何一个接口的网线,ping其他网络不会中断。

--------------------------

银河麒麟操作系统是天津麒麟信息技术有限公司自主研发的类Linux操作系统,目前有桌面版和服务器版以及一些特种行业的定制版本。银河麒麟社区版可在http://www.ubuntukylin.com/downloads/自由下载使用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  bond Kylin