Public | Automated Build

Last pushed: 19 days ago
Short Description
MariaDB Galera Cluster
Full Description

Docker Container for MariaDB Galera Cluster

We hope that this container will not be required in the future pending the integration of better Galera support in the official container.
eg PR 24.

This container uses entrypoint modifications similar to the ones by Kristian Klausen to provide (better) Galera support for the offcial mariadb:10.1 container.

Also included is Galera Arbitrator (aka garbd) which allows you to maintain quorum with a two node cluster. (Not required when running 3 or more nodes).

Usage

Environment Arguments

  • WSREP_NODE_ADDRESS - IP or domain of host interface eg WSREP_NODE_ADDRESS=10.0.0.1
  • WSREP_CLUSTER_ADDRESS - List of cluster nodes and ports eg WSREP_CLUSTER_ADDRESS=gcomm://10.0.0.1:4567,10.0.0.2:4567,10.0.0.3:4567
  • WSREP_CLUSTER_NAME - Default my_wsrep_cluster
  • WSREP_NODE_NAME - Defaults to the container hostname. You'll want to set this
    to something that doesn't change.

Running Garbd

Garbd is available. Just specify garbd as the command.

docker run -d --net host --name galera-garbd \
  -e WSREP_CLUSTER_ADDRESS=$WSREP_CLUSTER_ADDRESS \
  panubo/mariadb-galera \
    garbd

Bootstrapping the cluster

Node 1:

docker run -d --net host --name galera \
  -e WSREP_NODE_ADDRESS=$WSREP_NODE_ADDRESS \
  -e WSREP_CLUSTER_ADDRESS=$WSREP_CLUSTER_ADDRESS \
  -e MYSQL_ROOT_PASSWORD={{ mysql_root_password }} \
  -p 3306:3306 \
  -p 4567:4567/udp \
  -p 4567-4568:4567-4568 \
  -p 4444:4444 \
  -v /mnt/data/galera.service/mysql:/var/lib/mysql:Z \
  panubo/mariadb-galera \
    mysqld \
    --wsrep-new-cluster

Node 2-N:

Create empty mysql dir to skip database initialisation. (Kludge!)

mkdir -p /mnt/data/galera.service/mysql/mysql

Start the container normally (without --wsrep-new-cluster).

docker run -d --net host --name galera \
  -e WSREP_NODE_ADDRESS=$WSREP_NODE_ADDRESS \
  -e WSREP_CLUSTER_ADDRESS=$WSREP_CLUSTER_ADDRESS \
  -p 3306:3306 \
  -p 4567:4567/udp \
  -p 4567-4568:4567-4568 \
  -p 4444:4444 \
  -v /mnt/data/galera.service/mysql:/var/lib/mysql:Z \
  panubo/mariadb-galera \
    mysqld

Recovery

Recovery when quorum is lost is fairly simple:

First, stop on all nodes. Eg (if using a Systemd unit to run Galera):

systemctl stop galera.service

Secondly, start node with most complete / recent data set with --wsrep-new-cluster argument. EG:

docker run -d --net host --name galera-init \
  -e WSREP_NODE_ADDRESS=$WSREP_NODE_ADDRESS \
  -e WSREP_CLUSTER_ADDRESS=$WSREP_CLUSTER_ADDRESS \
  -e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD \
  -p 3307:3306 \
  -p 4567:4567/udp \
  -p 4567-4568:4567-4568 \
  -p 4444:4444 \
  -v /mnt/data/galera.service/mysql:/var/lib/mysql:Z \
  panubo/mariadb-galera \
    mysqld \
    --wsrep-new-cluster

Finally, bring up other nodes normally. Eg. (Systemd example)

systemctl start galera.service

Gotchas

  1. Whilst it isn't strictly necessary to use the host network (--net host), there seems to be an issue (bug?) whereby Galera gets both the host and the (duplicated) Docker network IP assigned to the node. This causes issues when multiple nodes fail and attempt to rejoin the cluster.

  2. Garbd requires an explicit port if it blows up with "Exception in creating receive loop." See issue 312.

Docker Pull Command
Owner
panubo
Source Repository

Comments (4)
macropin
8 months ago

Please do not post comments here and expect support. If you have a technical issue please post it in github. Thanks

codingtea
10 months ago

base on 2016-12-22T02:21:50.380Z:

docker run -d --name node11 -h node11 \
-p 11306:3306 -p 11444:4444 -p 11567:4567/udp -p 11567:4567 -p 11568:4568 \
-e WSREP_NODE_ADDRESS=192.168.1.70:11567 \
-e WSREP_CLUSTER_ADDRESS=gcomm://192.168.1.70:11567 \
-e MYSQL_ROOT_PASSWORD=hhgznlzq \
-v /test/data/node11:/var/lib/mysql:Z \
panubo/mariadb-galera:latest mysqld \
--wsrep-new-cluster

