-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql-replica.yml
101 lines (100 loc) · 3.48 KB
/
mysql-replica.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# https://hub.docker.com/r/bitnami/mysql
services:
mysql-replica-master:
image: ${MYSQL_IMAGE}
container_name: mysql-replica-master
restart: on-failure
environment:
- TZ=Asia/Shanghai
- MYSQL_CHARACTER_SET
- MYSQL_COLLATE
- MYSQL_ROOT_PASSWORD
- MYSQL_AUTHENTICATION_PLUGIN
- MYSQL_REPLICATION_MODE=master
- MYSQL_REPLICATION_USER=root
- MYSQL_REPLICATION_PASSWORD=${MYSQL_ROOT_PASSWORD}
volumes:
- ${MYSQL_REPLICA_HOME}/master/data:/bitnami/mysql/data
- ${MYSQL_REPLICA_HOME}/master/initdb.d:/docker-entrypoint-initdb.d
- ${MYSQL_REPLICA_HOME}/master/conf/my_custom.cnf:/opt/bitnami/mysql/conf/my_custom.cnf:ro
networks:
- mysql_replica
ports:
- ${MYSQL_REPLICA_MASTER_PORT_3306}:3306
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD
mysql-replica-slave-1:
image: ${MYSQL_IMAGE}
container_name: mysql-replica-slave-1
restart: on-failure
environment:
- TZ=Asia/Shanghai
- MYSQL_CHARACTER_SET
- MYSQL_COLLATE
- MYSQL_ROOT_PASSWORD
- MYSQL_AUTHENTICATION_PLUGIN
- MYSQL_REPLICATION_MODE=slave
- MYSQL_REPLICATION_USER=root
- MYSQL_REPLICATION_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_MASTER_HOST=mysql-replica-master
- MYSQL_MASTER_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
volumes:
- ${MYSQL_REPLICA_HOME}/slave-1/data:/bitnami/mysql/data
- ${MYSQL_REPLICA_HOME}/slave-1/conf/my_custom.cnf:/opt/bitnami/mysql/conf/my_custom.cnf:ro
networks:
- mysql_replica
ports:
- ${MYSQL_REPLICA_SLAVE1_PORT_3306}:3306
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD
mysql-replica-slave-2:
image: ${MYSQL_IMAGE}
container_name: mysql-replica-slave-2
restart: on-failure
environment:
- TZ=Asia/Shanghai
- MYSQL_CHARACTER_SET
- MYSQL_COLLATE
- MYSQL_ROOT_PASSWORD
- MYSQL_AUTHENTICATION_PLUGIN
- MYSQL_REPLICATION_MODE=slave
- MYSQL_REPLICATION_USER=root
- MYSQL_REPLICATION_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_MASTER_HOST=mysql-replica-master
- MYSQL_MASTER_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
volumes:
- ${MYSQL_REPLICA_HOME}/slave-2/data:/bitnami/mysql/data
- ${MYSQL_REPLICA_HOME}/slave-2/conf/my_custom.cnf:/opt/bitnami/mysql/conf/my_custom.cnf:ro
networks:
- mysql_replica
ports:
- ${MYSQL_REPLICA_SLAVE2_PORT_3306}:3306
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD
mysql-replica-slave-3:
image: ${MYSQL_IMAGE}
container_name: mysql-replica-slave-3
restart: on-failure
environment:
- TZ=Asia/Shanghai
- MYSQL_CHARACTER_SET
- MYSQL_COLLATE
- MYSQL_ROOT_PASSWORD
- MYSQL_AUTHENTICATION_PLUGIN
- MYSQL_REPLICATION_MODE=slave
- MYSQL_REPLICATION_USER=root
- MYSQL_REPLICATION_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_MASTER_HOST=mysql-replica-master
- MYSQL_MASTER_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
volumes:
- ${MYSQL_REPLICA_HOME}/slave-3/data:/bitnami/mysql/data
- ${MYSQL_REPLICA_HOME}/slave-3/conf/my_custom.cnf:/opt/bitnami/mysql/conf/my_custom.cnf:ro
networks:
- mysql_replica
ports:
- ${MYSQL_REPLICA_SLAVE3_PORT_3306}:3306
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD
networks:
mysql_replica:
driver: bridge