Linux的企业-高可用集群Lvs+keepalived+ftp

  1. 云栖社区>
  2. 博客>
  3. 正文

Linux的企业-高可用集群Lvs+keepalived+ftp

技术小胖子 2017-11-15 14:32:00 浏览1602
展开阅读全文

wKioL1nQp7_jclTdAAD76ocHjkk278.png

wKiom1nQqAWzJ4U9AAAiZ5q3hxQ233.png


一.配置环境

客户机: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

wKiom1nDs9iSKGt9AABIIHuf4Lo148.png

 源码的安装一般由3个步骤组成:配置(configure)、编译(make)、安装(make install)。

Configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./configure –help输出详细的选项列表。

其中--prefix选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr /local/share。


1.安装keepalived包

wKioL1nDLkfj6op_AACIFhSBqtw466.png

wKioL1nDM5CjvHbqAAAhBcYD9F4502.png

出错,安装包依赖,需要加上-devel为开发包

wKiom1nDLsPz_FtkAACOnppHGko839.png


编译

wKiom1nDLsSzYCVdAAA3dE3cHlM137.png


安装

wKioL1nDLo-wsijPAAAWLfBrm1s652.png


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加可执行权限

wKiom1nDLsWRRQBJAACoyQ2uYig417.png


wKiom1nDMneQbj8OAADQe8QOxTY594.png


wKioL1nDLpHTrPXxAADwFZXBC5o328.png



3.配置server4上的keepalived

wKioL1nDMkHj3oNcAAATyW8I2ZU824.pngwKiom1nDLseTrFOkAAEc5T3IvKE225.png

wKiom1nDLsezFZaeAAAbRDEufE8048.png



二.配置服务文件

1.在server1上配置vim /etc/keepalived/keepalived.conf,设置为主,优先级为100,配置完后给server4 , vrrp_strict打开会自动在iptables上显示策略,造成vip被防火墙drop

wKioL1nDM4PyiZUdAAA8Xz_dEUs969.png

wKioL1nDM4Oy6MZXAAC0z4Ug2E0442.png

wKiom1nDM7nAd11fAACHDnWhwBo353.png


2.在server2添加VIP,启动屏蔽mac地址arptables_jf插件

wKioL1nDM4SgiMxJAAAgUnI9jF4512.png

wKiom1nDM7rjg0PKAAB2NI4kgIY265.png

wKiom1nDM7rzhK-jAAE6_7tgL1g370.png


3.在server3添加VIP,启动屏蔽mac地址arptables_jf插件

wKioL1nDM4bQr9ikAAB4VvloF4E346.png

wKiom1nDM7yAE5dXAAEc0NwhDdw335.png



4.在server4上配置vim /etc/keepalived/keepalived.conf,设置为副,优先级为50

wKioL1nDM4fCaBxYAAC0IvZBamA761.png

wKioL1nDM4jx-JsZAACFkfsx9DY902.png


5.开启server4上的keepalived

wKiom1nDM73BtLxQAAAmiBCuGVY052.png

wKioL1nDM4jx-fLIAABajlinC5A804.png

wKiom1nDM77BhgBzAABZ5CP9LpQ270.png


6.客户机测试正常,实现轮询

wKioL1nDM4vChvjKAADA5UaY_Nc257.png

wKioL1nDM4mg7wJsAACE0PQdH4Y681.png

wKiom1nDM8Cz5ekwAACVKCfUwfA462.png


关闭server1,VIP到server4访问

wKiom1nDM7_D_gGoAAED-CQagtk161.png



三.Lvs+keepalived+ftp


1.在server1上配置vim /etc/keepalived/keepalived.conf,在配置文件后面加上下面的ftp的配置内容


#persistence_timeout 50  连接后端服务器,50S内不会负载均衡

wKiom1nDM8Gg7oV2AACBIq5ebs0417.png



2.server2安装vsftpd服务

wKiom1nDM8KSwBdmAACc2UPF1XI077.png



3.server3安装vsftpd服务

wKioL1nDM43w5vPrAABgg7DAyMY203.png


4.启动keepalived服务,server1上的Directory上服务启动

wKioL1nDM4yTaNvIAACv_pCZ6Go551.png


4.在server4上配置vim /etc/keepalived/keepalived.conf,在配置文件后面加上下面的ftp的配置内容

wKiom1nDM8Oj8PeWAACIhOci1Dg718.png


5.启动keepalived服务,server4上的Directory上服务启动

wKioL1nDM4-yT7MMAACxu9AKqGM843.png


6.在客户机测试

wKiom1nDM8SixQ1CAABAEMx_rEs309.png


关闭server3,服务在server2上

wKioL1nDM5DhIrkgAAAbAmvHFGE359.png

wKiom1nDM8XDEmLpAAA4Q0hDdCs118.png



      本文转自一百个小排 51CTO博客,原文链接:http://blog.51cto.com/anfishr/1967392,如需转载请自行联系原作者






网友评论

登录后评论
0/500
评论
技术小胖子
+ 关注