docker run -d --name node12 -h node12 \
-p 12306:3306 -p 12444:4444 -p 12567:4567/udp -p 12567:4567 -p 12568:4568 \
-e WSREP_NODE_ADDRESS=192.168.1.70:12567 \
-e WSREP_CLUSTER_ADDRESS=gcomm://192.168.1.70:11567,192.168.1.70:12567 \
-e MYSQL_ROOT_PASSWORD=hhgznlzq \
-v /kmcf/data/node12:/var/lib/mysql:Z \
panubo/mariadb-galera:latest mysqld

docker run -d --name node13 -h node13 \
-p 13306:3306 -p 13444:4444 -p 13567:4567/udp -p 13567:4567 -p 13568:4568 \
-e WSREP_NODE_ADDRESS=192.168.1.70:13567 \
-e WSREP_CLUSTER_ADDRESS=gcomm://192.168.1.70:11567,192.168.1.70:12567,192.168.1.70:13567 \
-e WSREP_CLUSTER_NAME=KMCF_YZJ \
-e MYSQL_ROOT_PASSWORD=hhgznlzq \
-v /kmcf/data/node13:/var/lib/mysql:Z \

panubo/mariadb-galera:latest mysqld

docker exec -ti node11 mysql -p -e 'show status like "wsrep_cluster_size"'
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 1 |

+--------------------+-------+

What am I wrong ?

mastercatz
a year ago

docker run -d --net host --name galera-garbd -e WSREP_CLUSTER_ADDRESS=firstnodeadress.bounceme.net:4567 -e WSREP_CLUSTER_NAME=aio_cluster -p 3306:3306 -p 4567:4567/udp -p 4567-4568:4567-4568 -p 4444:4444 panubo/mariadb-galera garbd

Container: b705d1721ccb
42016-11-17T06:35:37.241594299Z >> Configuring Garbd
g2016-11-17T06:35:37.275175131Z 2016-11-17 06:35:37.274 INFO: CRC-32C: using "slicing-by-8" algorithm.
L2016-11-17T06:35:37.275312350Z 2016-11-17 06:35:37.274 INFO: Read config:
+2016-11-17T06:35:37.275410908Z daemon: 0
A2016-11-17T06:35:37.275448863Z name: serveradress.eu
J2016-11-17T06:35:37.275482948Z address: firstnodeadress.bounceme.net:4567
52016-11-17T06:35:37.275516831Z group: aio_cluster
12016-11-17T06:35:37.275550811Z sst: trivial
2016-11-17T06:35:37.275585312Z donor:
j2016-11-17T06:35:37.275648552Z options: gcs.fc_limit=9999999; gcs.fc_factor=1.0; gcs.fc_master_slave=yes

2016-11-17T06:35:37.275688865Z cfg:
*2016-11-17T06:35:37.275754782Z log:
 2016-11-17T06:35:37.275786996Z
2016-11-17T06:35:37.277500468Z 2016-11-17 06:35:37.277 ERROR: gcs/src/gcs_backend.cpp:gcs_backend_init():102: Invalid backend URI: firstnodeadress.bounceme.net:4567
2016-11-17T06:35:37.277595926Z 2016-11-17 06:35:37.277 ERROR: gcs/src/gcs_core.cpp:gcs_core_open():215: Failed to initialize backend using 'firstnodeadress .bounceme.net:4567': -22 (Invalid argument)
2016-11-17T06:35:37.277794227Z 2016-11-17 06:35:37.277 ERROR: gcs/src/gcs.cpp:gcs_open():1380: Failed to open channel 'aio_cluster' at 'firstnodeadress .bounceme.net:4567': -22 (Invalid argument)
2016-11-17T06:35:37.277969607Z 2016-11-17 06:35:37.277 FATAL: Exception in creating receive loop: Failed to open connection to group: 22 (Invalid argument)
?2016-11-17T06:35:37.278015177Z at garb/garb_gcs.cpp:Gcs():35

mastercatz
a year ago

a bit confused

Running Garbd
Garbd is available. Just specify garbd as the command.

docker run -d --net host --name galera-garbd \
-e WSREP_CLUSTER_ADDRESS=$WSREP_CLUSTER_ADDRESS \
panubo/mariadb-galera \
garbd

which one of these do I change ? assuming the ones with $

WSREP_CLUSTER_ADDRESS=$WSREP_CLUSTER_ADDRESS

or better yet an example using IP's or DNS

not having much luck getting this to connect to get a 2 node system running