/ memsql

Setup a MemSQL Cluster in Debian 8

MemSQL is a distributed database that perform its transactions in memory, although the user can deliberately choose to store things on disk should they wish. This results in extremely low latency and high throughput and is perfect for real-time systems.

MemSQL Introduction Video

For this tutorial, I am going to configure two Debian 8 virtual machines using virtualbox consisting of an aggregator node that has just 4GiB of RAM and a leaf node that has over 8GiB of RAM. The leaf nodes store all of the data in memory, and the aggregator acts as a gatekeeper that takes queries from clients and pulls the relevant information from the relevant leaf nodes. This kind of architecture is the most common in distributed systems. If you are just getting started, you can install the aggregator and the leaf node in one go on the same server, but this tutorial is aimed at those who would like to configure a cluster.

Every machine in the cluster requires at least 4 vCPUs and 4 GiB of RAM.

Steps

Download the installation files on every node in your cluster.

wget http://download.memsql.com/memsql-ops-4.1.9/memsql-ops-4.1.9.tar.gz

By the time you read this, there may be a later version, so use the download that this page will give you.

Extract the files, navigate to within the extracted directory and run the installer.

tar --extract --gzip --file memsql-ops*
cd memsql-ops*
sudo ./install.sh

You should see the following output:

Installing MemSQL Ops in /var/lib/memsql-ops
Creating a memsql user
Setting up permissions
Adding stuart to the memsql group
Creating an init script so that MemSQL Ops runs on startup
Creating a symlink to MemSQL Ops at /usr/bin/memsql-ops

Successfully installed MemSQL Ops!

--------------------------------------------------------------------------------

You can install MemSQL across multiple machines
using the MemSQL Ops Web UI.

For quick testing, you can also install a simple MemSQL
deployment on this host.

Do you want to install MemSQL on this host only? [y/N]

If you are installing a cluster as we are, then answer with N. If you are setting up just a single server that will act as both aggregator and leaf node, then answer with 'Y'.

Navigate to the aggregator's IP/hostname in your browser with the port 9000. For example:

http://memsql-aggregator.programster.org:9000
You should be shown a page like follows: ![](https://lh3.googleusercontent.com/X2hzXqFwEBXFe6rY0JHpRbeUk6xZE0BpKyKo7ZXJ9Yk0HzE8L2v5-MtFEVtJw5E65QSUwL35GMzCkOg1anOEJA_crd2j57qr6Ot0qyweKqkNaKT7VlhxJD3gerWb0OCVzM5E1PXEnsKUh--pCH02_oKuTec3S9dHymsvqYep6X3cPgzQjfcLtUKe3RPJanx3ud7ZzQbHQoONgZhSERk6dx4trWMgy2UBB0PluPFSMAWA9rorHjFcNzg34G2rhd1FunCb_G7p48GPq2Jakad-6p56Tr9tX03sAlfGjel0NhJa36UEuMpeTZyYIJrEGC-hS9YXuXNuHc5ROYTLNJ1Y-onlOguzXCUoO3dYWpghxqV7WRG2pDB2LUhFrmAnQgx3eIhUcJ6Z99Vv5AG0fTG64qdOL__iZ3dscEE94HFF1-RgMZndtFJNFwICdolqLWzby9j26XKLc0rK3sf0Whc5s_fPpm9zDc4FjUWgtd5DV59JGdyhaZWW3dAQI3fUUKH50xv9QrxtsjZTErY0aD8bDw6ZrIY6wb8aBWGoeWblkr8=w750-h699-no)

Click next and select "Community Edition".

Then select "On Multiple Hosts".

Click cancel on the setup page. We are not going to plug our sudo/root SSH access details into this software. Instead we are going to manually configure the leaf nodes to "follow" the aggregator. Details of which can be found in the offline install manual.

SSH into the leaf node after installation and execute:

memsql-ops follow -h [aggregator hostname or IP]

You will now see the node's IP in your aggregators web GUI.

Now that all of your leaf nodes have been added and set to follow the aggregator, click the plus symbol in the web GUI and select "Add MemSQL Nodes"

![](https://lh3.googleusercontent.com/Qeo77vTCEcnih5Kj2ShZ_UrhplWC8WTgZQUfaAo7cgPDiWvvvuFmHrLg9LVtBHpTmZpLL0_S5xW7Xv-sFStAojOT8Jv8C-bwERNS_7zIbBizZlaCB_zo4zyRrU5aVdY3_pipt3R92rkEaM6QlraFRbLCImaGNo2_R7BLrfXOB8VJqz78eHgJ4R7V_Fr-dWlmkT6oEfYLZXDXTDSw1qHwzWYfEjaDV8LNlWEfKCxHFZsk3NdlSlY37hSi0RlpcxXPmQT-AFTV8APjd39kCS7kyqiRcfV2hxbNtTJL_1zJuve2XfCdGAgKl_vgpKnBKuMTxeJvH-AyNvPczKXRbh6XJJZApbzZqhU1DdxZmmkPJQ963J2wWIQ1lhdWxLkvM2C_VJoXOJ0lmT88pSQPm0XGfGMFA388BvpPsW2H2y6NGUZOb2GEylwUllPDpnLwyjYzkJxwlHvhTQTqtAEkt4wBL4L8eC-fH0qzT2_tdqq9rUoiwI8UL9HlhtNlVF4_VY3TcdCJngqZcVORpBwtMw8PmnUeBJd0tApnHwFf3gerIE0=w455-h226-no)

You should see all of your nodes listed with their roles (master aggregator and leaf). If you are happy with the cluster, click the checkboxes and click the "DEPLOY MEMSQL CLUSTER" button.

![](https://lh3.googleusercontent.com/A_1bl161r54O77BONBtMoI-cjnnOe11CilXk2_NxeH-7jWBKfn94gGgNb94JAI5Do22GVpkOSK77wjPEccZInjtNLObJv5J2GjERYIqx7rkNwV9c7cSXwYaEbszx9C901jJqe_U7mYhjaz4KirCMCve-VFio6szOySyvFsUl8UuFnLSM_x8Fp31sZPkw4qXOYFpcNSYXxht54pn5h7vmQNM5Ial8Akd_8yqK_nliRlu6HxrfnvdxuWL5Sdig4W2n4ll5KXLlET2Si2ajKrKqteOImh3x6KuRYJR2mc2I3jl-Y4D_35b1uAuWtvE-hFqKsCSNrEn6EBj3GMoU0JL8uS-4cCRnZpiMoK7FEmDlcOMBVeVXQ0rmZSCYr6FgnAttQ-C2mr2sb2VhM-PxKmC8OMfekWeoyjiR_Q_D-hd7Te0lm_OQwLhgJAHa_KTGPBQs-rXj2k2MprkuPsbm4yWg1NqgdhKsHcPC8nZXknayTzaSXH7kda_cx9_JusPev9EVKr_hy4cSefKVTi8fFMOlN4OdjlcGLIG2LT-wkfYOgOs=w672-h336-no)

You will see a progress log of the cluster setting up. Once it has finished, it will show you the command you need to execute in order to connect to your cluster. For example, mine was:

mysql -u root -h memsql-aggregator.programster.org -P 3306 --prompt="memsql> ";

Conclusion

You now have a MemSQL cluster configured. Next time we will cover setting up redundancy for automatic failover and securing your cluster.

References

Stuart Page

Stuart Page

Stuart is a software developer with a passion for Linux and open source projects.

Read More