Galera meets Docker Network \o/

| Keine Kommentare | Keine TrackBacks

Galera und Docker Network

Using Docker to run Galera on multiple nodes is quite a mess as described here. It is possible but no fun at all. As Docker does NATing every bidirectional setup is complicated.

Starting with Docker Network (version 1.9) you can simply span a Docker owned network (multiple of them) over multiple nodes. These networks are separated as the known bridged network Docker uses by default. It also provides a simple node/container discovery using the --name switch. Feels like a simple DNS.

Let's have a look how easy it is to deploy a Galera cluster. It is not for production. I use my own Docker image. It is just to play around.

There are our nodes:

  • Swarm1 IP=172.17.152.11
  • Swarm2 IP=172.17.152.12
  • Swarm3 IP=172.17.152.13

At the start we still a network. We are going to name it galera.

$ DOCKER_HOST=172.17.152.11:2375 docker network ls --filter "name=galera"
NETWORK ID          NAME                DRIVER

Creating a network is .. easy:

$ DOCKER_HOST=172.17.152.11:2375 docker network create -d overlay galera 
b0cadfa914206c212cce0de611d500620cd07bcae289841f7dc03c26d19b6e91


$ DOCKER_HOST=172.17.152.11:2375 docker network ls --filter "name=galera"
NETWORK ID          NAME                DRIVER
b0cadfa91420        galera              overlay

Every other node is part of this network too:

$ DOCKER_HOST=172.17.152.12:2375 docker network ls --filter "name=galera"
NETWORK ID          NAME                DRIVER
b0cadfa91420        galera              overlay             

$ DOCKER_HOST=172.17.152.13:2375 docker network ls --filter "name=galera"
NETWORK ID          NAME                DRIVER
b0cadfa91420        galera              overlay

So let's bootstrap a Galera Cluster. Remind the --net switch also. As you see we use the hostname to connect the cluster :)

$ DOCKER_HOST=172.17.152.11:2375 docker run -d --name galera1 \
  --net galera erkules/galera:basic --wsrep-cluster-address=gcomm://
d3410d308171df5a3ef2da3b37a7d11ea6479dc8550eea24447d488cbf490a0d

$ DOCKER_HOST=172.17.152.12:2375 docker run -d --name galera2 \
  --net galera  erkules/galera:basic --wsrep-cluster-address=gcomm://galera1
24d4a2dfe3e2ba6914c83c92f814116ff72d5de8daba8304fe89ed3661f57270

$ DOCKER_HOST=172.17.152.13:2375 docker run -d --name galera3 \
 --net galera  erkules/galera:basic --wsrep-cluster-address=gcomm://galera1
751f4f071359495a28e31bc996b62c2042283ee08df0194b7871402e2f851e06

Let's see if everything went fine:

$ DOCKER_HOST=172.17.152.13:2375 docker exec -ti galera3 \
  mysql -e 'show status like "wsrep_cluster_size"' 
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 3     |
+--------------------+-------+

This is a quite simple and insecure example. Docker Network will change also the way we build simple MySQL replication setups. If you used to use --links. Get rid of it. As they are deprecated already in favor of Docker Network. Next time we are going to use Docker Swarm (on top of Docker Network) to deploy a Galera Cluster.

Viel Spaß :)

Erkan

Keine TrackBacks

TrackBack-URL: http://linsenraum.de/mt/mt-tb.cgi/384

Jetzt kommentieren