Haproxy配置文件(haproxy.cfg)

Posted bazingafraser

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Haproxy配置文件(haproxy.cfg)相关的知识,希望对你有一定的参考价值。

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

# Example configuration for a possible web application. See the

# full configuration options online.

#

# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt

#

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

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

# Global settings

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

global

log 127.0.0.1 local0 info

log 127.0.0.1 local1 notice

chroot /var/lib/haproxy

stats socket /run/haproxy/admin.sock mode 660 level admin

user haproxy

group haproxy

maxconn 65535

tune.maxaccept 65535

tune.ssl.default-dh-param 2048

daemon

defaults

option dontlognull #不记录监控检查日志信息

retries 3 #三次失败认为服务器不可用,也可通过后边设置

log global

option redispatch #当serverId对应的服务器挂掉后,强制定向到其他健康的服务器,以后将不支持

maxconn 65535 #默认最大的链接数

timeout client 50s #客户端超时

timeout server 50s #服务器超时

timeout connect 5s #连接超时

#Create mysql_proxy 迁移1组

listen mysql1

bind 0.0.0.0:33061

mode tcp

balance roundrobin

server mysql1 10.19.159.86:3306

listen mysql2

bind 0.0.0.0:33062

mode tcp

balance roundrobin

server mysql2 10.19.84.98:3306

listen mysql3

bind 0.0.0.0:33063

mode tcp

balance roundrobin

server mysql3 10.19.176.184:3306

listen mysql4

bind 0.0.0.0:33064

mode tcp

balance roundrobin

server mysql4 10.19.83.32:3306

listen mysql5

bind 0.0.0.0:33065

mode tcp

balance roundrobin

server mysql5 10.19.43.79:3306

listen mysql6

bind 0.0.0.0:33066

mode tcp

balance roundrobin

server mysql6 10.6.11.135:3306

listen mysql7

bind 0.0.0.0:33067

mode tcp

balance roundrobin

server mysql7 10.19.6.12:3306

listen mysql8

bind 0.0.0.0:33068

mode tcp

balance roundrobin

server mysql8 10.19.126.225:3306

listen mysql9

bind 0.0.0.0:33069

mode tcp

balance roundrobin

server mysql9 10.19.139.84:3306

listen mysql10

bind 0.0.0.0:3310

mode tcp

balance roundrobin

server mysql10 10.19.115.92:3306

listen mysql11

bind 0.0.0.0:3320

mode tcp

balance roundrobin

server mysql11 10.19.47.142:3306

listen mysql12

bind 0.0.0.0:3330

mode tcp

balance roundrobin

server mysql12 106.2.11.252:3306

listen mysql13

bind 0.0.0.0:3331

mode tcp

balance roundrobin

server mysql13 106.2.12.28:3306

listen mysql14

bind 0.0.0.0:3332

mode tcp

balance roundrobin

server mysql14 106.2.12.6:3306

listen mysql15

bind 0.0.0.0:3333

mode tcp

balance roundrobin

server mysql15 106.2.12.41:3306

listen mysql16

bind 0.0.0.0:3334

mode tcp

balance roundrobin

server mysql16 106.2.12.42:3306

 

以上是关于Haproxy配置文件(haproxy.cfg)的主要内容,如果未能解决你的问题,请参考以下文章

Docker+Haproxy实现MongoDB数据库负载均衡

公网访问内网数据库--Haproxy配置

Haproxy配置文件

haproxy高可用以及双主模式

haproxy 安装配置

Linux高性能负载均衡HAProxy配置详解