haproxy负载均衡

haproxy安装html


一台haproxy服务器  192.168.80.183linux

两台Web服务器  192.168.80.182   192.168.80.181web


两台Web服务器部署:浏览器

        关闭防火墙及selinux服务器

        yum install -y httpd负载均衡

        vi /etc/httpd/conf/httpd.confide

        把ServerName 前面的注释符号去掉测试

        image.pngimage.png

启动httpd服务spa

            systemctl start httpd 3d


 浏览器测试:

image.png

image.png

到此 web服务器部署完成


haproxy服务器:

vi /etc/haproxy/haproxy.cfg到配置文件修改内容

最下面添加web设置

listen webcluster
        bind 0.0.0.0:80
        mode http
        option httpchk GET /index.html
        log global
        maxconn 3000
        balance roundrobin
server web01 192.168.80.181:80 check inter 2000 fall 5
server web02 192.168.80.182:80 check inter 2000 fall 5

重启haproxy服务 查看端口

        service haproxy restart


image.png


在浏览器测试 192.168.80.183:8089/stats

image.png


查看轮询:

image.png

点击浏览器的刷新或者F5刷新

image.png


到此haproxy负载均衡完成。