haproxy高可用实现 和 动静资源的调度分离
一、项目需求:(1) 动静分离部署wordpress,动静都要能实现负载均衡,要注意会话的问题;
(2) 配置memcached服务做为应用程序服务器的session server;
(3) 给出设计拓扑,写成博客;
(4) haproxy的设计要求:
(a) stats page,要求仅能通过本地访问使用管理接口;
(b) 动静分离;
(c) 分别考虑不同的服务器组的调度算法;
(5) haproxy高可用;
1) haproxy的高可用,用KeepAlived实现;
在A主机和D主机实现;
A为MASTER进程;
http://s1.运维网.com/images/20180704/1530719533415496.png
D为BACKUP进程;
http://s1.运维网.com/images/20180704/1530719546227849.png
A的keepalived的配置文件内容;
http://s1.运维网.com/images/20180704/1530719557279816.png
http://s1.运维网.com/images/20180704/1530719563407942.png
D的keepalived的配置文件内容;
http://s1.运维网.com/images/20180704/1530719575466928.png
http://s1.运维网.com/images/20180704/1530719580142956.png
2) haproxy的配置内容;
A和D一样;
http://s1.运维网.com/images/20180704/1530719597507812.png
3) 启动haproxy,启动keepalived;
4) 主机B为动态解析主机,需要安装php-fpm,和php-memcached的接口;
http主配置文件内容需要添加的内容;
http://s1.运维网.com/images/20180704/1530719617610517.png
Php-fpm主配置内容需要更改的部分;注意,需要安装php和memcached接口
名字:php-pecl-memcached.x86_64
http://s1.运维网.com/images/20180704/1530719630674508.png
5) 在memcached服务器上直接开启memcached服务即可;
http://s1.运维网.com/images/20180704/1530719644378689.png
6) 开启浏览器,进行验证;
动态主机B:
http://s1.运维网.com/images/20180704/1530719659696243.png
虚拟ip动态解析:
http://s1.运维网.com/images/20180704/1530719671903194.png
结果:一致
静态资源解析主机;
C主机
http://s1.运维网.com/images/20180704/1530719684551259.png
虚拟ip主机:
http://s1.运维网.com/images/20180704/1530719696718941.png
结果:一致;
通过stats查看haproxy的状态;
http://s1.运维网.com/images/20180704/1530719709924290.png
页:
[1]