haproxy負載均衡

haproxy安裝


一臺haproxy服務器  192.168.80.183

兩臺Web服務器  192.168.80.182   192.168.80.181


兩臺Web服務器部署:

        關閉防火牆及selinux

        yum install -y httpd

        vi /etc/httpd/conf/httpd.conf

        把ServerName 前面的註釋符號去掉

        image.pngimage.png

啓動httpd服務

            systemctl start httpd 


 瀏覽器測試:

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負載均衡完成。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章