좋은 프로그램은 마음의 여유에서 나온다.

우분투에 haproxy 설치하기 본문

기타

우분투에 haproxy 설치하기

좋은데이 2016.05.03 23:43

L7 로드발란서 HAProxy 설치하기

설치 환경 : 우분투 14.04 64bit

  1. HAProxy 다운로드
    1. 다운로드 주소 보기 : http://www.haproxy.org/#down
    2. 현재 최신버전 1.6.4 주소 : http://www.haproxy.org/download/1.6/src/haproxy-1.6.4.tar.gz

      $ wget http://www.haproxy.org/download/1.6/src/haproxy-1.6.4.tar.gz
        
      --2016-05-03 14:00:44--  http://www.haproxy.org/download/1.6/src/haproxy-1.6.4.tar.gz
      Resolving www.haproxy.org (www.haproxy.org)... 195.154.117.1612001:7a8:363c:2::2
      Connecting to www.haproxy.org (www.haproxy.org)|195.154.117.161|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: 1559276 (1.5M) [application/x-gzip]
      Saving to: ‘haproxy-1.6.4.tar.gz’
       
      100%[======================================>] 1,559,276    206KB/s   in 11s    u
       
      2016-05-03 14:00:56 (139 KB/s) - ‘haproxy-1.6.4.tar.gz’ saved [1559276/1559276]
    3. 압축 해제 : $ tar zxvf haproxy-1.6.4.tar.gz

  2. make로 컴파일 하기

    1. 압축 해제후 README 파일을 열어보면 TARGET를 지정해주라고 나와있음

      - linux22 for Linux 2.2
      - linux24 for Linux 2.4 and above (default)
      - linux24e for Linux 2.4 with support for a working epoll (> 0.21)
      - linux26 for Linux 2.6 and above
      - linux2628 for Linux 2.6.28, 3.x, and above (enables splice and tproxy)
      - solaris for Solaris 8 or 10 (others untested)
      - freebsd for FreeBSD 5 to 10 (others untested)
      - netbsd for NetBSD
      - osx for Mac OS/X
      - openbsd for OpenBSD 3.1 and above
      - aix51 for AIX 5.1
      - aix52 for AIX 5.2
      - cygwin for Cygwin
      - generic for any other OS or version.
      - custom to manually adjust every setting

    2. 리눅스 버전 확인하기

      $ uname -a
      Linux ip-172-31-23-15 3.13.0-74-generic #118-Ubuntu SMP Thu Dec 17 22:52:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    3. 컴파일하기. 

      1. 나는 3.13.0 이므로 TARGET=linux2628을 지정

      2. USE_PCRE : 펄 호환 정규 표현식을 사용할 경우 USE_PCRE=1
      3. USE_OPENSSL : SSL을 이용할 경우 USE_OPENSSL=1, 이 옵션을 주지 않으면 https를 사용할 수 없음
      4. USE_ZLIB : http 압축을 이용할 경우 USE_ZLIB=1

      5. make 설치 : sudo apt-get install make

      6. gcc 설치 : sudo apt-get install gcc

      7. pcre 설치 : sudo apt-get install libpcre3-dev
      8. openssl 설치 : sudo apt-get install libssl-dev openssl

        $ make TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1
          
          
        README 내용 중 빌드 예제
          
        For example, I use this to build for Solaris 8 :
         
            $ make TARGET=solaris CPU=ultrasparc USE_STATIC_PCRE=1
         
        And I build it this way on OpenBSD or FreeBSD :
         
            $ gmake TARGET=freebsd USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1
         
        And on a classic Linux with SSL and ZLIB support (eg: Red Hat 5.x) :
         
            $ make TARGET=linux26 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1
         
        And on a recent Linux >= 2.6.28 with SSL and ZLIB support :
         
            $ make TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1
  3. 설치하기

    $ sudo make install
    install -d "/usr/local/sbin"
    install haproxy  "/usr/local/sbin"
    install -d "/usr/local/share/man"/man1
    install -m 644 doc/haproxy.1 "/usr/local/share/man"/man1
    install -d "/usr/local/doc/haproxy"
    for x in architecture close-options configuration cookie-options intro linux-syn-cookies lua management network-namespaces proxy-protocol; do \
            install -m 644 doc/$x.txt "/usr/local/doc/haproxy" ; \
        done


  4. haproxy 서비스 등록하기, 실행파일 /usr/sbin에 복사하기

    $ sudo cp examples/haproxy.init /etc/init.d/haproxy
    $ sudo chmod 755 /etc/init.d/haproxy
    $ sudo cp /usr/local/sbin/haproxy /usr/sbin/


  5. 설정파일 만들어주기

    내용 샘플(http://cbonte.github.io/haproxy-dconv/configuration-1.6.html#2.4) 2.5인데 2.4로 북마크가 잘못걸려있음
      
    $ sudo vi /etc/haproxy/haproxy.cfg
      
    global
            daemon
            maxconn 256
     
        defaults
            mode http
            timeout connect 5000ms
            timeout client 50000ms
            timeout server 50000ms
     
        frontend http-in
            bind *:80
            default_backend servers
     
        backend servers
            server server1 127.0.0.1:8000 maxconn 32
      

  6. 설치 확인 : $ haproxy -v

  7. 설치 정보 확인 : $ haproxy -vv

    1. 빌드시 옵션이 제대로 적용되었나 확인

    2. HA-Proxy version 1.6.3 2015/12/25

      Copyright 2000-2015 Willy Tarreau <willy@haproxy.org>


      Build options :

        TARGET  = linux2628

        CPU     = generic

        CC      = gcc

        CFLAGS  = -O2 -g -fno-strict-aliasing -Wdeclaration-after-statement

        OPTIONS = USE_ZLIB=1 USE_OPENSSL=1 USE_PCRE=1


      Default settings :

        maxconn = 2000, bufsize = 16384, maxrewrite = 1024, maxpollevents = 200


      Encrypted password support via crypt(3): yes

      Built with zlib version : 1.2.8

      Compression algorithms supported : identity("identity"), deflate("deflate"), raw-deflate("deflate"), gzip("gzip")

      Built with OpenSSL version : OpenSSL 1.0.1f 6 Jan 2014

      Running on OpenSSL version : OpenSSL 1.0.1f 6 Jan 2014

      OpenSSL library supports TLS extensions : yes

      OpenSSL library supports SNI : yes

      OpenSSL library supports prefer-server-ciphers : yes

      Built with PCRE version : 8.31 2012-07-06

      PCRE library supports JIT : no (USE_PCRE_JIT not set)

      Built without Lua support

      Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND


      Available polling systems :

            epoll : pref=300,  test result OK

             poll : pref=200,  test result OK

           select : pref=150,  test result OK

      Total: 3 (3 usable), will use epoll.

  8. 서비스 실행 : $ sudo service haproxy start


저작자 표시
신고
0 Comments
댓글쓰기 폼