Skip to content

Simple MySQL master-slave replication with docker-compose for development.

Notifications You must be signed in to change notification settings

raahii/docker-mysql-master-slave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker mysql master slave replication

Simple MySQL master-slave replication with docker-compose for development.

Setting

  • MySQL 8.0

  • GTID replicatoin

  • 1 master, 1 slave

  • mysql user (both master and slave)

    • user: root
    • password: password
  • database to be replicated: app

Run

docker-compose up -d
    Name                 Command             State                 Ports
--------------------------------------------------------------------------------------
mysql-master   docker-entrypoint.sh mysqld   Up      0.0.0.0:3306->3306/tcp, 33060/tcp
mysql-slave    docker-entrypoint.sh mysqld   Up      0.0.0.0:3307->3306/tcp, 33060/tcp

Test

  • Make changes to master
docker exec mysql-master sh -c "export MYSQL_PWD=password; mysql -u root app -e 'create table code(code int); insert into code values (100), (200)'"  
  • Read changes from slave
docker exec mysql-slave sh -c "export MYSQL_PWD=password; mysql -u root app -e 'select * from code \G'"  

Reference

About

Simple MySQL master-slave replication with docker-compose for development.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published