drbdmanage has been replaced by LINSTOR.
You find more information about LINSTOR:
Thank you and have a fun read!
Nowadays, Docker has support for plugins; for LINBIT, volume plugins are certainly the most interesting feature. Volume plugins open the way for storing content residing in usual Docker volumes on DRBD backed storage.
In this blog post we show a simple example of using our new Docker volume plugin to create a WordPress powered blog with a MariaDB database, where both the content of the blog and the database is replicated among two cluster nodes.
The advantage of this setup is that there are multiple copies of your important data and that switching hosts that run the blog service is a breeze because other nodes in the cluster have instant access to the replicated data.
For the rest of this blog entry we assume two nodes with recent versions of Docker, DRBD9, and DRBD Manage.
For the sake of simplicity we use two nodes based on Ubuntu Xenial, called alpha and bravo.
The first step is to install the required software on both nodes:
# sudo su - $ add-apt-repository ppa:linbit/linbit-drbd9-stack $ apt update $ apt install -y docker.io docker-compose $ apt install -y drbd-dkms drbd-utils \ python-drbdmanage drbdmanage-docker-volume
Before we continue, let’s check if docker works:
docker run -it --rm alpine:latest /bin/echo It works
(Setting up a drbdmanage cluster is documented here, we assume that alpha and bravo are already added to the cluster and that creating resources on a DRBD Manage level works as expected. This then looks as follows:) drbdmanage has been replaced by LINSTOR.
The Docker plugin for DRBD Manage is not enabled by default, so let’s do that on both nodes:
$ systemctl enable docker-drbdmanage-plugin.socket $ systemctl start docker-drbdmanage-plugin.socket
Let’s create our first docker volume that is backed by DRBD:
$ docker volume create -d drbdmanage --name=first --opt size=20 $ docker volume ls DRIVER VOLUME NAME drbdmanage first $ docker volume rm first
For our blog service we create two Docker volumes: one for the WordPress content and one for the database. In this case we choose xfs as the file system and make the volumes 300MB in size. The volume driver has some other interesting options, like specifying additional file system options or a replica count for the number of redundant copies in the cluster (
man drbdmanage-docker-volume). The MariaDB container is a bit picky about the size, so don’t make that volume too small, or the container does not start:
$ docker volume create -d drbdmanage \ --name=bloghtml --opt fs=xfs --opt size=300 $ docker volume create -d drbdmanage \ --name=blogdb --opt fs=xfs --opt size=300 $ docker volume ls DRIVER VOLUME NAME drbdmanage blogdb drbdmanage bloghtml
After that, we create a yaml configuration for our blog service on both nodes:
$ mkdir ~/ha-blog && cd ~/ha-blog
Create a file with the name
docker-compose.yml and the following content:
wordpress: image: wordpress links: - db:mysql ports: - 8080:80 volume_driver: drbdmanage volumes: - bloghtml:/var/www/html db: image: mariadb environment: MYSQL_ROOT_PASSWORD: mysecretpwd volume_driver: drbdmanage volumes: - blogdb:/var/lib/mysql
And now it is time to start our blog. For this demonstration we will just start the blog interactively; in a real world scenario one would write a systemd service file that automates the following manual steps.
Wait until the two containers are started up:
Open a browser and connect to
http://alpha:8080. Do the initial WordPress setup and modify the initial post.
When you are satisfied, we can now migrate our blog from node alpha to node bravo.
ctrl-c in alpha‘s terminal where
docker-compose is still running. Being nice Docker citizens, we remove the now unused containers:
Now we switch to bravo and execute:
$ cd ~/ha-blog $ docker-compose up
Now point your browser to bravo‘s IP on port 8080 and you will see the content you created on alpha before the migration.
Please note that this demonstrates the capabilities of our Docker volume plugin for DRBD Manage, but is in no way a Tech-Guide on how to run a highly available WordPress blog. This would require further configuration, like floating IPs and/or DNS updates, and a cluster manager that starts/stops/monitors the required containers.
Still – for five minutes work, a nice result!