Building Your Own Private DBaaS with ClusterControl

Krzysztof Ksiazek


As we explained in one of our blogs, DBaaS are powerful tools for the users that require a database for their purposes. This can be a developer that spins up database clusters for their applications, an user that automatically deploys applications in a highly available fashion, including the database cluster for it. The requirement is that the deployment process is fast, automated and unattended.

There are numerous ways you can approach the problem of creating DBaaS service. After all there are many ways in which you can deploy databases, starting from scripts through infrastructure orchestration tools. It also depends on the environment in which you want to accomplish it as some cloud providers make available infrastructure management tools that can be used to automate deployments in their cloud infrastructure.

The main common part across those methods is that you have to write the code that will accomplish the deployment or find someone else’s code that does what you want and modify it to your liking. No matter how you do that, you will have to maintain that code from now on – new versions of the software will deprecate some functionality and add new features, you may be forced to rewrite parts of the code to follow the changes and handle incompatibilities. But what if you could use a tested tool, managed and supported by a well-established company, that can be used to deliver the same functionality?

Let’s take a look at the options available in ClusterControl.

Using ClusterControl as the Heart of Your DBaaS

ClusterControl can be used to deploy clusters of open source databases – MySQL, MariaDB, PostgreSQL, MongoDB.

Private DBaaS Database Deployment with ClusterControl

With a couple of clicks in the UI you can deploy one of the supported setups, passing just a handful of information and settings. While a UI may not be the best way to automate actions, ClusterControl still has you covered through the use of CLI and RPC.

Using the Command Line Interface

ClusterControl comes with a CLI that allows you to manage your databases through the use of commands executed from the shell. For example, we can create a replication cluster by running following command:

root@vagrant:~# s9s cluster --create --cluster-type=mysqlreplication --nodes=";" --vendor=mariadb --cluster-name=MariaDB_replication --provider-version=10.4 --os-user=root --os-key-file=/root/.ssh/id_rsa

Job with ID 1 registered.

We can see that the job has been registered:

root@vagrant:~# s9s jobs --list --long


Create MySQL Replication Cluster

Installing MySQL on                                                                                                                                                                                                                                           [████▎     ]


Created   : 2020-07-30 08:56:40    ID   : 1          Status : RUNNING

Started   : 2020-07-30 08:56:40    User : admin      Host   :

Ended     :                        Group: admins     Cluster: 0

Tags      : -

RPC       : 2.0


Total: 1

We can, as well, see the job log and where we are at right now: 

root@vagrant:~# s9s jobs --job-id=1 --log

Cluster will be created on 2 data node(s).

Verifying job parameters.

Checking ssh/sudo on 2 hosts with credentials ssh_cred_job_6656.

All 2 hosts are accessible by SSH. Checking if host already exists in another cluster. Checking if host already exists in another cluster.

Found replication link 0: ->

Setting up server Checking OS information. Vendor  is 'ubuntu'. Release is 'bionic'. Type    is 'debian'. Check and disable AppArmor. Checking SELinux status (enabled = false). Checking firewall. Disabling ufw. Flushing iptables. Tuning OS parameters. Setting vm.swappiness = 1. Installing helper packages. Waiting for dpkg lock. Proceeding. Installing psmisc. Installing rsync. Installing libaio1. Installing netcat. Installing netcat-openbsd. Installing socat. Installing lsb-release. Installing wget. Installing curl. Installing pigz. Installing libnuma1. Installing libmecab2. Installing bzip2. Installing iproute2. Installing tar. Installing libatomic1. Installing openssl. Installing apt-transport-https. Installing libssl1.0.0. Installing augeas-tools. Finished with helper packages. Verifying helper packages (checking 'socat').

Auto-generating MySQL root password.

Using skip_name_resolve as all servers are defined by IP.

Cluster type is 'replication'. Using template 'my.cnf.mdb10x-replication'.

Using config template '/usr/share/cmon/templates/my.cnf.mdb10x-replication'.

Loaded template '/usr/share/cmon/templates/my.cnf.mdb10x-replication'. Detecting total memory. Detected memory: 733MB. Detected memory: 733.16 MiB. The memory size might be insufficient. Checking free-disk space of '/var/lib/mysql'. Free disk space: 57.05 GiB. Total disk space: 61.80 GiB. Using external repositories. Setting up repository 'mariadb'

Using repository template file 'mariadb.list'. Setting up repository 'percona'

Using repository template file 'percona.list'. Uninstalling existing MySQL packages. Checking OS user mysql. Cleaning old MySQL packages: Prepare MySQL environment (user/group). Checking OS user mysql. OS user mysql already exists. mysqld: no process found

mysqld_safe: no process found

mysql: no process found

mysql_chk: no process found

cmon: no process found Installing the MySQL packages.

When the job is finished we can perform additional actions like adding a ProxySQL load balancer to the cluster:

root@vagrant:~# s9s jobs --list


 1   0 FINISHED admin admins 08:56:40 100% Create MySQL Replication Cluster

Total: 1

root@vagrant:~# s9s cluster --add-node --cluster-id=1 --nodes="proxysql://"

Job with ID 2 registered.

All of those actions are, of course, represented in the UI as well:

Given that we have a cluster now, we can take a backup using CLI:

root@vagrant:~# s9s backup --create --nodes= --cluster-id=1 --backup-method=mariabackupfull

Please keep in mind that this is, by no means, full functionality of the ClusterControl CLI. It is just a list of examples that are intended to show you what can be accomplished by using CLI. The full documentation is available on our website.


Another option to interact with ClusterControl is to use RPC. ClusterControl itself uses RPC for the communication between UI and the backend (cmon) therefore pretty much every job that you can start in the UI can be executed through direct use of the RPC. Let’s take a look at the jobs that we executed via CLI and see how they can be executed through the RPC. One of the ways to see that is in the UI. You can go to the “Activity” tab, and then “Jobs”, pick the job that you want to see, click on “Full Job Details” and, finally, “Expand Job Specs”:

The JSON that you see is the RPC call used to pass all required information for the given job to be executed by the backend service. More details about how to construct the calls can be found in the documentation.

Designing a DBaaS with ClusterControl

Of course, there are many ways in which you can build the DBaaS solution based on ClusterControl. Here we would like to describe some of the challenges that you will encounter while designing DBaaS solutions. 

First, provisioning of the instances. ClusterControl can do that to some extent for the most popular cloud providers, but if you would like to have a better control over this process, you may have to figure out a solution on your own. Such a solution can be based on the tools like Terraform that can be used to define the infrastructure and deploy it. 

If you want to stick to your on-prem data center, there are solutions like Nutanix that can help you build cloud solutions using the local infrastructure. Whatever you’ll choose, that’s the first building block. Next step is to integrate with ClusterControl – you can use CLI made available by ClusterControl, you can use RPC calls – it is up to you. As we mentioned, integration can be accomplished through tools like Ansible, Terraform or straight up code.

Depending on the purpose, it might be a good idea to cover the cogs and wheels of the integration under the hood of a nice UI. Such UI can be built in a way that allows users to easily deploy their database clusters wherever they need to do so using just a handful of clicks. An example solution may look like on the diagram below.

Building a Private Internal DBaaS with ClusterControl

As you can see, the whole setup is not very complex and it mostly depends on the environment that you work with. What’s great, ClusterControl does not really care what environment you have as long as it can connect to the nodes using SSH connectivity. This allows you to mix and match whatever solutions you use. Mixed cloud and on-prem architecture will work just as fine as single or multi-cloud deployments. The only complexity related to the mix of environments would be in the configuration management stage where you would have to define methods to provision instances and ensure they can be reliably reached by ClusterControl.

We hope this very short introduction to the subject of building your own DBaaS using ClusterControl will give you some ideas how it can be accomplished. In a future blog post, we will discuss such a setup in a bit more detail.

Subscribe below to be notified of fresh posts