HAproxy 源碼包安裝
- 系統環境:Centos 7 x64位
- 服務版本:haproxy-1.7.8.tar.gz
- 編譯工具:gcc
下載地址
HAproxy:https://pan.baidu.com/s/1rt8gLoMgkS6oR1Bv5lFXTw
密碼:e4db
下載安裝包到本地,並解壓
進入解壓目錄
指定編譯路徑
編譯安裝
查看haproxy版本
復制haproxy啟動服務到指定目錄下
添加啟動腳本到系統服務目錄內,並給腳本添加啟動權限
創建系統賬號
創建配置文件目錄
創建配置文件 vim /etc/haproxy/haproxy.cfg

global log 127.0.0.1 local3 info chroot /usr/local/haproxy user haproxy group haproxy daemon maxconn 4000 defaults log global mode http option httplog option dontlognull timeout connect 5000 timeout client 50000 timeout server 50000 frontend http_front bind *:80 stats uri /haproxy?stats default_backend http_back backend http_back balance roundrobin option httpchk GET /index.html option forwardfor header X-Forwarded-For server node1 192.168.1.166:80 check inter 2000 rise 3 fall 3 weight 30 server node2 192.168.1.110:80 check inter 2000 rise 3 fall 3 weight 30

global log 127.0.0.1 local3 info chroot /usr/local/haproxy user haproxy group haproxy daemon maxconn 4000 defaults log global mode http option httplog option dontlognull timeout connect 5000 timeout client 50000 timeout server 50000 listen redis bind 0.0.0.0:6379 mode tcp server s1 192.168.1.79:6379 check inter 2000 rise 3 fall 3 server s2 192.168.1.82:6379 check inter 2000 rise 3 fall 3
打開rsyslog文件 , 配置。
去掉下面兩行前面的#號
$ModLoad imudp $UDPServerRun 514
並添加下面一行
local3.* /var/log/haproxy.log
重啟rsyslog
啟動haproxy
了解更多:https://www.cnblogs.com/zyd112/p/8888945.html