How to install HAproxy v1.8.9 on OpenSUSE leap 15.0

To install HAproxy v1.8.9 on OpenSUSE 15.0


HAProxy or High Availability Proxy is used for load balancing, Load balancer servers are also known as front-end servers. Generally, their purpose is to direct users to available application servers. HAProxy aims to optimize resource usage, maximize throughput, minimize response time, and avoid overloading any single resource.

Installation

First, install the required dependencies

Linuxhelp1:~ # zypper install gcc pcre-static pcre-devel -y
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 19 NEW packages are going to be installed:

  gcc gcc7 glibc-devel libasan4 libatomic1 libcilkrts5 libitm1 liblsan0 libmpx2
  libmpxwrappers2 libpcre16-0 libpcrecpp0 libpcreposix0 libstdc++6-devel-gcc7
  libstdc++-devel libtsan0 libubsan0 linux-glibc-devel pcre-devel

19 new packages to install.

Overall download size: 30.1 MiB. Already cached: 0 B. After the operation,
additional 121.0 MiB will be used.
Continue? [y/n/...? shows all options] (y): y
Retrieving package libasan4-7.3.1+r258812-lp150.2.10.x86_64
                                          (1/19), 354.2 KiB (  1.3 MiB unpacked)
Retrieving: libasan4-7.3.1+r258812-lp150.2.10.x86_64.rpm ....[done (72.5 KiB/s)]
Retrieving package libatomic1-7.3.1+r258812-lp150.2.10.x86_64
.
.
.
.
.
(13/19) Installing: linux-glibc-devel-4.15-lp150.1.23.noarch .............[done]
(14/19) Installing: glibc-devel-2.26-lp150.11.3.2.x86_64 .................[done]
(15/19) Installing: libstdc++6-devel-gcc7-7.3.1+r258812-lp150.2.10.x86_64 [done]
(16/19) Installing: gcc7-7.3.1+r258812-lp150.2.10.x86_64 .................[done]
(17/19) Installing: libstdc++-devel-7-lp150.1.50.x86_64 ..................[done]
(18/19) Installing: gcc-7-lp150.1.50.x86_64 ..............................[done]
(19/19) Installing: pcre-devel-8.41-lp150.4.15.x86_64 ....................[done]

Download the archive format of HAProxy 1.8.9 with the help of wget command

linuxhelp1:~ # wget https://www.haproxy.org/download/1.8/src/haproxy-1.8.9.tar.gz
--2018-06-15 08:33:14--  https://www.haproxy.org/download/1.8/src/haproxy-1.8.9.tar.gz
Resolving www.haproxy.org (www.haproxy.org)... 51.15.8.218
Connecting to www.haproxy.org (www.haproxy.org)|51.15.8.218|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2057051 (2.0M) [application/x-tar]
Saving to: ‘ haproxy-1.8.9.tar.gz’ 
haproxy-1.8.9.tar.g 100%[===================> ]   1.96M   144KB/s    in 13s     
2018-06-15 08:33:30 (151 KB/s) - ‘ haproxy-1.8.9.tar.gz’  saved [2057051/2057051]


After downloading it extract it by,

linuxhelp1:~ # tar -zxf haproxy-1.8.9.tar.gz

Move inside the extracted directory

linuxhelp1:~ # cd haproxy-1.8.9/

Compile the program for your system.

