I've wasted too much time trying to search around for a good tutorial that actually works with the latest version of MariaDB, and for a commonly used Linux distribution most people are actually using, so what the heck. I'm now sharing simple installation instructions for a three node cluster.
For this setup I'm using MariaDB 10.5 on the default Debian 11 image on G2. Assume that the public ip addresses are 10.10.10.1, 10.10.10.2, and 10.10.10.3 for the three nodes. Okay, let's start.
1 Install MariaDB
On each node, run the following:
sudo apt install mariadb-server mariadb-client rsync
2 Apply the configuration
Edit the file:
# Mandatory settings
wsrep_on = ON
wsrep_provider = /usr/lib/galera/libgalera_smm.so
wsrep_cluster_name = "my_galera_cluster"
wsrep_cluster_address = gcomm://10.10.10.1,10.10.10.2,10.10.10.3
wsrep_sst_method = rsync
binlog_format = row
default_storage_engine = InnoDB
innodb_autoinc_lock_mode = 2
# Allow connections on all interfaces
bind-address = 0.0.0.0
port = 3306
# Cluster options and unique settings
wsrep_provider_options = pc.weight=0; ist.recv_bind=0.0.0.0
wsrep_node_address = 10.10.10.1
# Configure timezone
Since MariaDB 10.4 or so, you need to set
wsrep_on = ON as it's off by default.
wsrep_provider replaces the former galera-4 package I presume, as it's now included in the mariadb-server package, or at least a dependency. Pick a name for your cluster, this needs to be the same on all nodes, so does the
wsrep_cluster_address, here you can also use the private ip addresses if your nodes are within the same region and connected to the same vpc.
port decides over the outbound connectivity for your database. 0.0.0.0 means that your database is accessible on all interfaces, you may also use
127.0.0.1 or the private ip address here if you wish to secure your nodes further.
wsrep_provider_options offer you some additional configuration options. I noticed that ist.recv_bind needs to be set to avoid connectivity issues so I'd just set it to 0.0.0.0 to be sure. pc.weight is useful to adjust the cluster weight and to avoid a split brain problem. This should be an odd number in total, a concept I found working pretty well is to use: 0, 1, 2, 4, 8... then doubling the number for each node added, then use an odd number of nodes, like 3, 5 or 7.
Note that Σ4 + 1 = 8 so no matter how many nodes are connected, and which are online or offline, there will always be a clear majority/minority in the quorum. Hence no risk of a split brain situation.
Last but not least, set the
wsrep_node_address to the address of the node respectively.
3 Start the cluster
Now, to start the cluster. First stop the mariadb service on each node.
sudo systemctl stop mariadb
Then bootstrap the first node using:
If there seems to be no errors you can now run:
sudo mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_%'"
To verify that the first node started up as it's supposed to. Cluster weight should be the summarized weight of all nodes,
wsrep_cluster_size should be the number of connected nodes, so 1 in this case. Now let's start the next node, on node 2 and 3 run after each others:
sudo systemctl start mariadb
Now show status again on node 1,
wsrep_cluster_size should now say 3,
wsrep_cluster_status should say primary, and
wsrep_cluster_state_uuid should be the same on all nodes. If that's the case for you, then congratulations, you're now up and running.
Apply some commands on one of the nodes, create a database with some tables and data, then check on the other nodes to see if it's replicated. Also make sure that you have the backup service enabled, this will provide decent data protection.