一.配置环境
客户机:172.25.29.250
lvs服务器:172.25.29.1 keepalived ipvsadm
服务器:172.25.29.4 keepalived
RS:www.westos.org-server2:172.25.29.2 ftp
RS:www.westos.org-server3:172.25.29.3 ftp
源码的安装一般由3个步骤组成:配置(configure)、编译(make)、安装(make install)。
Configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./configure –help输出详细的选项列表。
其中--prefix选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr /local/share。
1.安装keepalived包
出错,安装包依赖,需要加上-devel为开发包
编译
安装
2.配置server1上的keepalived
做软链接,server1与server4一致
ln -s /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
ln -s /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
ln -s /usr/local/keepalived/etc/keepalived /etc/
ln -s /usr/local/keepalived/sbin/keepalived /usr/sbin
/etc/init.d/下的脚本keepalived加可执行权限
3.配置server4上的keepalived
二.配置服务文件
1.在server1上配置vim /etc/keepalived/keepalived.conf,设置为主,优先级为100,配置完后给server4 , vrrp_strict打开会自动在iptables上显示策略,造成vip被防火墙drop
2.在server2添加VIP,启动屏蔽mac地址arptables_jf插件
3.在server3添加VIP,启动屏蔽mac地址arptables_jf插件
4.在server4上配置vim /etc/keepalived/keepalived.conf,设置为副,优先级为50
5.开启server4上的keepalived
6.客户机测试正常,实现轮询
关闭server1,VIP到server4访问
三.Lvs+keepalived+ftp
1.在server1上配置vim /etc/keepalived/keepalived.conf,在配置文件后面加上下面的ftp的配置内容
#persistence_timeout 50 连接后端服务器,50S内不会负载均衡
2.server2安装vsftpd服务
3.server3安装vsftpd服务
4.启动keepalived服务,server1上的Directory上服务启动
4.在server4上配置vim /etc/keepalived/keepalived.conf,在配置文件后面加上下面的ftp的配置内容
5.启动keepalived服务,server4上的Directory上服务启动
6.在客户机测试
关闭server3,服务在server2上
本文转自一百个小排 51CTO博客,原文链接:http://blog.51cto.com/anfishr/1967392,如需转载请自行联系原作者