LoginSignup
0
2

More than 5 years have passed since last update.

Haproxyのインストール(ソースからrpmの作成Ver.)

Posted at

必要モジュールのインストール

yum install rpm-build pcre-devel gcc

インストールの準備

mkdir -p /root/rpmbuild/SOURCES
mkdir -p /root/rpmbuild/SPECS
cd /root/rpmbuild/SOURCES

ソースのダウンロード

wget http://www.haproxy.org/download/1.5/src/haproxy-1.5.5.tar.gz
tar zxvf haproxy-1.5.5.tar.gz
cp haproxy-1.5.0/examples/haproxy.spec ../SPECS/

RPMのビルド

cd /root/rpmbuild/SPECS
rpmbuild -ba haproxy.spec

Haproxyのインストール

rpm -Uvh /root/rpmbuild/RPMS/x86_64/haproxy-1.5.5-1.x86_64.rpm

mkdir /var/lib/haproxy

ログ出力の設定

/etc/rsyslog.conf
#*.info;mail.none;authpriv.none;cron.none                /var/log/messages
*.info;mail.none;authpriv.none;cron.none;local6.none                /var/log/messages

local6.*                                                /var/log/haproxy.log

# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

$ModLoad imudp
$UDPServerRun 514

ログのローテート設定

/etc/logrotate.d/syslog
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
/var/log/haproxy.log
{
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

設定@サンプル

/etc/haproxy/haproxy.cfg
global
        log         127.0.0.1 local6
        maxconn     16384
        chroot      /var/lib/haproxy
        uid 99
        gid 99
        daemon
#       debug
        spread-checks 5
        nbproc      4 #CPUのコア数に合わせる

defaults
        log             global
        option          tcplog
        mode tcp
        retries 2
        timeout connect 5s
        timeout client  20s
        timeout server  20s
        timeout check   10s

listen http
        bind *:80
        mode tcp
        balance roundrobin
        option  log-health-checks
        option  tcp-smart-connect
        option  contstats
        server  read1 192.168.1.11:80 check port 80 inter 30000 fall 1
        server  read2 192.168.1.12:80 check port 80 inter 30000 fall 1
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2