There had been already a couple of blogposts about Docker and Galera in the MySQL community. I've got to confess I love both. But on the other hand I don't think this is a good combination at all. Having a look at the blogpost doing galera with docker Im still not confessed. Im going to tell some points why I think so.
I assume Galera is already well know in the MySQL community :)
Docker is not just another technique to virtualize
Docker is more than just being another way to virtualize. And this may be one of the biggest points I miss with the other blogposts.
What is the purpose of Docker?
With Docker you build applicationcontainers. So you have a container just running one application. The overhead of containers compared to hypervisor technologies like KVM, VMWare etc. is much slower. But instead running a full OS in a container, you just run on application. This was first seen with LXC btw. But Docker is much more.
Some points (and yes we are missing a lot of important points)
Build your Images via Dockerfile
Don't configure your running container
If you want to upgrade a container. Build a new image.
There is a lot more. But this is sufficient for a basic 'rant'
This post is some way of doing the holy grail for docker :)
Think about an applicationcontainer as a binary you run on your system. You don't do ssh to your mysql binary and so you don't do to your MySQL applicationcontaine.
Even applicationcontainer get there own IP. You shall not use them. They are not accessible from outside the host and they ere likely to change if you restart a container.
Docker advises you to do port mapping. Thats where you map the port of your application(container) to one port on the host. This will work on every host instead of relying on an IP.
Just think about Managing Ports. Remember you need to manage at least 4 ports per node (3x) to do it right. Using IPs just
Configuring and deploying docker reminds of the old Golden Image era. You upgrade an Container by starting from an upgraded Images and not by upgrading the container. Images are build via Dockerfiles, some kind of makefiles for images. Besides having fully configured images you can build images reading env or options when starting.
In the end you start your container and after that you don't connect and configure them. Thats the point. Thats what happened in the blogposts. Also Dockerfiles had been used. But they had been used in a half hearted way. Afaik there was some basic installation but still they need to access the container (attach, ssh, ansible) and configure the container. This is not the holy grail of Docker.
So at least they got a running Galera Cluster
Yes indeed and lets talk about Galera configuration. Let's only talk about Docker.
Let's summarize some fails.
- The Galera Cluster is build while the containers are running.
- The Galera Cluster depends on local IPs. IPs you gonna loose if one container restarts. For sure this setup is for playing testing only.
- As the Installation depends on local IPs. They all run on one host. Most unlikely you want to run you Galera Cluster on one node in production.
- Remember your datadir is on Aufs. Fine for tests indeed.
Is it that bad?
As long as you do it for testing and playing around it is fine. But when you want to go into production,, you got to rethink your setup.
I wonder why the blogger didn't used LXC in first place. In the end they used Docker like (virtual) stand alone nodes. For that LXC would be the right fit. And working for Galera. (Even not hipster at all)
With LXC you have.
- Fixed IPs
- Able to communicate via network using that IP. (Multi host deployment)
- Run datadir on your prefered filesystem
So is there a Happy End for Docker and Galera
Of course you can do it. But lets have a look at the ports. There are two way to manage the ports:
- Do a 1:1 mapping of the container ports to the host. 3306 -> 3306 etc.
But this would not scale at all.
- Do your portmanagement on your own
So you got to take care of 12 Ports for a 3-node Galera Cluster. If you want to do it you should also be sure to know following Galera options:
wsrep_sst_receive_address gmcast.listen_addr ist.recv_addr
You also got to think about Volumemanagement.
On the other hand thats the benefit of Galera. Upgraded Nodes will do an SST. The old data is gone with the old container and using Docker for small/mid sized Installations this could even work.
In the end everyone can use Docker the way he wants to. But then you are not hipster:)
Btw: Maybe service discovery for the rescue?! Let's see if Ive got some time to investigate it and present the holy grail of Docker and Galera \o/