Skip to content

Instantly share code, notes, and snippets.

@ahromis
Last active May 3, 2017 21:37
Show Gist options
  • Save ahromis/eb60a9a173987b0a0e3423fb3e62b6db to your computer and use it in GitHub Desktop.
Save ahromis/eb60a9a173987b0a0e3423fb3e62b6db to your computer and use it in GitHub Desktop.
MySQL HA Sample
version: "3"
services:
mysql1:
image: mysql/mysql-gr:latest
command: --group-replication-group-seeds='mysql2:6606,mysql3:6606' --server-id=1
environment:
MYSQL_ROOT_PASSWORD: aTestPwd
MYSQL_REPLICATION_USER: rpl_user
MYSQL_REPLICATION_PASSWORD: rpl_pass
volumes:
- mysql1:/var/lib/mysql
networks:
- mysql
ports:
- "14001:3306"
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.hostname == db-worker0]
mysql2:
image: mysql/mysql-gr:latest
command: --group-replication-group-seeds='mysql1:6606,mysql3:6606' --server-id=2
environment:
MYSQL_ROOT_PASSWORD: aTestPwd
MYSQL_REPLICATION_USER: rpl_user
MYSQL_REPLICATION_PASSWORD: rpl_pass
volumes:
- mysql2:/var/lib/mysql
networks:
- mysql
ports:
- "14002:3306"
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.hostname == db-worker1]
mysql3:
image: mysql/mysql-gr:latest
command: --group-replication-group-seeds='mysql1:6606,node2:6606' --server-id=3
environment:
MYSQL_ROOT_PASSWORD: aTestPwd
MYSQL_REPLICATION_USER: rpl_user
MYSQL_REPLICATION_PASSWORD: rpl_pass
volumes:
- mysql3:/var/lib/mysql
networks:
- mysql
ports:
- "14003:3306"
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.hostname == db-worker2]
volumes:
mysql1:
driver: local
mysql2:
driver: local
mysql2:
driver: local
networks:
mysql:
driver: overlay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment