March 4, 2015 Hatem Ben Yacoub

MySQL Cluster NDB Up and running (7.4 and 6.3) on ubuntu server trusty 14.04

I previously talked about MySQL Master-Master clustering using the default MySQL packages which is more a proof of concept, and could be working fine if you don’t have heavy load on servers, but especially it will work fine if you don’t have autoincrement fields in your tables.

The most appropriate clustering solution for MySQL is at least the MySQL cluster package which is available as community edition, there are some other solutions that we’ll talk about in another article. If you are looking to get MySQL cluster up and running easily on Ubuntu servers, here is how to proceed.

In this article I installed once again a two nodes Master-Master mysql cluster, this is not the perfect configuration but it’s doable. If you are looking for a highly available environment it is always recommended to have at least two separate management nodes and two separate data nodes, then we can add extra data nodes depending on our requirements.

Today there are even GUIs available for those looking for mode advanced solution, but I have always a preference of doing things myself before going to the automation level. Note that this configuration should work for four servers and more, all changes will be made in the config.ini and my.cnf file that we will see shortly.

Before starting..

First make sure you don’t have any other mysql package previously installed on your server, this will create conflicts with this installation and it’s probably the cause of most installation problems (I warned you). So even after removing mysql package, make sure you don’t have any my.cnf somewhere, or an /etc/mysql/ folder.

Otherwise mentioned below if the command is not using sudo, it should be run as root.

pre-requirement : (required for mysqld ~ data nodes only)

Preparing user and group (data nodes only) :

Getting MySQL cluster package

Download package from http://dev.mysql.com/downloads/cluster/

Before going further let’s move binary files to /usr/bin to make sure we are using the same binary version for next steps.

Install NDB_MGMD and NDBD :

and enter the script below in both management servers :

Now we can start manually the ndb_mgmd

Starting with MySQL cluster version 7 and above you can add configdir and we may define a seperate my.1.cnf in each server, otherwise the previous configuration is enough.

As root run :

Install MySQL cluster

Add mysql-server to ubuntu default startup script

Enter the script below :

Now everything is almost ready let’s start ndbd first and make sure you use “–initial” in the first run only and then followed by simple mysqld startup :

Test installation :

Now we can check if all our cluster is up and running using ndb_mgm :

As I have previously said this configuration is for two servers only which is not highly recommended for production environment, unless you do not need more than two servers. I use this in production simply because I have a two nodes web cluster and in each node a mysql instance. So if one of these two nodes fail, the second will keep serving data normally.

So before making more test make sure you are securing MySQL database by running :

Now we can try to create our first NDB table :

Now let’s move to the second data node and make sure we have the tables and data available :

Now my cluster is up and running but before move it to production make sure you test it very well and especially make sure you put the right amount of storage for DataMemory and IndexMemory in the config.ini. Also config.ini files have to be identical in all your management servers, and there is no automation for this. Personally I edit on one server then use scp to transfer config.ini to other servers.

Finally you can check NDB memory usage using :

Some recommended books for reading about MySQL NDB :

Also see below some important links for reference

Enjoy!

-Hatem

Tagged: , , , ,

About the Author

Hatem Ben Yacoub Energy Engineer, Entrepreneur, ICT & eGov Consultant with over 15 years experience. Independent Open Data expert.

Comment (1)

Comments are closed.

(HBY) Consultancy