当前位置:网站首页>HAProxy高可用解决方案
HAProxy高可用解决方案
2022-07-04 12:43:00 【51CTO】
中添加--line-numbers选项
衡量负载均衡器性能的因素
Session rate会话率:每分钟产生的会话数
Session concurrency 并发会话数: 服务器处理会话的时间越长,并发会话数越多;
Date rate 数据速率: 以MB/s、Mbps衡量
HaProxy简介
官方网站: https://www.haproxy.org/
HAProxy是个免费的负载均衡软件,可以运行于大部分主流的Linux操作系统上。
适用于负载特大的Web站点,这些站点通常又需要会话保持或者七层代理。
HAProxy的核心功能
- 负载均衡:L4和L7两种模式,支持RR/静态RR/LC/IP Hash/URI Hash/URL_PARAM Hash/HTTP_HEADER Hash等丰富的负载均衡算法
- 健康检查:支持TCP和HTTP两种健康检查模式
- 会话保持:对于未实现会话共享的应用集群,可通过Insert Cookie/Rewrite Cookie/Prefix Cookie,以及上述的多种Hash方式实现会话保持
- SSL:HAProxy可以解析HTTPS协议,并能够将请求解密为HTTP后向后端传输
- HTTP请求重写与重定向
- 监控与统计:HAProxy提供了基于Web的统计信息页面,展现健康状态和流量数据。基于此功能,使用者可以开发监控程序来监控HAProxy的状态
HAProxy工作模式
- http:客户端请求被深度分析后再发往服务器;
- tcp:4层调度,不检查七层信息;
- Health: 仅做健康检查(不建议使用);
HAProxy优缺点
优点
- 支持sessio、cookie功能;
- 可以通过Url进行健康检查;
- 效率、负载均衡速度高于Nginx而低于LVS;
- HAProxy支持TCP,可以对MySQL进行负载均衡;
- 调度算法丰富;
缺点
- 正则表达式弱于Nginx;
- 日志依赖于Syslogd;
HAProxy安装
1)安装haproxy
CentOS系统可以使用yum直接进行安装
查看HAProxy版本
2022年最新版本为2.6
2)修改配置文件
$
v
i
m
/
e
t
c
/
h
a
p
r
o
x
y
/
h
a
p
r
o
x
y
.
c
f
g
g
l
o
b
a
l
l
o
g
1
2
7
.
0
.
0
.
1
l
o
c
a
l
2
c
h
r
o
o
t
/
v
a
r
/
l
i
b
/
h
a
p
r
o
x
y
p
i
d
f
i
l
e
/
v
a
r
/
r
u
n
/
h
a
p
r
o
x
y
.
p
i
d
#
p
i
d
文
件
m
a
x
c
o
n
n
4
0
0
0
#
最
大
连
接
数
(
默
认
4
0
0
0
)
u
s
e
r
h
a
p
r
o
x
y
g
r
o
u
p
h
a
p
r
o
x
y
d
a
e
m
o
n
#
将
进
程
放
入
d
e
a
m
o
n
模
式
运
行
;
d
e
f
a
u
l
t
s
m
o
d
e
h
t
t
p
#
工
作
模
式
(
默
认
h
t
t
p
)
l
o
g
g
l
o
b
a
l
#
采
用
全
局
定
义
的
日
志
o
p
t
i
o
n
h
t
t
p
l
o
g
#
日
志
类
别
(
h
t
t
p
日
志
格
式
)
o
p
t
i
o
n
d
o
n
t
l
o
g
n
u
l
l
#
不
记
录
健
康
检
查
的
日
志
信
息
o
p
t
i
o
n
h
t
t
p
-
s
e
r
v
e
r
-
c
l
o
s
e
o
p
t
i
o
n
f
o
r
w
a
r
d
f
o
r
e
x
c
e
p
t
1
2
7
.
0
.
0
.
0
/
8
o
p
t
i
o
n
r
e
d
i
s
p
a
t
c
h
#
S
e
r
v
e
r
i
d
服
务
器
挂
掉
后
强
制
定
向
到
其
它
健
康
的
服
务
器
上
r
e
t
r
i
e
s
3
#
连
接
失
败
到
3
次
后
就
任
务
服
务
不
可
用
t
i
m
e
o
u
t
h
t
t
p
-
r
e
q
u
e
s
t
1
0
s
t
i
m
e
o
u
t
q
u
e
u
e
1
m
t
i
m
e
o
u
t
c
o
n
n
e
c
t
1
0
s
t
i
m
e
o
u
t
c
l
i
e
n
t
1
m
#
客
户
端
连
接
超
时
f
r
o
n
t
e
n
d
m
a
i
n
*:
5
0
0
0
#
监
听
的
端
口
d
e
f
a
u
l
t
_
b
a
c
k
e
n
d
a
p
p
#
将
请
求
转
发
到
名
为
“
a
p
p
”
的
后
端
服
务
b
a
c
k
e
n
d
s
t
a
t
i
c
#
定
义
后
端
服
务
b
a
l
a
n
c
e
r
o
u
n
d
r
o
b
i
n
s
e
r
v
e
r
s
t
a
t
i
c
1
2
7
.
0
.
0
.
1:
4
3
3
1
c
h
e
c
k
b
a
c
k
e
n
d
a
p
p
b
a
l
a
n
c
e
r
o
u
n
d
r
o
b
i
n
s
e
r
v
e
r
a
p
p
1
1
2
7
.
0
.
0
.
1:
5
0
0
1
c
h
e
c
k
l
i
s
t
e
n
s
t
a
t
u
s
b
i
n
d
*:
1
0
2
5
0
#
定
义
监
控
页
面
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
{配置文件构成}
global: 全局配置块,配置参数在全局生效;
default: 为后续的其它部分设置缺省参数,缺省参数可以被后续部分重置(即以后续配置部分为准);
frontend:定义前端服务;
backend:定义后端服务
3)服务启停
监控HAProxy状态
查看HAProxy服务端口,然后通过主机IP:端口在浏览器访问HAProxy的监控页面。
$ ss -ntulp | grep haproxy


