A development environment for MaxScale with Docker and Vagrant
Team Host.it 3 min read
Content
Why use docker? It is very fast for local development/testing
It's easy to share Docker images within the team
Containers can also be shared outside the team via the Dockerfile
It guarantees maximum process isolation without having to create a virtual machine for each service
It is the ideal solution for locally testing architectures with multiple hosts interacting via the network
Docker: a platform for managing containers
With Docker you can create, launch and destroy application containers at the speed of light. There are many ready-to-use images released by the community, including that of MaxScale.
For our test we chose to use these three containers:
MaxScale: in beta (Dockerfile)
MariaDB: version 10.0 (Dockerfile)
MySQL: version 5.1 (Dockerfile)
Docker is a winning choice for this type of experimentation: we can create an application container and launch our applications using a simple file called Dockerfile. In a few seconds it is possible to have all the MySQL/MariaDB databases necessary to carry out the tests. From the command line or using docker APIs you can create and destroy containers with MaxScale, MariaDB and MySQL.
To automate the creation of the infrastructure we chose to use Vagrant: an agile system that allows you to create and configure reproducible and portable development infrastructures.
Vagrant: Create development environments quickly
Vagrant is an open source tool for managing development environments through the use of different providers including VirtualBox and Docker. Through the Vagrantfile it is possible to define the system infrastructure and, as already happens in Docker, create and destroy it through very simple command line commands. In our test we chose the Docker Provider to define the containers used and the connections between them.
It is possible to define two types of connections:
volumes-from : to connect the volume to a container dedicated to storage
link : to allow one container to see another
At this point we have created a configuration very similar to the production one consisting of:
A MySQL 5.1 container that corresponds to the database used for Joomla! installations 1.5.x
A MariaDB 10.0 container set as MASTER
A MariaDB 10.0 container set as SLAVE, connected to the MASTER
A MaxScale container that can reach all databases.
The next step involves configuring MaxScale on this infrastructure.
MaxScale: A proxy for MySQL and MariaDB databases
Part of our test was to use MaxScale as a proxy to send traffic to the database with MySQL 5.1 and copy all queries to the MariaDB databases to analyze the traffic and verify correct behavior of the Read/Write Split router.
The container with MySQL 5.1 was used to test the functioning of the MaxScale filter and check the rewrite TYPE in the CREATE TABLE:
Example query accepted in MySQL 5.1:
CREATE TABLE Person (id int, name varchar(255)) TYPE=MyISAM ;
E.g. query from MySQL/MariaDB version 5.5 onwards:
CREATE TABLE Person (id int, name varchar(255)) ENGINE=MyISAM ;
We therefore configured MaxScale in this way:
A Listener listening to /var/lib/mysql/mysql.sock and on port 3306
Router: traffic arriving from the listener is directed to the main router Traffic sent to the MySQL 5.1 server without any modification
The traffic is copied to the Read/Write split router
The Read/Write split router takes care of separating read-only queries from write-only queries. Before sending them to the MariaDB Master/Slave servers, the queries are passed through the CreateTableFilter
The CreateTableFilter that modifies CREATE TABLE queries that contain the TYPE parameter instead of ENGINE
A monitor for each backend server to allow MaxScale to constantly know the situation and status of the replication.
Sharing across multiple development teams
Thanks to Docker and Vagrant it was possible to share a complex infrastructure not only within our development team, but also externally with the MariaDB MaxScale team.
In the next article I will explain how it was possible to bring this configuration into production, minimizing the downtime of the machines to a few minutes.
Joomla hosting
Joomla hosting in Italy
Plans with backups, SSL certificates and tools for developers and agencies.
Related articles
From the blog
From the archive