일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 라떼판다 NAS
- LattePanda Ubuntu
- RDP Wrap
- Packstack
- CentOS
- 라떼판다 우분투
- Openstack Rocky
- PostgreSQL
- haproxy
- Rocky Linux 8
- 라떼판다
- LattePanda NAS
- MariaDB
- CentOS 8
- LattePanda
- centos 7
- RHEL 8
- MySQL
- Kubernetes
- podman
- RHEL
- nextcloud
- WireGuard
- openstack
- Rocky Linux
- MSA
- Windows 10 Home
- RHEL 7
- ubuntu
- 자작 NAS
- Today
- Total
간마늘작업소
(RHEL / CentOS / Rocky Linux) HAProxy - 1.설치(리포지터리 패키지, 컴파일) 본문
(RHEL / CentOS / Rocky Linux) HAProxy - 1.설치(리포지터리 패키지, 컴파일)
간마늘 2021. 10. 26. 15:55HAProxy는 기존 하드웨어 스위치 장비를 대체하는 소프트웨어 로드밸런서입니다.
주로 L4 스위치나 L7 스위치의 대안으로 사용되고 있으며 본래 목적인 리버스 프록시 기능도 제공하고 있습니다.
사전 패키지 설치
RHEL 7 / CentOS 7
yum install gcc openssl openssl-devel pcre-devel pcre-static systemd-devel
RHEL 8 / CentOS 8 / Rocky Linux 8.4
dnf install gcc openssl openssl-devel pcre-devel systemd-devel
dnf install http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/pcre-static-8.42-4.el8.x86_64.rpm
사전 패키지를 설치합니다.
저는 Rocky Linux 8.4 환경에서 테스트를 진행했습니다. pcre-static 등 일부 패키지는 찾을 수 없다고 뜨는 경우가 있는데 이 경우에는 미러 사이트 등지에서 호환되는 OS 버전의 rpm 파일을 구해서 설치하면 됩니다.
HAProxy 설치 (리포지터리 패키지 설치)
RHEL 7 / CentOS 7
yum install haproxy
RHEL 8 / CentOS 8 / Rocky Linux 8.4
dnf install haproxy
기본 리포지터리를 통해서 설치하는 방식입니다. 다만, 버전이 낮습니다.
haproxy -v
HAProxy 설치 (컴파일 설치)
최신 버전을 이용하기 위해서는 컴파일 설치를 해야합니다.
HAProxy - The Reliable, High Performance TCP/HTTP Load Balancer
HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for very high traffic web sites and powers quite a number of the world's most visited
www.haproxy.org
HAProxy 공식 사이트에서 최신 버전을 다운로드 받습니다.
글 작성 시점에서 최신 안정 버전은 2.4.7이네요. 우 클릭해서 URL을 복사합니다.
wget http://www.haproxy.org/download/2.4/src/haproxy-2.4.7.tar.gz
다운로드를 받았으면 압축을 해제합니다. 그리고 컴파일 설치를 진행합니다.
tar -xvf haproxy-2.4.7.tar.gz
cd haproxy-2.4.7/
make TARGET=linux-glibc USE_OPENSSL=1 USE_PCRE=1 USE_ZLIB=1 USE_SYSTEMD=1
make install
이후, HAProxy 계정을 확인해야 합니다. 자동 생성될 수도 있지만 그렇지 않을 수 있습니다. 우선 확인부터 합니다.
cat /etc/passwd | grep haproxy
아무것도 뜨지 않는다면 계정을 생성해줍니다.
groupadd --gid 980 haproxy
useradd --gid 980 --uid 980 -r haproxy
HAProxy가 실행될 때 필요한 디렉토리와 파일들을 생성해줍니다. 내용을 변경한다거나 그런건 없기 때문에 생성만 해주고 기억에서 지워도 무방합니다.
mkdir -p /var/lib/haproxy
touch /var/lib/haproxy/stats
chown -R haproxy:haproxy /var/lib/haproxy
HAProxy의 설정 파일을 저장할 디렉토리를 생성합니다.
기본적으로 리포지터리 패키지 설치를 하게되면 이 경로는 /etc/haproxy가 됩니다. 이 글에서는 동일하게 /etc/haproxy로 하겠습니다. 설치 환경에 따라 이를 변경해주셔도 됩니다.
mkdir -p /etc/haproxy
서비스 데몬 파일을 생성해줍니다.
curl "http://git.haproxy.org/?p=haproxy-2.3.git;a=blob_plain;f=contrib/systemd/haproxy.service.in" -o haproxy.service
내용을 편집합니다.
[Unit]
Description=HAProxy Load Balancer
After=network-online.target
Wants=network-online.target
[Service]
EnvironmentFile=-/etc/default/haproxy
EnvironmentFile=-/etc/sysconfig/haproxy
Environment="CONFIG=/etc/haproxy/haproxy.cfg" "PIDFILE=/run/haproxy.pid" "EXTRAOPTS=-S /run/haproxy-master.sock"
ExecStartPre=/usr/local/sbin/haproxy -Ws -f $CONFIG -c -q $EXTRAOPTS
ExecStart=/usr/local/sbin/haproxy -Ws -f $CONFIG -p $PIDFILE $EXTRAOPTS
ExecReload=/usr/local/sbin/haproxy -Ws -f $CONFIG -c -q $EXTRAOPTS
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
Restart=always
SuccessExitStatus=143
Type=notify
# The following lines leverage SystemD's sandboxing options to provide
# defense in depth protection at the expense of restricting some flexibility
# in your setup (e.g. placement of your configuration files) or possibly
# reduced performance. See systemd.service(5) and systemd.exec(5) for further
# information.
# NoNewPrivileges=true
# ProtectHome=true
# If you want to use 'ProtectSystem=strict' you should whitelist the PIDFILE,
# any state files and any other files written using 'ReadWritePaths' or
# 'RuntimeDirectory'.
# ProtectSystem=true
# ProtectKernelTunables=true
# ProtectKernelModules=true
# ProtectControlGroups=true
# If your SystemD version supports them, you can add: @reboot, @swap, @sync
# SystemCallFilter=~@cpu-emulation @keyring @module @obsolete @raw-io
[Install]
WantedBy=multi-user.target
수정할 것은 2가지 정도입니다.
CONFIG=/etc/haproxy/haproxy.cfg
- haproxy.cfg 파일의 위치. 이 글에서는 /etc/haproxy로 하는 것으로 진행
@SBINDIR@ → /usr/local/sbin/haproxy
- haproxy의 실행파일 위치
작성한 서비스 데몬 파일을 위치시켜줍니다.
cp -rp haproxy.service /etc/systemd/system
정상적으로 설치가 이뤄졌는지 HAProxy의 버전을 확인합니다.
/usr/local/sbin/haproxy -v
HAProxy
- 설치(리포지터리 패키지, 컴파일)
- 설정 파일 작성
- SSL 인증서 적용