备注
- Queue队列数据的信息(当前队列数量,最大值,队列限制数量);
- Session rate每秒会话率(当前值,最大值,限制数量);
- Sessions总会话量(当前值,最大值,总量,Lbtot: total number of times a server was selected选中一台服务器所用的总时间);
- Bytes(入站、出站流量);
- Denied(拒绝请求、拒绝回应);
- Errors(错误请求、错误连接、错误回应);
- Warnings(重新尝试警告retry、重新连接redispatches);
- Server(状态、最后检查的时间(多久前执行的最后一次检查)、权重、备份服务器数量、down机服务器数量、down机时长)。
边栏推荐
- Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
- Efficient! Build FTP working environment with virtual users
- 诸神黄昏时代的对比学习
- jsonp
- Annual comprehensive analysis of China's mobile reading market in 2022
- Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
- 6 分钟看完 BGP 协议。
- JVM系列——栈与堆、方法区day1-2
- Backgroundworker usage example
- Zhongang Mining: in order to ensure sufficient supply of fluorite, it is imperative to open source and save flow
猜你喜欢

MDK在头文件中使用预编译器时,#ifdef 无效的问题

众昂矿业:为保障萤石足量供应,开源节流势在必行

【AI系统前沿动态第40期】Hinton:我的深度学习生涯与研究心法;Google辟谣放弃TensorFlow;封神框架正式开源

How real-time cloud interaction helps the development of education industry

7 月数据库排行榜:MongoDB 和 Oracle 分数下降最多

C#/VB. Net to add text / image watermarks to PDF documents

比量子化学方法快六个数量级,一种基于绝热状态的绝热人工神经网络方法,可加速对偶氮苯衍生物及此类分子的模拟

Is the outdoor LED screen waterproof?

CVPR 2022 | transfusion: Lidar camera fusion for 3D target detection with transformer

JVM系列——栈与堆、方法区day1-2
随机推荐
Etcd storage, watch and expiration mechanism
爬虫练习题(一)
C#/VB.NET 给PDF文档添加文本/图像水印
Definition of cognition
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
使用 NSProxy 实现消息转发
Meituan Ali's Application Practice on multimodal recall
iptables基础及Samba配置举例
CA: efficient coordinate attention mechanism for mobile terminals | CVPR 2021
Efficient! Build FTP working environment with virtual users
再说rsync+inotify实现数据的实时备份
室外LED屏幕防水吗?
AI 绘画极简教程
从0到1建设智能灰度数据体系:以vivo游戏中心为例
[Android kotlin] lambda return statement and anonymous function
Is the main thread the same as the UI thread- Is main thread the same as UI thread?
游戏启动后提示安装HMS Core,点击取消,未再次提示安装HMS Core(初始化失败返回907135003)
After installing vscode, the program runs (an include error is detected, please update the includepath, which has been solved for this translation unit (waveform curve is disabled) and (the source fil
众昂矿业:为保障萤石足量供应,开源节流势在必行
Implementation mode and technical principle of MT4 cross platform merchandising system (API merchandising, EA merchandising, nj4x Merchandising)