This Docker container is based on the official Docker mariadb:10.1 image and is designed to be
compatible with auto-scheduling systems, specifically Docker Swarm Mode (1.12+) and Kontena.
However, it could also work with manual scheduling (docker run) by specifying the correct
environment variables.
It takes as a command one of the following:
"seed" - Used only to initialize a new cluster and after initialization and other nodes are joined
the "seed" container should be stopped and replaced with a "node" container using the same volume.
"node" - Join an existing cluster. Takes as a second argument a comma-separated list of IPs or
hostnames to resolve which are used to build the --wsrep_cluster_address option for joining a cluster.
"no-galera" - Start server with Galera disabled. Useful for maintenance tasks like performing mysql_upgrade
and resetting root credentials.
"sleep" - Start the container but not the server. Runs "sleep infinity". Useful just to get volumes
initialized or if you want to docker exec without the server running.
The main feature over the official maraiadb image is that DNS-resolution is used to discover other nodes
so they don't have to be specified explicitly. Works with any system with DNS-based service discovery such
as Kontena, Docker Swarm Mode, Consul, etc.
Tries to handle as many recovery scenarios as possible including full cluster ungraceful shutdown by
using --wsrep-recovery and inter-node communication to discover the optimal node for bootstrapping
a new cluster when the old one cannot be recovered.
If you need to perform manual recovery of a previously healthy cluster you can use "node" mode
but touch a file at /var/lib/mysql/wsrep-new-cluster to force a node to bootstrap a new cluster
and bypass the automatic recovery steps.
XtraBackup is used for state transfer and MariaDb now supports pc.recovery so the correct node should
automatically become master in the case of all nodes being grgacefully shutdown.
A go server runs within the cluster exposing an http service for intelligent health checking.
Port 8080 is used by the Docker 1.12 HEALTHCHECK feature and also can be used by any other health checking
node in the network such as HAProxy or Consul to determine readable/writeable nodes.
Port 8081 is used to detemine cluster status
If your container network uses something other than ethwe* or eth0 then you need to specify NODE_ADDRESS
as either the name of the interface to listen on or a grep pattern to match one of the container's IP addresses.
E.g.: NODE_ADDRESS='^10.0.1.*'
When using DNS for node address discovery the container entrypoint script will wait indefinitely for
GCOMM_MINIMUM IP addresses to resolve before trying to start mysqld in case some containers are starting
slower than others to increase the chance of a healthy recovery. Scenarios where not enough IPs would resolve
might include:
Some nodes may finish pulling container images from remote repositories sooner than others
Schedulers may not be launching nodes quickly enough
Service discovery systems may be slow to propagate updates via DNS
If the file /usr/local/lib/startup.sh exists it will be sourced in the start.sh script.
If you need to promote a running node to be a new "Primary Component" you can run the following command to do so:
$ docker exec -i mysql -p /primary-component.sql