Member-only story
Setting up MySQL Group Replication With Docker Images
Step-by-Step Guide to Implementing MySQL Group Replication Using Docker Images
MySQL Group Replication (GR) is a MySQL Server plugin that enables you to create elastic, highly-available, fault-tolerant replication topologies. Groups can operate in a single-primary mode with automatic primary election, where only one server accepts updates at a time. Alternatively, groups can be deployed in multi-primary mode, where all servers can accept updates, even if they are issued concurrently.
Docker is an open source framework that automates deployment and provisioning, and simplifies distribution of applications in lightweight and portable containers. These containers can be executed in a wide variety of places including your laptop, the cloud, or a virtual machine (VM).
In this blog post, we show how to combine these two technologies by setting up GR using Docker containers running a MySQL image. We will also demonstrate how to use Docker commands to emulate GR fault scenarios like disconnecting a group member from the network and crashing one of the group members.
Overview
We start by downloading the MySQL 8 image from Docker Hub (hub.docker.com/r/mysql/mysql-server/), then we are going to create a Docker network named groupnet and finally setup a Multi-Primary GR topology with 3 group members in different containers. The steps that follow assume that you have Docker installed on your system and know its basic commands.
Pulling MySQL Sever Image
In this example, we are going to use mysql/mysql-server:8.0:
$ docker pull mysql/mysql-server:8.0
If you prefer to use another version, the general command to download the MySQL Community Edition image is:
$ docker pull mysql/mysql-server:<tag>
where <tag> is the server version you’re targeting. If :<tag> is omitted, the latest tag is used, and the image for the latest GA version of MySQL Server is downloaded.