haproxy代理数据库
安装部署
cp haproxy-systemd-wrapper /usr/sbin/
cp haproxy /usr/sbin
chmod x /usr/sbin/haproxy
chmod x /usr/sbin/haproxy-systemd-wrapper
mkdir -p /etc/haproxy
vi /etc/haproxy/haproxy.cfg
useradd haproxy
chown -R haproxy:haproxy /etc/haproxy
mkdir /var/lib/haproxy
chown -R haproxy:haproxy /var/lib/haproxy
vi /etc/sysconfig/haproxy
# Add extra options to the haproxy daemon here. This can be useful for
# specifying multiple configuration files with multiple -f options.
# See haproxy(1) for a complete list of options.
OPTIONS=""
vi /usr/lib/systemd/system/haproxy.service
[Unit]
Description=HAProxy Load Balancer
After=syslog.target network.target
[Service]
EnvironmentFile=/etc/sysconfig/haproxy
ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid $OPTIONS
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl restart haproxy
安装步骤
配置文件说明
#---------------------------------------------------------------------
# 全局设定部分
#---------------------------------------------------------------------
global
defaults
log global
mode tcp
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
#---------------------------------------------------------------------
# HAPROXY状态页面
#---------------------------------------------------------------------
listen admin_stats
stats enable
# 监听端口
bind *:12345
mode http
option httplog
log global
maxconn 10
# 刷新间隔
stats refresh 30s
# 页面路径
stats uri /
stats realm haproxy
# 访问认证
stats auth admin:password
stats hide-version
#---------------------------------------------------------------------
# TCP转发及负载均衡及简单TCP可用性校验
# weight权重;check inter检测频率;rise 1一次可用恢复;fall 2两次失败降级
#---------------------------------------------------------------------
frontend tidb-in
bind *:10000
maxconn 80000
default_backend tidb
backend tidb
#使用HTTP对URI路径可用性进行检测
#option httpchk
#http-check send meth GET uri /check.html
#http-check expect status 200
server tidb-1 10.30.92.70:4000 maxconn 40480 weight 10 check inter 10s rise 1 fall 2
server tidb-2 10.30.92.71:4000 maxconn 40480 weight 10 check inter 10s rise 1 fall 2
server tidb-3 10.30.92.73:4000 maxconn 44440 weight 10 check inter 10s rise 1 fall 2
haproxy.cfg
负载均衡配置
haproxy可以不需要虚拟vip,可以在多台主机上同时部署haproxy并且进行同样的配置,这样客户端无论连接哪台haproxy主机都能把请求转发到后台的服务主机上进行处理
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhibhgif
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
微信运动停用后别人还能看到步数吗
PHP中文网 07-22 -
excel打印预览压线压字怎么办
PHP中文网 06-22