负载均衡:HAProxy

**1.**安装:

root @haproxy \~ \] # yum -y install ntpdate.x86_64 \[root @haproxy \~ \] # yum -y install ntp \[root @haproxy \~ \] # ntpdate cn.ntp.org.cn 13 Aug 19 : 39 : 27 ntpdate\[ 1955 \] : adjust time server 120.197.116.202 offset 0.059032 sec \[root @haproxy \~ \] # systemctl start ntpd \[root @haproxy \~ \] # systemctl enable ntpd \[root @haproxy \~ \] # yum -y install haproxy18.x86_64 ## **2.****配置** : \[root@haproxy \~\]# vim /etc/haproxy18/haproxy.cfg 63 frontend main \*: 80 64 acl url_static path_beg - i / static / images / javascript / stylesheets 65 acl url_static path_end - i .jpg .gif .png .css .js 66 67 # use_backend static if url_static 68 default_backend web ...... 77 #---------------------------------------------------- ----------------- **3.** **重启,设置开机启动** 78 # round robin balancing between the various backends 79 #----------------------------------------------------- ---------------- 80 backend web 81 balance roundrobin 82 server web01 10.1.1.200 : 80 check 83 server web02 10.1.1.201 : 80 check 84 ## **3.****重启,设置开机启动:** \[root @haproxy \~ \] # systemctl restart haproxy \[root @haproxy \~ \] # systemctl enable haproxy ## **4.测试:** ![](https://i-blog.csdnimg.cn/direct/663dddc65c084b28a0d7d7fb35c5ec3a.png) ## **5.添加统计页面:** 在配置文件vim /etc/haproxy18/haproxy.cfg 中添加: **# 定义web管理界面** **listen statistics bind \*:9090 #定义监听端口 mode http #默认使用协议 stats enable #启用stats stats uri /hadmin?stats #自定义统计页面的url stats auth admin:admin #统计页面的账号密码 stats hide-version #隐藏在统计页面上的haproxy版本信息 stats refresh 30s #统计页面自动刷新时间 stats admin if TRUE #如果认证通过就做管理功能,可以管理\>后端服务器 stats realm hapadmin #统计页面密码框上提示文件,默认haproxy\\statistics** ![](https://i-blog.csdnimg.cn/direct/287d92df377944bf9581727015e0ea0d.png)

相关推荐
the_fat_bird2 分钟前
ubuntu install nvidia gpu driver
linux·运维·ubuntu
江南风月9 分钟前
WGCLOUD如果使用SQL Server数据库推荐哪个版本
运维·网络·zabbix·运维开发·prometheus
IMPYLH20 分钟前
Linux 的 tac 命令
linux·运维·服务器·bash
计算机安禾24 分钟前
【Linux从入门到精通】第50篇:专栏总结与Linux学习之路的未来展望
linux·运维·学习
yyuuuzz26 分钟前
企业出海技术落地的几个常见问题
运维
byoass37 分钟前
企业云盘高可用架构:主备切换、负载均衡与健康检查实战
运维·网络·安全·架构·云计算·负载均衡
白菜欣1 小时前
Linux —进程概念
linux·运维·服务器
iuu_star1 小时前
Vue+FastAPI 项目宝塔Linux部署指南
linux·运维·fastapi
杜哥无敌1 小时前
FreeSSHd vs FileZilla Server vs SFTPGo:Windows SFTP服务器易用性终极横向测评
运维·服务器·windows
楼田莉子1 小时前
仿Muduo的高并发服务器:Channel模块与Poller模块
linux·服务器·c++·学习·设计模式