Haproxy实现普通负载均衡的配置

打开haproxy配置文件

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

59行及以下的都删除

添加59行如下:

 59     stats    uri            /admin
添加如下行

 61 listen mylbweb 192.168.4.20:80
 62        cookie  SERVERID  rewrite 
 63        balance  roundrobin
 64        server   web30 192.168.4.30:80 cookie app30 check inter 2000 rise 2 fall 5
 65        server   web40 192.168.4.40:80 cookie app40 check inter 2000 rise 2 fall 5
 66        server   web50 192.168.4.50:80 cookie app50 check inter 2000 rise 2 fall 5
 67        server   web60 192.168.4.60:80 cookie app60 check inter 2000 rise 2 fall 5
inter 2000 表示多长时间检查一次

rise 2 重试次数是几次

fall 5 最大失败次数

重启haproxy服务

[root@haproxy20 ~]# systemctl restart haproxy

最后使用测试主机测试分发调配情况。

猜你喜欢

转载自blog.csdn.net/weixin_42182501/article/details/85215179
今日推荐