Downloaded source from HAProxy website. Installed requirements:
# apt-get install build-essential zlib1g-dev libpcre3-dev libssl-dev
Unpacked sorce and cd to root of sorce directory. Make is for many targets and many options, Debian Wheezy with installed libs would be:
$ make TARGET=linux2628 CPU=native USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1
When build is successfully executed we can install it:
# make install
Then I created config file called hapconfig with following content:
global
daemon
user tcpstuff
group tcpstuff
chroot /home/tcpstuff
maxconn 1024
defaults
mode tcp
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend tcp-in
bind *:7000
default_backend servers
backend servers
balance roundrobin
server s1 127.0.0.1:7001
server s2 127.0.0.1:7002
server s3 127.0.0.1:7003
And now to run HAProxy:
# /usr/local/sbin/haproxy -f /home/tcpstuff/work/haproxy-1.4.24/hapconfig
It daemonizes itself, as requested in config file, and goes into background, to verify it is up we can execute:
ps aux | grep haproxy
To test echo server cluster I used:
$ echo ‘Hello world!’ | nc -q 1 192.168.1.101 7000
Why -q 1? If we omit it on Debian it will default to waiting for timeout to expire, on Linux Mint we can skip -q. And that was really quick.
No comments:
Post a Comment