Let’s SSH into the individual nodes to set them up.
- On the first node:
systemctl stop mariadb nano /etc/mysql/mariadb.conf.d/60-galera.cnf [mysqld] # MySQL-related settings bind-address = 0.0.0.0 binlog_format = ROW default_storage_engine = InnoDB innodb_autoinc_lock_mode = 2 # This setting provides better write performance at a small risk of data # loss on OS crash (not just DB crash). In a multi-node cluster, this is an acceptable # and common setting, as data exists on other nodes. innodb_flush_log_at_trx_commit = 2 innodb_log_file_size = 256M innodb_log_buffer_size = 64M # A shorter lock wait timeout fails faster in a cluster environment, # which is generally preferred over long waits. innodb_lock_wait_timeout = 60 # The InnoDB buffer pool is the most critical performance setting. # Set this to ~70% of the server's available RAM if it's a dedicated database server. innodb_buffer_pool_size = 800M # Skip trying to resolve names since we are using IP addresses skip-name-resolve # Allow for more attempts to prevent HAProxy from being blocked max_connect_errors = 1000 # Logs not only errors but warnings, too (older more compatible method from log_error_verbosity)): log_warnings = 1 wait_timeout = 1800 interactive_timeout = 1800 max_allowed_packet = 1G [galera] # Galera Provider Configuration wsrep_on=ON wsrep_provider=/usr/lib/galera/libgalera_smm.so # Note: The gcache stores writesets for nodes that briefly disconnect. # A larger gcache allows for a longer disconnect time before a full SST is required. wsrep_provider_options="gcache.size=512M;gcs.fc_limit=128;gcs.fc_factor=0.8" # Galera Cluster Configuration (ADJUST - same on each node) wsrep_cluster_name="clusterA" # Info about each node (ADJUST - same on each node) wsrep_cluster_address="gcomm://192.168.8.71,192.168.8.72,192.168.8.73,192.168.8.74" # The newer non-blocking method is mariadb, the older one is rsync (ports need to be opened!) wsrep_sst_method = mariabackup # SST user for syncinging, same for each node. UPDATE! wsrep_sst_auth = sst_user:MySuperSecurePassword # Galera Node Configuration (ADJUST FOR EACH NODE) wsrep_node_address = "192.168.8.71" # <-- CHANGE THIS ON EACH NODE wsrep_node_name = "galera-a1" # <-- CHANGE THIS ON EACH NODE wsrep_sst_receive_address = "192.168.8.71" # <-- CHANGE THIS ON EACH NODE
- Once done, do not yet try starting the mysql service, because it will fail due to not seeing any node in the cluster yet (not even itself). Instead, initiate the new cluster and check that you can see one unit:
# Initiate the galera cluster from the first node: galera_new_cluster # Check that the output shows '1' mysql -e "SHOW STATUS LIKE 'wsrep_cluster_size';" # Now start the MariaDB service! systemctl start mariadb
- The result of the mysql query should look like this:
- Let’s head to the ‘galera-A2’ node and set it up in a similar way – just ensure to change the last few rows.
systemctl stop mariadb nano /etc/mysql/mariadb.conf.d/60-galera.cnf # Copy the same config file as above with the difference in the last two rows: # Galera Node Configuration (ADJUST FOR EACH NODE) wsrep_node_address = "192.168.8.72" # <-- CHANGE THIS ON EACH NODE wsrep_node_name = "galera-a2" # <-- CHANGE THIS ON EACH NODE wsrep_sst_receive_address = "192.168.8.72" # <-- CHANGE THIS ON EACH NODE # Exit with save. Do not start a new cluster by runnning 'galera_new_cluster'. # Start the MariaDB service: systemctl start mariadb # Verify that the service started and the node joined the cluster systemctl status mariadb # Check how many nodes are in the cluster mysql -e "SHOW STATUS LIKE 'wsrep_cluster_size';"
- Here is how the output may look like (from node A2 that was just added to the cluster):
- Rinse and repeat with ‘galera-A3’ and ‘galera-A4’, each time:
- Stop the MariaDB service
- Edit the 60-galera.conf file
- Copy paste the full config that we used on the ‘galera-A1’ node.
- Edit the last two rows to capture the node’s IP and hostname
- Start the MariaDB service again (or reboot the container)
- Once all for nodes have been added to the cluster, you can run
mysql -e "SHOW STATUS LIKE 'wsrep_cluster_size';"on any of them and should get the value of 4.


