Like any good, thus lazy, engineer I don’t like to start things manually. Creating directories, configuration files, specify paths, ports via command line is too boring. I wrote already how I survive in case when I need to start MySQL server (here). There is also the MySQL Sandbox which can be used for the same purpose.
But what to do if you want to start Percona XtraDB Cluster this way? Fortunately we, at Percona, have engineers who created automation solution for starting PXC. This solution uses Docker. To explore it you need:
- Clone the
pxc-docker
repository:
git clone https://github.com/percona/pxc-docker
- Install Docker Compose as described here
cd pxc-docker/docker-bld
- Follow instructions from the README file:
a)
./docker-gen.sh 5.6
(docker-gen.sh
takes a PXC branch as argument, 5.6 is default, and it looks for it on github.com/percona/percona-xtradb-cluster)b) Optional:
docker-compose build
(if you see it is not updating with changes).c)
docker-compose scale bootstrap=1 members=2
for a 3 node cluster - Check which ports assigned to containers:
123456$docker port dockerbld_bootstrap_1 33060.0.0.0:32768$docker port dockerbld_members_1 45670.0.0.0:32772$docker port dockerbld_members_2 45680.0.0.0:32776
Now you can connect to MySQL clients as usual:
123456789101112131415$mysql -h 0.0.0.0 -P 32768 -urootWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 10Server version: 5.6.21-70.1 MySQL Community Server (GPL), wsrep_25.8.rXXXXCopyright (c) 2009-2015 Percona LLC and/or its affiliatesCopyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.mysql> - To change MySQL options either pass it as a mount at runtime with something like
volume: /tmp/my.cnf:/etc/my.cnf
indocker-compose.yml
or connect to container’s bash (docker exec -i -t container_name /bin/bash
), then changemy.cnf
and rundocker restart container_name
Notes.
- If you don’t want to build use ready-to-use images
- If you don’t want to run Docker Compose as root user add yourself to
docker
group
Comments (7)
Hi Sveta,
I got error like this:
docker-bld$ docker-machine ssh default
## .
## ## ## ==
## ## ## ## ## ===
/”””””””””””””””””\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| ‘_ \ / _ \ / _ \| __| __) / _
|/ _ \ / __| |/ / _ \ '__|
docker-machine start default`.| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.9.1, build master : cef800b - Fri Nov 20 19:33:59 UTC 2015
Docker version 1.9.1, build a34a1d5
docker@default:~$ ls
log.log
docker@default:~$ ls /
bin/ dev/ etc/ home/ init lib/ lib64 linuxrc mnt/ opt/ proc/ root/ run/ sbin/ sys/ tmp usr/ var/
docker@default:~$ exit
docker-bld$ docker-compose scale bootstrap=1 members=2
WARNING: The RANDOM variable is not set. Defaulting to a blank string.
ERROR: Couldn't connect to Docker daemon - you might need to run
Would you please give some advice here ?
Please ignore previous comment.
Here is the output of
$docker-compose build
WARNING: The RANDOM variable is not set. Defaulting to a blank string.
Building bootstrap
Step 0 : FROM centos:centos7
—> ce20c473cd8a
Step 1 : MAINTAINER Raghavendra Prabhu raghavendra.prabhu@percona.com
—> Using cache
—> 99ffa239711d
Step 2 : RUN curl -s https://github.com/percona/percona-repositories/blob/master/rpm/percona-release.repo > /etc/yum.repos.d/percona-dev.repo
—> Using cache
—> 9633aa93213c
Step 3 : RUN yum install -y http://epel.check-update.co.uk/7/x86_64/e/epel-release-7-5.noarch.rpm
—> Running in a57b46a572a8
Loaded plugins: fastestmirror
File contains no section headers.
file: file:///etc/yum.repos.d/percona-dev.repo, line: 4
‘\n’
ERROR: Service ‘bootstrap’ failed to build: The command ‘/bin/sh -c yum install -y http://epel.check-update.co.uk/7/x86_64/e/epel-release-7-5.noarch.rpm‘ returned a non-zero code: 1
The “http://jenkins.percona.com/dev-repo/percona-dev.repo” in Dockfile is no longer valid, how to fix it ?
Tony, I am sorry for the delay in answer. I contacted with original maintainer of this Docker image asking to check how this issue can be fixed, but he is on travel now and we have to wait a little bit more when he is back. I will update you right after I have news.
First of all, I should note that, could run this only with CentOS 7.
But there were some errors and I want to share workarounds.
Change dev-repo link as it was changed:
http://jenkins.percona.com/yum-repo/percona-dev.repo
New should be similar to:
vim docker-gen.sh
RUN curl -s http://jenkins.percona.com/yum-repo/percona-dev.repo > /etc/yum.repos.d/percona-dev.repo
Also change make command:
from “RUN make -j$numcp” to “RUN make -j 1”
I’ve changed the pxc_strict_mode to permissive in wsrep.cnf and even added it to the node.cnf file to no avail. It persists even if I use mysqld restart –pxc_strict_mode=PERMISSIVE. Any thoughts?
Can you provide all command you use to modify pxc_strict_mode?
Actually, I figured it out. You have to stipulate “configs” secion in the yaml.
configs:
– source: my_config
target: /etc/mysql/my.cnf
uid: ‘1000’
gid: ‘1000’
mode: 0444
– source: wsrep_config
target: /etc/mysql/percona-xtradb-cluster.conf.d/wsrep.cnf
uid: ‘1000’
gid: ‘1000’
mode: 0444
configs:
my_config:
file: /root/backup/mysql/my.cnf
wsrep_config:
file: /root/backup/mysql/percona-xtradb-cluster.conf.d/wsrep.cnf
In the my.cnf just add:
[mysqld]
pxc_strict_mode=PERMISSIVE
I added the wsrep config as well in order to ensure that the strict mode setting located in that file did not override the my.cnf setting.