Skip to content

Instantly share code, notes, and snippets.

@ProMasoud
Created June 1, 2021 11:07
Show Gist options
  • Save ProMasoud/5faf9bc354b305d310d39aa9132616ce to your computer and use it in GitHub Desktop.
Save ProMasoud/5faf9bc354b305d310d39aa9132616ce to your computer and use it in GitHub Desktop.
Mysql Replication in docker
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
version: '3'
services:
db:
image: mysql:8.0
container_name: db
restart: always
ports:
- $DB_PORT:3306
command:
- --default-authentication-plugin=mysql_native_password
volumes:
- ./master.conf.cnf:/etc/mysql/conf.d/mysql.conf.cnf
- db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_USER: ${DB_USERNAME}
MYSQL_DATABASE: ${DB_DATABASE}
networks:
- internal
adminer:
image: adminer:latest
restart: always
ports:
- "8081:8080"
networks:
- internal
#Docker Networks
networks:
internal:
#Volumes
volumes:
db:
version: '3'
services:
mysql_slave:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_USER: ${DB_USERNAME}
MYSQL_DATABASE: ${DB_DATABASE}
container_name: "mysql_slave"
restart: "always"
ports:
- $MYSQL_PORT:3306
volumes:
- ./slave.conf.cnf:/etc/mysql/conf.d/mysql.conf.cnf
- data:/var/lib/mysql
networks:
- internal
adminer:
image: adminer:latest
restart: always
ports:
- "8080:8080"
networks:
- internal
#Docker Networks
networks:
internal:
#Volumes
volumes:
db:
[mysqld]
server-id = 1
log-bin = mysql-bin-1.log
binlog_format = ROW
binlog_do_db = bit24
tmpdir = /tmp
max_binlog_size = 500M
sync_binlog = 1
expire-logs-days = 3
slow_query_log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment