Combining Mariadb Galera Cluster with a stand-alone database

59 Views Asked by At

I am setting up a MariaDB Galera cluster along several servers so that they can have access to synchronized data. However, one of the servers is hosting an independent WordPress website which needs its own database, which should not be part of the cluster.

All servers are running Ubuntu (20.04 or 22.04) and MariaDB 10.6.

How can I separate the clustered and stand-alone databases on the same server? Can MariaDB handle this within its settings, or should there be another instance running (and how?)

1

There are 1 best solutions below

2
danblack On

There is a systemd templated services that can operate independently from the Galera instance.

By default, the templated (multi-instance) services are will execute mariadbd with --defaults-group-suffix=.%I.

This means in your configuration file (/etc/mysql/mariadb.conf.d/wordpress.cnf) there needs to be a sections like:

[client-server.wordpress]
socket=/var/lib/mariadb.wordpress/mariadb.socket
port=3309

[mariadb.wordpress]
wsrep_on=off
datadir=/var/lib/mariadb.wordpress
tmpdir=/tmp/mariadb.wordpress

/etc/tmpfiles.d/mariadb.wordpress

d /tmp/mariadb.wordpress 1755 mysql mysql

This is just to be 100% about the temporary file isolation.

The .wordpress sections apply to the wordpress instance and won't be read by the Galera instance. However global setting will be read by the wordpress instance hence disabling wsrep_on=off.

To install a datadir:

mkdir -p /var/lib/mariadb.wordpress
mariadb-install-db --defaults-group-suffix=.wordpress
chown -R mysql: /var/lib/mariadb.wordpress

Then to enable and start the service:

systemctl enable [email protected]
systemctl start [email protected]

ref: MariaDB KB systemd, or look inside the /lib/systemd/system/[email protected] file.