Installation Couchdb HAProxy - kwantu/platformconfiguration GitHub Wiki
#HAProxy installation for a cluster
sudo yum install haproxy
vim /etc/haproxy/haproxy.conf
#https://github.com/apache/couchdb/blob/master/rel/haproxy.cfg
https://dev.to/tmidi/getting-started-with-haproxy-install-from-code-source-5c4g
CentOS RHEL:
sudo yum -y install make gcc perl pcre-devel zlib-devel
Download the source code:
wget https://www.haproxy.org/download/1.8/src/haproxy-1.8.8.tar.gz
Extract the file and change directory:
tar xvzf haproxy-1.8.8.tar.gz && cd haproxy-1.8.8
Compile the program:
make TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1
Install HAProxy:
sudo make install
With that, we should now have the chosen HAProxy version installed. now we need to setup HAProxy. Setup:
Adding HAProxy user:
id -u haproxy &> /dev/null || useradd -s /usr/sbin/nologin -r haproxy
Copy HAProxy binary located in the extracted HAProxy directory to /usr/sbin/:
cp haproxy /usr/sbin/
Create Manual page:
wget -qO - https://raw.githubusercontent.com/horms/haproxy/master/doc/configuration.txt | gzip -c > /usr/share/doc/haproxy/configuration.txt.gz
Create Systemd service script to manage HAProxy, use the following at your discretion:
sudo wget https://gist.githubusercontent.com/tmidi/1699a358533ae876513e2887fec6fbe2/raw/6c07ce39adc56c731d2bbeb88b90d8bbc636f3ea/haproxy.service -O /lib/systemd/system/haproxy.service
or create /lib/systemd/system/haproxy.service with the following content:
[Unit] Description=HAProxy Load Balancer Documentation=man:haproxy(1) Documentation=file:/usr/share/doc/haproxy/configuration.txt.gz
allows us to do millisecond level restarts without triggering alert in Systemd
StartLimitInterval=0 StartLimitBurst=0 After=network.target syslog.service Wants=syslog.service
[Service] Environment="CONFIG=/etc/haproxy/haproxy.cfg" "PIDFILE=/run/haproxy.pid"
EXTRAOPTS and RELOADOPS come from this default file
EnvironmentFile=-/etc/default/haproxy ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q ExecStart=/usr/sbin/haproxy -W -f $CONFIG -p $PIDFILE $EXTRAOPTS ExecReload=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS $RELOADOPTS ExecReload=/bin/kill -USR2 $MAINPID KillMode=mixed Restart=always Type=forking
[Install] WantedBy=multi-user.target
Enable and start haproxy.service:
systemctl enablle haproxy.service
systemctl start haproxy.service