High availability mariadb galera cluster

From VoIPmonitor.org
Jump to navigation Jump to search
  • 3 mariadb 10.8.2 nodes - 192.168.0.1, 192.168.0.2, 192.168.0.3
  • haproxy 192.168.0.100


/etc/mysql/mariadb.conf.d/50-server.cnf
[mysqld]
default-authentication-plugin=mysql_native_password
skip-log-bin
symbolic-links=0
innodb_flush_log_at_trx_commit=0
innodb_flush_log_at_timeout = 1800
max_heap_table_size = 24G
innodb_log_file_size = 5G
innodb_log_buffer_size = 2G
innodb_file_per_table = 1
open_files_limit = 200000
skip-external-locking
key_buffer_size = 2G
sort_buffer_size = 65M
max_connections = 100000
max_connect_errors = 1000
skip-name-resolve
max_allowed_packet=256M
wsrep_slave_threads=46
innodb_read_io_threads = 20
innodb_write_io_threads = 20
innodb_purge_threads = 20
innodb_flush_neighbors = 0
innodb_io_capacity = 1000000
innodb_io_capacity_max = 10000000
innodb_doublewrite = 0
innodb_buffer_pool_size = 120G
innodb_flush_method = O_DIRECT
transaction-isolation = READ-UNCOMMITTED
performance_schema=0
innodb_compression_default=ON
innodb_compression_algorithm=lz4

disable log_bin (comment it with #)

/etc/mysql/mariadb.conf.d/60-galera.cnf

[galera]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0

# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib64/galera-4/libgalera_smm.so

# Galera Cluster Configuration
wsrep_cluster_name="VoIPmonitor cluster"
wsrep_cluster_address="gcomm://192.168.0.1,192.168.0.2,192.168.0.3"

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address="100.82.46.72"
wsrep_node_name="Node-01"

wsrep_provider_options="gcache.size=10G;gcache.recover=yes;gcs.fc_limit=500000;"

you can lower the fc_limit to lower values (it is lenght of the queue on each node)


HAPROXY

HAPROXY is on IP 192.168.0.10 (which can be anywhere) and port 3307 - voipmonitor sniffer and GUI connects to 192.168.0.10:3307

/etc/haproxy/haproxy.cfg

 global
        daemon
        maxconn 10000
 defaults
        timeout connect 10s
        timeout client  60m
        timeout server  60m
        option tcplog

# Incoming TCP Connection request for HAproxy
 frontend frontend1
    mode tcp
    option tcpka
    bind 192.168.0.10:3307
    default_backend galera_cluster

# Define the back-end servers
 backend galera_cluster
    #balance roundrobin
    server Node1  192.168.0.1:3306 check         
    server Node2  192.168.0.2:3306 check backup
    server Node3  192.168.0.3:3306 check backup