HTTP协议响应的状态码:

200OK

301:重定向

404notfound

403forbidden

501InternalError



HAProxy

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

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

3node4作为调度器

[[email protected]~]# yum install -y haproxy

  1. 修改配置文件

[[email protected]~]# 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、启动服务

[[email protected]~]# systemctl start haproxy



[[email protected] ~]#

 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

[[email protected] ~]#

   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


HAProxy服务器

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

排错:

[[email protected] ~]# journalctl -xe

相关文章:

  • 2021-06-09
  • 2021-12-19
  • 2021-07-03
  • 2022-03-01
  • 2021-09-02
  • 2022-01-06
  • 2021-12-24
  • 2021-07-19
猜你喜欢
  • 2021-04-18
  • 2022-12-23
  • 2021-11-05
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
相关资源
相似解决方案