-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDEV-25855 Added support for Galera replication with cluster auto bootstrapping #377
base: master
Are you sure you want to change the base?
Conversation
@janlindstrom do you think you can review this, please? |
I must say I do not know much about docker but changes do look reasonable. |
Thanks @janlindstrom. @tymonx sorry I've been so slow, I am progressing. I've been podman{,-compose} testing being a userspace only limits some for the things like unique IP addresses per node (probably will have a way eventually), and I've been reacquainting myself with galera and compose to ensure that its the right design. I'm pretty happy so far. Just been composing test cases. Success:
Not Yet (to be fixed eventually):
What was the rational behind the order in: |
Hi @tymonx! Thank you for doing this! We are currently evaluating bitnami/mariadb-galera, but we are seeing quite a lot of bugs. Some of these bugs happen because this image is not designed for host-networking Please make sure that your PR also works in these cases. Also, you may want to provide an option to force a container into bootstrap mode. When the whole cluster crashes, it may happen that no node is But after thinking about this for a minute, this is probably not necessary here, because the user could just pass |
It would be nice if you could provide a way to force a node into bootstrap mode just once. In case of a cluster crash, I want a node to force-bootstrap just once to repair the cluster. But when I do Edit: I have no idea how this could be archived... |
@ChristianCiach thanks for your interest and describing the requirements/use cases. The number of variants is what is taking this so long to review. While the aim is not to be comprehensive on the first functionality I do aim to use an implementation that needs will be stable. Yes I'm going to consider this bootstrap first, and then recovery as the next step. |
Bitnami's |
I'm back :)
Fixed. I have also added line for striping cluster addresses options # it removes URI schemes like gcomm://
address="${address#[[:graph:]]*://}"
# it removes port suffix per address
address="${address/:[0-9]*//}"
# it removes options suffix ?option1=value1[&option2=value2]
address="${address%\?[[:graph:]]*}"
I have just randomly hitting on my keyboard. No specific reasons. I have already changed order, first hostnames. I have added new changes after some intense testing on various environments, Docker Compose, Docker Swarm, QEMU, Fedora CoreOS, with/without virtualization or physical machines.
Reasons:
To Do:
|
To be honest, I don't fully trust your ip/hostname detection logic. There are too many "but what if"s. For example, what happens if the machine has multiple network devices and the container is deployed using "host networking"? Also, I've seen many environments where dns reverse lookup is just not possible. I would like to be able to explicitly define the node address of the current container. For example, if |
@ChristianCiach no problem, I can add a comparison with the It depends on user needs. For example |
Yes, of course, I agree with you :) It is not always possible to have different configurations for each node. For example, if you want to scale your cluster up/down dynamically (for example using Docker Swarm services or Kubernetes StatefulSet), then it is very hard or even impossible to set I think it would be awesome if you could at least look at Again, thank you so much for doing this. It already looks very promising!. |
Sure. It is very reasonable to do that. I was thinking about the same. |
@ChristianCiach I have already added support for the When someone will provide the |
Just to share some rough stuff I've been looking at (that covers other galera options) and needing to reread the above:
As a crude hack with:
Is there a point at which the autobootstrap is (always?) applied if you are actually starting from an empty datadir? Anything else is recovery. Should non-first nodes not initialize with /docker-entrypoint-initdb.d/ (and rely on galera sst)? |
Docker Daemon (I don't know about Podman) always creates a volume for container. If container stops and starts again (including restarting), files are still present. Bootstrapping will not fire. I have also tested and confirmed that graceful shutdown I'm looking into more proper solution to handle this. |
For Podman I cannot simple strip port numbers from |
Working Podman example script to start N containers in db pod for commit 45149e2: #!/usr/bin/env sh
NODES="${1:-3}"
options="--add-host db_node_1:127.0.0.1"
address="db_node_1:4567"
for i in $(seq 2 "${NODES}"); do
options="${options} --add-host db_node_$i:127.0.0.1"
address="${address},db_node_$i:$(( 4567 + ( $i - 1 ) * 10 ))"
done
podman pod stop db
podman pod rm db
podman pod create --name=db --share net
for i in $(seq 1 "${NODES}"); do
podman create \
--pod=db \
--name=db_node_$i \
--security-opt label=disable \
--env MARIADB_ROOT_PASSWORD=example \
--restart always \
${options:+${options}} \
mariadb:dev \
--port $(( 3305 + $i )) \
--wsrep_cluster_address="gcomm://${address}" \
--wsrep-node-address="db_node_$i:$(( 4567 + ( $i - 1 ) * 10 ))" \
--wsrep-on=on \
--wsrep-provider=/usr/lib/libgalera_smm.so \
--binlog_format=row
done
podman pod start db View logs:
Output:
|
Added support for the For Docker Compose users after |
84b089e
to
5fbf4c6
Compare
I've based and squashed the commits up. Shell check changed a few things. As a basic bootstrap its ok. I'm still looking at what crash recovery would look like. Probably need to make our own state transition diagram. https://galeracluster.com/library/documentation/crash-recovery.html |
This patch add support for Galera replication. Features: - It detects if Galera replication was enabled wsrep_on=ON - By default it enables cluster auto bootstrap feature - By default the first cluster node is used for cluster auto bootstrapping based on the wsrep_cluster_address parameter or by setting the `WSREP_CLUSTER_ADDRESS` environment variable - cluster auto bootstrap feature can be disabled by setting the `WSREP_SKIP_AUTO_BOOTSTRAP` environment variable - use the `WSREP_AUTO_BOOTSTRAP_ADDRESS` environment variable to explicitly choice other node for cluster bootstrapping - cluster node hostnames or IP addresses must be valid to enable cluster auto bootstrapping How to use it. 1. Prepare MariaDB configuration file `galera.cnf`: ```plaintext [galera] wsrep_on = ON wsrep_sst_method = mariabackup wsrep_provider = /usr/lib/libgalera_smm.so binlog_format = row default_storage_engine = InnoDB innodb_doublewrite = 1 innodb_autoinc_lock_mode = 2 ``` 2. Make it read-only: ```plaintext chmod 444 galera.cnf ``` 3. Prepare Docker Compose file `docker-compose.yml`: ```yaml services: node: image: mariadb restart: always security_opt: - label=disable environment: WSREP_CLUSTER_ADDRESS: "${WSREP_CLUSTER_ADDRESS:-}" MARIADB_ROOT_PASSWORD: example volumes: - ./galera.cnf:/etc/mysql/conf.d/10-galera.cnf:ro command: - --wsrep-cluster-address=gcomm://db_node_1,db_node_2,db_node_3 deploy: replicas: 3 ``` 4. Start Docker Compose: ```plaintext docker-compose --project-name db up ``` To start N MariaDB instances using environment variable: ```plaintext WSREP_CLUSTER_ADDRESS="gcomm://db_node_1,db_node_2,db_node_3,db_node_4,db_node_5" docker-compose --project-name db up --scale node="$(echo "${WSREP_CLUSTER_ADDRESS}" | tr ',' ' ' | wc -w)" ``` To start N MariaDB instances using MariaDB configuration file: ```plaintext docker-compose --project-name db up --scale node="$(grep -i wsrep_cluster_address <name>.cnf | tr -d ' ' | tr ',' ' ' | wc -w)" ``` Closes: MariaDB#28
5fbf4c6
to
38bebe0
Compare
@ChristianCiach et all. I welcome any summary of the test cases needed. MDEV-25855 (preferred) or here. I have looked though the bitnami galera issue referenced above, and the blog from which I'll derive some cases too. |
Hello, any news with this PR ? |
This patch add support for Galera replication. It fixes #28 Support Galera Replication.
Features:
mysql
configuration files or provided
mysqld
command line argumentsbased on the wsrep_cluster_address parameter from
mysql
configuration files,
mysqld
command line arguments or by setting theWSREP_CLUSTER_ADDRESS
environment variableWSREP_SKIP_AUTO_BOOTSTRAP
environment variableWSREP_AUTO_BOOTSTRAP_ADDRESS
environment variable to explicitlychoice other node for cluster bootstrapping
auto bootstrapping
How to use it.
mysql
configuration filegalera.cnf
:Warning: World-writable config file
):docker-compose.yml
:To start N MariaDB instances using environment variable:
To start N MariaDB instances using
mysql
configuration file:To start N MariaDB instances using POSIX script helper:
Example usage: