티스토리 뷰
16년 10월 기준.
wget http://www.haproxy.org/download/1.6/src/haproxy-1.6.9.tar.gz
tar -xvzf haproxy-1.6.9.tar.gz
make TARGET=linux26 ARCH=x86_64
make install
cd examples
cp haproxy.init /etc/rc.d/init.d/haproxy
chmod 755 /etc/rc.d/init.d/haproxy
mkdir -p /etc/haproxy/
cp ssl.cfg /etc/haproxy/
// vi haproxy.cfg 한후에 직접생성해도 된다.
mkdir -p /etc/haproxy/errors/
cp errorfiles/* /etc/haproxy/errors/
cd /usr/sbin
ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
// 심볼릭 링크
/etc/init.d/haproxy: line 98: /usr/sbin/haproxy: 그런 파일이나 디렉터리가 없습니다
Errors found in configuration file, check it with 'haproxy check'.
// config가 /usr/sbin/haproxy의 경로를 참조하게 설정되어 있으므로 해당 경로에 복사해야 한다.
mv haproxy /usr/sbin/haproxy
// /usr/local/haproxy의 haproxy 심볼릭을 참조해서 설치된 경로의 haproxy를 복사한다. 실제 경로는 cd /usr/local/sbin/haproxy
/etc/init.d/haproxy start
/etc/init.d/haproxy stop
make TARGET=linux26 ARCH=x86_64 PREFIX=/usr/local/haproxy
// 초기 설치시에 경로 지정
vi /etc/haproxy/haproxy.cfg
#LB ip 192.168.100.97
#server-1 192.168.100.97
#server-2 192.168.100.75
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
maxconn 4096
uid 99
gid 99
daemon
log-send-hostname
defaults
log global
mode http
timeout connect 5000
timeout client 5000
timeout server 5000
balance roundrobin
stats enable
stats refresh 10s
stats uri /admin
frontend http-in
bind *:80
reqadd X-Forwarded-Proto:\ http
default_backend http_backend
backend http_backend
mode http
balance roundrobin
option log-health-checks
option forwardfor
option httpclose
cookie SERVERID rewrite
cookie JSESSIONID prefix
server s1 192.168.100.97:8003 cookie s1 check inter 1000 rise 2 fall 5
server s2 192.168.100.75:8080 cookie s2 check inter 1000 rise 2 fall 5
listen으로 설정시
listen test
bind 192.168.100.97:80
HAProxy만 사용시 keepalived 관련 옵션은 지워야 한다. 안지우면 deviation 발생.
backend http_backend
mode http
balance roundrobin
option forwardfor
# option log-health-checks
# option httpclose
# option httpchk GET /
cookie SERVERID rewrite
cookie JSESSIONID prefix
haproxy 로그 설정
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
/etc/sysconfig/rsyslog
SYSLOGD_OPTIONS="-m 0 -r"
vi /etc/rsyslog.conf
local2.* /var/log/haproxy.log
service rsyslog restart
HAProxy rsyslog 설정
vi /etc/rsyslog.conf
# Provides UDP syslog reception
$ModLoad imudp.so
$UDPServerRun 514
$template HAProxy, "%msg%\n"
local2.* -/var/log/haproxy.log;HAproxy
local2.* /var/log/haproxy.log
vi /etc/haproxy/haproxy.cfg
global
log 127.0.0.1 local2
/var/log/haproxy.log
'Study' 카테고리의 다른 글
keepalived(킵얼라이브) 관련 (1) | 2024.01.07 |
---|---|
Apache(아파치) 설치 (0) | 2024.01.07 |
Spring(스프링) Error(에러) 관련 (1) | 2024.01.07 |
Unity3D(유니티3D) 관련 (1) | 2024.01.07 |
Linux(리눅스) Mail Server(메일서버) Setting(세팅) (0) | 2024.01.07 |