Haproxy代理TCP安装部署文档

HaProxy安装部署文档
官网网址
https://www.haproxy.org/

下载软件包
haproxy-1.9.8.tar.gz

解压缩
tar -zxvf ?haproxy-1.9.8.tar.gz

解压后目录
/opt/haproxy/haproxy-1.9.8

安装依赖
yum install gcc pcre-static pcre-devel -y

进入文件目录-编译安装
1、cd /opt/haproxy/haproxy-1.9.8
2、make TARGET=linux2628
3、make install
4、mkdir -p /etc/haproxy
5、ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
(安装完的可之执行文件在/usr/local/sbin/haproxy,需要创建一个软连接到/usr/sbin/haproxy,因为启动脚本默认使用/usr/sbin/haproxy这个位置)

6、cp /opt/haproxy/haproxy-1.9.8/examples/haproxy.init /etc/init.d/haproxy
(把启动文件拷贝到init.d目录下)

7、chmod 755 /etc/init.d/haproxy


8、useradd -r haproxy
(添加一个账户)

9、haproxy -v
(HA-Proxy version 1.9.8 2019/05/13 - https://haproxy.org/)

10、vi /etc/haproxy/haproxy.cfg

global
	maxconn 4096
	daemon
	chroot      /var/lib/haproxy
	pidfile     /var/run/haproxy.pid
	#debug
	#quiet
	user haproxy
	group haproxy
    log 127.0.0.1:514  local0
 
defaults
	log     global
	mode    http
	option  httplog
	option  dontlognull
	log 127.0.0.1 local0
	retries 3
	option redispatch
	maxconn 2000
	#contimeout      5000
	#clitimeout      50000
	#srvtimeout      50000
	timeout http-request    10s
	timeout queue           1m
	timeout connect         10s
	timeout client          1m
	timeout server          1m
	timeout http-keep-alive 10s
	timeout check           10s
 

listen proxy-netty 
bind *:8888
	mode tcp
	balance roundrobin
    log 127.0.0.1 local2
	option tcplog
	server netty1 192.168.80.110:8080 check weight 1 maxconn 2000
	server netty2 192.168.80.113:8080 check weight 1 maxconn 2000
	#option tcpka

11、service haproxy start|check|stop|restart.....

添加日志
1、install -y rsyslog
2、vim /etc/rsyslog.conf

$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514

#在rules(规则)节中添加如下信息
local2.* /var/log/haproxy.log
#表示将发往facility local2的消息写入haproxy.log文件中,"local2.* "前面的local2表示facility,预定义的。*表示所有等级的消息

3、service rsyslog restart

4、log 127.0.0.1 local2?
(配置文件增加)

5、Service haproxy restart

6、tail -f /var/log/haproxy.log
?

Haproxy代理TCP安装部署文档

上一篇:Solr与Elasticsearch:开源搜索引擎到底如何选择?


下一篇:QXlsx的private header message消除(替换QZip)