Skip to content

bxb100/docker-mysql-master-slave

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker MySQL master-slave replication

MySQL 8.0 master-slave replication with using Docker.

Previous version based on MySQL 5.7 is available: in mysql5.7 branch. (see upstream)

Quick Start

make build

Run

To run this examples you will need to start containers with "docker-compose" and after starting setup replication. See commands inside ./build.sh.

Create 3 MySQL containers with master-slaves STATEMENT-based replication1

make build

Make changes to master

make master db=mydb sql="create table code(code int); insert into code values (100), (200)"

Read changes from slave

make slave1 db=mydb sql="select * from code \G"
make slave2 db=mydb sql="select * from code \G"

Troubleshooting

Check Logs

docker-compose logs

Start containers in "normal" mode

Go through "build.sh" and run command step-by-step.

Check running containers

make ps

Clean data dir

make clean

Run command inside "mysql_master"

make master_status

Run command inside "mysql_slave"

make slave1_status
make slave2_status

Enter into "mysql_master"

make master

Enter into "mysql_slave"

make slave1
make slave2

Footnotes

  1. https://dev.mysql.com/doc/refman/8.0/en/replication-formats.html Not using row for this project

About

Docker MySQL master-slaves replication

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 50.2%
  • Makefile 49.8%