【運維筆記】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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章