Custom mysql docker image with replication enabled
654
A custom mysql docker image with replication enabled, easy and convenient to set up MySQL master-slave replication in 30 seconds.
The image is based on official mysql-server with replication enabled for the purpose of learning mysql. Note that this image is for people who want to learn and practice MySQL replication in an easy way.
SERVER_ID
Make sure every node has a different server id.
REPLICATION_USER
The user name for replication.
REPLICATION_PASSWORD
The password of replication user.
Download the image
docker pull mottox/mysql-replication
Alternatively, you could also clone this repository and build the image locally.
Run master node with
docker run \
--name master \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-e MYSQL_ROOT_HOST=% \
-e SERVER_ID=1 \
-d mottox/mysql-replication
And then Run slave node with
docker run \
--name slave \
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
-e MYSQL_ROOT_HOST=% \
-e SERVER_ID=2 \
-e REPLICATION_MASTER_HOST=master \
--link master:replication \
-d mottox/mysql-replication
Instead of run the two commands above, you could also copy and use the docker-compose.yml configuration file
and run docker-compose up to set up master-slave replication.
Check if replication is ready
docker exec -it slave mysql -e 'show slave status\G'
The expected Slave_IO_State should be Waiting for master to send event.
Test replication freely
official mysql image
docker-mysql-replication
High Performance MySQL
Content type
Image
Digest
Size
79.7 MB
Last updated
over 9 years ago
docker pull mottox/mysql-replication