SysAdmin Notes: FreeBSD, MariaDB 10.2, and Galera Cluster

Intro

Installing and getting MariaDB 10.2, and Galera Cluster going on FreeBSD (from ports/packages) was not straight forward. The getting started were all geared for linux packages which seem to have different helpers. I couldn’t find any how to’s for freebsd.

These are more notes, not a how-to. Please, someone write up a better how-to or add in helper scripts to ports.

Packages / Ports

As things do and always change from version to version, custom poudriere builds, however all default options.
galera-25.3.21_2
mariadb102-client-10.2.9_1
mariadb102-server-10.2.9_1

Actual Setup / Config

See Appendix A for the my.cnf … this was a merge and hack up of /usr/local/share/mysql/my-innodb-heavy-4G.cnf and /usr/local/share/mysql/wsrep.cnf included with the mariadb102 package.

Skim/read the official getting started first : https://mariadb.com/kb/en/library/getting-started-with-mariadb-galera-cluster/

A few observed notes that drove me crazy trying to get this to work.

– galera cluster does not seem to be launch-able via “mysqld_safe” which is in /usr/local/etc/rc.d/mysql-server.
– Seriously, don’t stop the first instance created with ” –wsrep-new-cluster”
– These freebsd builds won’t obey wsrep_on and wsrep_cluster_address from the my.cnf. I don’t know why.
– when finally running, /db/mysql/db2.err isn’t getting populated.
–log-error=${hostname}.err in the mysql_args reproduced the functionality in mysqld_safe wrapper script.

DB1 – first master

Breaking the FreeBSD-ism, DO NOT use /usr/local/etc/rc.d/mysql-server, so …

First, with wsrep_on and wsrep_cluster_address commented out, initialize the db:

/usr/local/bin/mysql_install_db --basedir=/usr/local

Now, start the first Cluster Master ( I can’t remember now, but when starting new, you might have to set the cluster address to itself ). MUST run as MySQL.

DB2 – test

Log into the databases, with root, (no password at this point if you followed my directions). May want to run mysql_secure_installation – nice script I often forget about. I did, root credentials didn’t seem to replicate.

DB2 – Boot Configure

Control-C didn’t work, will have to ‘kill -TERM $pid’ of the child process to the sudo, will get a clean shutdown.

Edit /usr/local/etc/rc.d/mysql-server, change command_args from using /usr/local/bin/mysqld_safe to /usr/local/libexec/mysqld.

run:/usr/local/etc/rc.d/mysql-server start

Done.

Outstanding issues

– Why does “mysqld_safe” not work.
– Why can’t one init a single node cluster ? makes sense, but for automatic provisioning, a self running cluster of one would be nice.
– wsrep_on, wsrep_cluster_address – why are these not in being respected from the my.cnf ?
– without mysqld_safe, db2.err isn’t getting populated.
–log-error=${hostname}.err in the mysql_args reproduced the functionality in mysqld_safe wrapper script.

# Options that need to be customized:
# - wsrep_provider
# - wsrep_cluster_address
# - wsrep_sst_auth
# The rest of defaults should work out of the box.

## WSREP options

#wsrep_on=on
# Full path to wsrep provider library or 'none'
wsrep_provider=/usr/local/lib/libgalera.so
#wsrep_provider_options=
# Logical cluster name. Should be the same for all nodes.
wsrep_cluster_name="ix_production"
#wsrep_cluster_address="gcomm://db1,db2"
wsrep_node_name=db2
wsrep_node_address=192.168.0.20[12]
#wsrep_node_incoming_address=