MariaDB clustering with galera

Some notes for myself written down publicly in the hopes that they might help some future person.

It is highly recommended to have the cluster on a vlan/vswitch!
Galera does not implement it’s own security for the cluster ports. See the vlan part at the bottom of this document if you do not have vlans setup yet.

In this example the following IPs are used:
Local machine:
Another cluster node:

Make sure mariadb is off before starting!

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

wsrep_on = ON
wsrep_provider = /usr/lib/galera/
wsrep_cluster_address = "gcomm://,"
binlog_format = row
default_storage_engine = InnoDB
wsrep_node_address =
innodb_autoinc_lock_mode = 2
bind-address =

If this is the first node in the cluster, or all nodes in the cluster are currently down, you have to run
galera_new_cluster to bootstrap the cluster again. Otherwise you can just start the mariadb service through systemd.

Now you’re good to go!
While everything should work now, if you want to read more about galera you can do so here.

Addendum: Vlans

You should keep the cluster on a vlan for security reasons. This can be done in netplan by editing /etc/netplan/(yourconfig).yaml and adding:

      id: 4001
      link: enp0s31f6
      mtu: 1400

Here enp0s31f6 is the interface name, 4001 is the vlan id, and is the ip to assign to the local box.