HAProxy服务器

HTTP协议响应的状态码:

200OK

301:重定向

404notfound

403forbidden

501InternalError



HAProxy

1、它的工作原理是Proxy代理。客户端把请求发送到HAProxy后,HAProxy替用户发送请求到web服务器,web服务器响应HAProxy,把页面发给HAProxyHAProxy再把页面发给客户端。

2、拓扑与LVSDR完全一样。因为LVSDR配置和HAProxy没有影响,也就不需要清理了。

3node4作为调度器

[root@node4~]# yum install -y haproxy

  1. 修改配置文件

[root@node4~]# vim /etc/haproxy/haproxy.cfg

mainfrontend which proxys to the backends后面的配置全部删除

listenstats

bind0.0.0.0:1080 # 监控页面的端口号

statsrefresh 30s # 页面自动刷新时间是30

statsuri /monitor # 页面网址

statsrealm HaManager

statsauth admin:admin # 用户名:密码


listenmyweb 0.0.0.0:80

cookieSERVERID rewrite

balanceroundrobin # 调度算是rr

serverweb1 192.168.4.2:80 cookie a1i1 check inter 2000 rise 2 fall 5 #2000ms检查一次服务器,2次成功是好的,5次失败表示故障

serverweb2 192.168.4.3:80 cookie a1i2 check inter 2000 rise 2 fall 5

5、启动服务

[root@node4~]# systemctl start haproxy



[root@vh02 ~]#

 11  ss -tulnp | grep httpd
   12  cat /var/www/html/index.html 
   13  systemctl stop httpd
   14  systemctl start httpd
   15  systemctl stop httpd

   16  systemctl start httpd

[root@vh03 ~]#

   11  ss -tulnp | grep httpd

   12  cat /var/www/html/index.html 

测试:

http://192.168.4.4/index.html

http://192.168.4.4:1080/monitor



# ab -n 1000 -c10 http://192.168.4.4/

排错:

[root@vh04 ~]# journalctl -xe

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乐于技术分享

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值