colinmollenhour / mariadb-galera-swarm

MariaDb Galera Cluster container based on official mariadb image which can auto-bootstrap and recover cluster state.
https://hub.docker.com/r/colinmollenhour/mariadb-galera-swarm
Apache License 2.0
223 stars 102 forks source link

Add a script to wait for seed #81

Closed alphaDev23 closed 5 years ago

alphaDev23 commented 5 years ago

The following is a feature request so that the number of deployed nodes can be predefined (rather than 0) leaving the user to just remove the seed after all nodes are healthy. In clusters with multiple services, this will simplify operations. The following has been tested and appears to work without issue.

A similar method may be implemented on the seed to verify that the nodes are healthy and then automatically exit. This would eliminate the need for any manual intervention when bringing up the galera cluster.

A simple script, such as wait-for-it.sh (https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh), can be added to the image. From start.sh, the code to call it can be as simple as the following (IS_SEED determined from the CMD or explicitly and MYSQL_SEED determined from the service or explicitly):

if [ "$IS_SEED" != "true" ]; then /tmp/wait-for-it.sh $MYSQL_SEED:3306 -t 0 -s fi

colinmollenhour commented 5 years ago

Can you provide a more specific example regarding how this was tested? I'm failing to understand the exact usage vs just setting the /var/lib/mysql/new-cluster flag, for example.

alphaDev23 commented 5 years ago

The current steps per your example are as follows: $ docker service ls (wait for galera_seed to be healthy) $ docker service scale galera_node=2 (wait for both galera_node instances to be healthy) $ docker service scale galera_seed=0 $ docker service scale galera_node=3

The suggestion would only require the following after nodes are healthy: $ docker service scale galera_seed=0

alphaDev23 commented 5 years ago

Closed in favor of #84