负载均衡: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)

相关推荐
Maple_land8 分钟前
Linux进程第八讲——进程状态全景解析(二):从阻塞到消亡的完整生命周期
linux·运维·服务器·c++·centos
爱吃生蚝的于勒13 分钟前
【Linux】零基础学会Linux之权限
linux·运维·服务器·数据结构·git·算法·github
量子物理学15 分钟前
Eclipse Mosquitto 在小内存下怎么修改配置文件
java·服务器·eclipse
Cyan_RA932 分钟前
Linux 远程Ubuntu服务器本地部署大模型 EmoLLM 中常见的问题及解决方案 万字详解
linux·运维·服务器·ubuntu·大模型·远程部署·emollm
数字冰雹34 分钟前
图观 流渲染打包服务器
服务器·前端·github·数据可视化
minji...44 分钟前
Linux相关工具vim/gcc/g++/gdb/cgdb的使用详解
linux·运维·服务器·c++·git·自动化·vim
web安全工具库1 小时前
Linux 高手进阶:Vim 核心模式与分屏操作详解
linux·运维·服务器·前端·数据库
不会调制解调的猫1 小时前
笔记 | 内网服务器通过wifi穿透,设置流量走向
运维·服务器·笔记
深蓝电商API1 小时前
将爬虫部署到服务器:Scrapy+Scrapyd 实现定时任务与监控
服务器·爬虫·scrapy
熊思宇1 小时前
ASP.NET Core Web API 发布到 IIS 服务器
服务器·microsoft·asp.net