[How-To] Install HAProxy on Ubuntu 24.04 LTS
Purpose
Purpose description.
Prerequisites
List of prerequisites:
- Root user or sudo user
- Debian 12 LXC or VM
Instructions
Step 1: Update and Install HAProxy
Install haproxy
sudo apt update
sudo apt install -y haproxy
# Global settings
global
log /dev/log local0
log /dev/log local1 notice
maxconn 4096
user haproxy
group haproxy
daemon
# Default settings
defaults
log global
option httplog
option dontlognull
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
# Frontend for MariaDB
frontend mariadb_frontend
bind 192.168.1.100:3306 # Replace with your VIP and port
mode tcp
default_backend mariadb_backend
# Backend for MariaDB Galera Cluster
backend mariadb_backend
mode tcp
balance roundrobin # Load balancing method (roundrobin, leastconn, etc.)
option tcp-check # Enable health checks
tcp-check connect port 3306
tcp-check expect response string "wsrep_local_state_comment: Synced"
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server mariadb1 192.168.1.101:3306 check # Replace with actual IPs of your nodes
server mariadb2 192.168.1.102:3306 check
server mariadb3 192.168.1.103:3306 check