linuxhelp1:~/haproxy-1.8.9 # make TARGET=linux2628
gcc -Iinclude -Iebtree -Wall  -O2 -g -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv -fno-strict-overflow -Wno-format-truncation  -Wno-null-dereference -Wno-unused-label       -DCONFIG_HAP_LINUX_SPLICE -DTPROXY -DCONFIG_HAP_LINUX_TPROXY -DCONFIG_HAP_CRYPT -DENABLE_POLL -DENABLE_EPOLL -DUSE_CPU_AFFINITY -DASSUME_SPLICE_WORKS -DUSE_ACCEPT4 -DNETFILTER -DUSE_THREAD -DUSE_SYSCALL_FUTEX  -DCONFIG_HAPROXY_VERSION=" 1.8.9-83616ec"  -DCONFIG_HAPROXY_DATE=" 2018/05/18"  -c -o src/ev_poll.o src/ev_poll.c
gcc -Iinclude -Iebtree -Wall  -O2 -g -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv -fno-strict-overflow -Wno-format-truncation  -Wno-null-dereference -Wno-unused-label       -DCONFIG_HAP_LINUX_SPLICE -DTPROXY -DCONFIG_HAP_LINUX_TPROXY -DCONFIG_HAP_CRYPT -DENABLE_POLL -DENABLE_EPOLL -DUSE_CPU_AFFINITY -DASSUME_SPLICE_WORKS -DUSE_ACCEPT4 -DNETFILTER -DUSE_THREAD -DUSE_SYSCALL_FUTEX  -DCONFIG_HAPROXY_VERSION=" 1.8.9-83616ec"  -DCONFIG_HAPROXY_DATE=" 2018/05/18"  -c -o src/ev_epoll.o src/ev_epoll.c
gcc -Iinclude -Iebtree -Wall  -O2 -g -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv -fno-strict-overflow -Wno-format-truncation  -Wno-null-dereference -Wno-unused-label       -DCONFIG_HAP_LINUX_SPLICE -DTPROXY -DCONFIG_HAP_LINUX_TPROXY -DCONFIG_HAP_CRYPT -DENABLE_POLL -DENABLE_EPOLL -DUSE_CPU_AFFINITY -DASSUME_SPLICE_WORKS -DUSE_ACCEPT4 -DNETFILTER -DUSE_THREAD -DUSE_SYSCALL_FUTEX  -DCONFIG_HAPROXY_VERSION=" 1.8.9-83616ec"  -DCONFIG_HAPROXY_DATE=" 2018/05/18"  -c -o ebtree/ebtree.o ebtree/ebtree.c
.
.
.
.
src/stats.o src/mux_h2.o src/checks.o src/haproxy.o src/log.o src/dns.o src/peers.o src/standard.o src/sample.o src/cli.o src/stream_interface.o src/proto_tcp.o src/backend.o src/proxy.o src/tcp_rules.o src/listener.o src/flt_http_comp.o src/pattern.o src/cache.o src/filters.o src/vars.o src/acl.o src/payload.o src/connection.o src/raw_sock.o src/proto_uxst.o src/flt_trace.o src/session.o src/ev_select.o src/channel.o src/task.o src/queue.o src/applet.o src/map.o src/frontend.o src/freq_ctr.o src/lb_fwlc.o src/mux_pt.o src/auth.o src/fd.o src/hpack-dec.o src/memory.o src/lb_fwrr.o src/lb_chash.o src/lb_fas.o src/hathreads.o src/chunk.o src/lb_map.o src/xxhash.o src/regex.o src/shctx.o src/buffer.o src/action.o src/h1.o src/compression.o src/pipe.o src/namespace.o src/sha1.o src/hpack-tbl.o src/hpack-enc.o src/uri_auth.o src/time.o src/proto_udp.o src/arg.o src/signal.o src/protocol.o src/lru.o src/hdr_idx.o src/hpack-huff.o src/mailers.o src/h2.o src/base64.o src/hash.o   -lcrypt -ldl &ndash lpthread
finally, install HAProxy
linuxhelp1:~/haproxy-1.8.9 # 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 WURFL-device-detection SPOE proxy-protocol peers-v2.0 peers network-namespaces netscaler-client-ip-insertion-protocol management lua linux-syn-cookies intro DeviceAtlas-device-detection cookie-options configuration close-options architecture 51Degrees-device-detection  do 
    install -m 644 doc/$x.txt " /usr/local/doc/haproxy"    
done

Add the following directories and the statistics file for HAProxy records.

linuxhelp1:~/haproxy-1.8.9 #  mkdir -p /etc/haproxy
linuxhelp1:~/haproxy-1.8.9 # mkdir -p /var/lib/haproxy 
linuxhelp1:~/haproxy-1.8.9 # touch /var/lib/haproxy/stats

Create a symbolic link for the binary to allow you to run HAProxy commands as a normal user.

linuxhelp1:~/haproxy-1.8.9 # ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy

Add the proxy as a service to the system, copy the haproxy.init file from the examples to your /etc/init.d directory.

linuxhelp1:~/haproxy-1.8.9 # cp ~/haproxy-1.8.9/examples/haproxy.init /etc/init.d/haproxy
linuxhelp1:~/haproxy-1.8.9 # chmod 755 /etc/init.d/haproxy
linuxhelp1:~/haproxy-1.8.9 # systemctl daemon-reload

Enable the service to allow it to restart automatically at system boot up.

linuxhelp1:~/haproxy-1.8.9 # chkconfig haproxy on

Add HAProxy user

linuxhelp1:~/haproxy-1.8.9 # useradd -r haproxy

Check the installed version

linuxhelp1:~/haproxy-1.8.9 # haproxy -v
HA-Proxy version 1.8.9-83616ec 2018/05/18
Copyright 2000-2018 Willy Tarreau < willy@haproxy.org> 

With this, the method to install HAproxy v1.8.9 on OpenSUSE 15.0 comes to an end.

Tag : HAProxy
FAQ
Q
what is HA proxy?
A
HAProxy or High Availability Proxy is used for load balancing, Load balancer servers are also known as front-end servers. Generally, their purpose is to direct users to available application servers. HAProxy aims to optimize resource usage, maximize throughput, minimize response time, and avoid overloading any single resource.
Q
What does layer 7 mean?
A
Layer 7 is related to seventh layer of the OSI model: application level. For example: HTTP, FTP, SMTP, DNS protocols are application level.
Q
how to access load balancer using url instead of ip ?
A
Just you need to have a valid DNS entry. And your hostname/IP A, AAA, PTR record should be created in DNS Server.
Q
What are the possible architectures with layer7 load balancers?
A
Actually, only one: Proxy mode, but two main flavors of it are available: Proxy mode Transparent proxy mode
Q
what is the Configuration Files of haproxy?
A
The /etc/haproxy/haproxy.cfg file is the primary configuration file for HAProxy.