【运维笔记】haproxy

源码安装

make TARGET=linux2628 PREFIX=/usr/local/haproxy
make install PREFIX=/usr/local/haproxy

全局配置

global
	log 127.0.0.1 local3 info  ## 设置日志
	chroot /usr/local/haproxy  ## 设置根目录
	user haproxy  ## 用户
	group haproxy
	daemon  ## 守护进程启动
	maxconn 4000  # 最大连接数

默认配置

defaults
	log global
	mode http
	timeout connect 5000
	timeout client 50000
	timeout server 50000

监听端口

listen stats
		bind *:80
		mode http
		stats uri /
		stats hide-version
		stats admin if TRUE

## 数据库代理TCP
listen mysql_lb
		bind *:3307
		mode tcp
		server mariadb1 127.0.0.1:3306 weight 1 check inter 2000 rise 2 fall 3
		server mariadb2 10.0.2.85:3306 weight 1 check inter 2000 rise 2 fall 3

## SSH代理 TCP
listen ssh1
		bind *:222
		mode tcp
		server mariadb1 10.0.2.85:22 weight
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章