温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

在国产处理器服务器上做HAProxy负载均衡

发布时间:2020-08-05 02:19:59 来源:ITPUB博客 阅读:209 作者:wxh585 栏目:建站服务器

环境

硬件平台:国产 arm64 3399cpu海之舟服务器

操作系统:海之舟服务器操作系统1.0A

在国产处理器服务器上做HAProxy负载均衡

用户访问192.168.125地址时,haproxy分配至二台服务器,192.168.1.7,192.168.1.8。实现负载分担。

root@bigdataA:/home/zs# apt-get install haproxy   //安装软件

root@bigdataA:/home/zs# nano /etc/haproxy/haproxy.cfg

#---------------------------------------------------------------------

#main frontend which proxys to the backends

#---------------------------------------------------------------------

frontend main

bind *:80   //侦测端口80

default_backend webserver

#---------------------------------------------------------------------

#static backend for serving up images, stylesheets and such

#---------------------------------------------------------------------

backend webserver

balance roundrobin    //轮询方式

server web1 192.168.1.7:80 check    //默认每2000ms检查一次服务器,192.168.1.7是否正常.

server web2 192.168.1.8:80 check

root@bigdataA:/home/zs# /etc/init.d/haproxy stop    //重启服务器,使配置生效

[ ok ] Stopping haproxy (via systemctl): haproxy.service.

root@bigdataA:/home/zs# /etc/init.d/haproxy start

[ ok ] Starting haproxy (via systemctl): haproxy.service.

root@bigdataA:/home/zs# netstat -an  |more    //查看端口是否启用

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address           Foreign Address         State

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      //显示80端口启用

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN

tcp        0     64 192.168.1.125:22        192.168.1.6:1524        ESTABLISHED

tcp6       0      0 :::8080                 :::*                    LISTEN

tcp6       0      0 :::22                   :::*                    LISTEN

tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN

tcp6       0      0 :::8009                 :::*                    LISTEN

Active UNIX domain sockets (servers and established)

root@bigdataA:/home/zs#

在客户端浏览器中输入地址http://192.168.1.125,即可访问到轮询的网页.

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI