Last active
April 14, 2017 08:42
-
-
Save ball6847/25ba64edc8de9d2e5ccef1af2f24dfad to your computer and use it in GitHub Desktop.
Create mariadb cluster using Docker Swarm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# first, create overlay network to make all of your nodes can to talk to each others. | |
docker network create -d overlay mariadb-network | |
# then, create primary node, make sure you create the service with only 1 replica | |
docker service create \ | |
--name mariadb-master \ | |
--replicas 1 \ | |
--mount target=/var/lib/mysql,source=/vol/mariadb-master,type=bind \ | |
--network mariadb-network \ | |
-e MYSQL_ROOT_PASSWORD=rootpassword \ | |
-e MYSQL_REPLICATION_PASSWORD=replicationpassword \ | |
-e MYSQL_CLUSTER_ADDRESS= \ | |
ball6847/mariadb-cluster | |
# now, your mariadb farm, (set --publish port if needed) | |
docker service create \ | |
--name mariadb \ | |
--replicas 1 \ | |
--mount target=/var/lib/mysql,source=/vol/mariadb,type=bind \ | |
--network mariadb-network \ | |
-e MYSQL_ROOT_PASSWORD=rootpassword \ | |
-e MYSQL_REPLICATION_PASSWORD=replicationpassword \ | |
-e MYSQL_CLUSTER_ADDRESS=mariadb-master \ | |
ball6847/mariadb-cluster | |
# finally, you can scale your farm as you wish, but make sure it run one container per node. | |
docker service scale mariadb=2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment