MySQL with Group Replication
This is a labs release of MySQL featuring the upcoming Group Replication plugin for MySQL Server, created and maintained by the MySQL team at Oracle.
The Group Replication server plugin introduces a new way of replicating your data with MySQL. Using a multi-master update everywhere technique based on group communication, we're now able to improve on the traditional MySQL replication adding several new features. Some of the features group replication brings to MySQL include:
- Removing the need for manually handling server failover
- Automatic group reconfiguration (handling of failures, crashes, reconnects)
- Providing distributed fault tolerance and the basis for a highly available distributed database system
For a more detailed overview, head over to the MySQL HA blog, and for some more background on this Docker image, visit http://mysqlrelease.com/2016/08/mysql-group-replication-docker-images/
The Group Replication plugin is currently in beta, and shouldn't be used in production at this stage. This Docker image is meant to preview upcoming features.
Setting up the replication group
This image makes setting up Group Replication quite easy. In the following example, we'll set up a replication group consisting of three MySQL Docker containers named node1–3.
The Group Replication plugin requires the group members to be on the same network subnet, so we start off by creating a Docker network named
group1 that we will have our containers connect to:
docker network create group1
The next step is to set up and add members to our replication group, taking care to set a unique replication ID for each member by using the
server-id option. In our Docker image,
server-id=1 is special. On first startup, this particular MySQL server instance will be put in a mode where it will serve group configuration information to the other servers that subsequently join the replication group, effectively providing a bootstrap service to the group.
docker run -d --name=node1 --net=group1 -e MYSQL_ROOT_PASSWORD=aTestPwd -e MYSQL_REPLICATION_USER=rpl_user -e MYSQL_REPLICATION_PASSWORD=rpl_pass mysql/mysql-gr --group_replication_group_seeds='node2:6606,node3:6606' --server-id=1
This will set up a separate user account for replication, as specified by the
MYSQL_REPLICATION_PASSWORD environment variables. Do note that these are insecure credentials: please refer to the section on Secure Container Startup in the main MySQL Docker image documentation for secure alternatives.
We now proceed to start the two remaining nodes, adjusting the node names, server IDs and seed options accordingly:
docker run -d --name=node2 --net=group1 -e MYSQL_ROOT_PASSWORD=aTestPwd -e MYSQL_REPLICATION_USER=rpl_user -e MYSQL_REPLICATION_PASSWORD=rpl_pass mysql/mysql-gr --group_replication_group_seeds='node1:6606,node3:6606' --server-id=2
docker run -d --name=node3 --net=group1 -e MYSQL_ROOT_PASSWORD=aTestPwd -e MYSQL_REPLICATION_USER=rpl_user -e MYSQL_REPLICATION_PASSWORD=rpl_pass mysql/mysql-gr --group_replication_group_seeds='node1:6606,node2:6606' --server-id=3
You should now have a running replication group consisting of three MySQL instances.
Supported Docker Versions
These images were created and tested on Docker version 1.12. Support for older versions is provided on a best-effort basis, but we strongly recommend running on the most recent version, since that is assumed for parts of the documentation above.
We welcome your feedback! For general comments or discussion, please drop us a line in the Comments section below. For bugs and issues, please submit a bug report at http://bugs.mysql.com under the category "MySQL Package Repos and Docker Images".