Running Percona XtraDB Cluster in a Docker Container¶
Docker images of Percona XtraDB Cluster are hosted publicly on Docker Hub at https://hub.docker.com/r/percona/percona-xtradb-cluster/.
For more information about using Docker, see the Docker Docs.
Note
Make sure that you are using the latest version of Docker.
The ones provided via apt
and yum
may be outdated and cause errors.
Note
By default, Docker will pull the image from Docker Hub if it is not available locally.
The following procedure describes how to set up a simple 3-node cluster for evaluation and testing purposes, with all nodes running Percona XtraDB Cluster 5.6 in separate containers on one host:
Create a Docker network:
docker network create pxc-network
Bootstrap the cluster (create the first node):
docker run -d \ -e MYSQL_ROOT_PASSWORD=root \ -e CLUSTER_NAME=cluster1 \ --name=node1 \ --net=pxc-network \ percona/percona-xtradb-cluster:5.6
Join the second node:
docker run -d \ -e MYSQL_ROOT_PASSWORD=root \ -e CLUSTER_NAME=cluster1 \ -e CLUSTER_JOIN=node1 \ --name=node2 \ --net=pxc-network \ percona/percona-xtradb-cluster:5.6
Join the third node:
docker run -d \ -e MYSQL_ROOT_PASSWORD=root \ -e CLUSTER_NAME=cluster1 \ -e CLUSTER_JOIN=node1 \ --name=node3 \ --net=pxc-network \ percona/percona-xtradb-cluster:5.6
To ensure that the cluster is running:
Access the MySQL client. For example, on the first node:
$ sudo docker exec -it node1 /usr/bin/mysql -uroot -proot Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.6.37-82.2-56 Percona XtraDB Cluster (GPL), Release rel82.2, Revision f3ba0dd, WSREP version 26.21, wsrep_26.21 Copyright (c) 2009-2017 Percona LLC and/or its affiliates Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql@node1>
View the wsrep status variables:
mysql@node1> show status like 'wsrep%'; +------------------------------+-------------------------------------------------+ | Variable_name | Value | +------------------------------+-------------------------------------------------+ | wsrep_local_state_uuid | 625318e2-9e1c-11e7-9d07-aee70d98d8ac | ... | wsrep_local_state_comment | Synced | ... | wsrep_incoming_addresses | 172.18.0.2:3306,172.18.0.3:3306,172.18.0.4:3306 | ... | wsrep_cluster_conf_id | 3 | | wsrep_cluster_size | 3 | | wsrep_cluster_state_uuid | 625318e2-9e1c-11e7-9d07-aee70d98d8ac | | wsrep_cluster_status | Primary | | wsrep_connected | ON | ... | wsrep_ready | ON | +------------------------------+-------------------------------------------------+ 59 rows in set (0.02 sec)
Contact Us
For free technical help, visit the Percona Community Forum.To report bugs or submit feature requests, open a JIRA ticket.
For paid support and managed or professional services, contact Percona Sales.