MySQL cluster (NDB cluster) – an introduction

Basically, cluster is a group of computers deployed to improve performance and availability that cannot be achieved via a single computer. And this type of web hosting distributes the load of hosting across various nodes/physical machines so that the probabilities of one service (e.g., FTP) affecting another (e.g., MySQL) are decreased.

So, a MySQL cluster is designed to achieve “MySQL database service” with high availability and upto 99.999% uptime for real-time systems.

Main features of MySQL cluster:

  • Node failure recovery and failover in less than 1 second.
  • Support for multiple APIs, including HTTP/REST, Memcached, Java, C++, Node.js/JavaScript and JPA.
  • Optimized for concurrent writes.

For more features, click here.

Installation of MySQL cluster for evaluation

MySQL cluster is installed with its “Auto-Installer” python script, which helps us to install it in purely web based environment. Make sure that all the host requirements are fulfilled for initial installation and required packages are ready to do the setup.

The cluster comprises basically 3 components/nodes for evaluation:

  1. Management Node.
  2. SQL Service Node.
  3. SQL Data Node.

Initially, we can evaluate it with 4 machines/hosts, running following components (nodes) per host:

  1. Management Node.
  2. SQL Service Node.
  3. SQL Data Node.
  4. SQL Data Node.

We can also put different components/nodes on the same host, like Management and SQL Service Node on the same host.

So to evaluate high availability, we can consider installing a single component/node per machine/host.

Cluster package can be downloaded from the community URL for any specific platform and OS versions – “http://dev.mysql.com/downloads/cluster/“. Make sure to do proper “MD5 checksums” and “GnuPG signatures” to verify the integrity of the packages.

Here, I will download the bundle package to install it on Linux Cent OS 6.x platform:

Package Name: MySQL-Cluster-gpl-7.4.12-1.el6.i686.rpm-bundle.tar

Get it downloaded via wget. Now we have to ready our host/machine per instructions below:

  • OS: Centos 6.x 64 bit on each host installed.
  • All the host servers should have basic installed (SSH only) with “time sync”.
  • MySQL Cluster Auto-Installer requires Java Script enabled in the browser, so take care.
  • An SSH unprivileged user (non root user shall be created and MySQL service should not be run as root due to security reasons).
  • Proper hostnames should be set on all the participating host servers, like –

Open /etc/sysconfig/network, update the HOSTNAME line and save:

  1. # vim /etc/sysconfig/network
  2. HOSTNAME=HOST_NAME

Make hosts entries with corresponding IP address.

Open your hosts file, and update the hostname entry and save:

  1. # vim /etc/hosts
  2. IP HOST_NAME

Now, on each host, run following commands to proceed with installation:

# yum -y install python python-paramiko python-crypto screen perl numactl-devel libaio

Remove any previous MySQL installation if any:

# yum remove mysql*

Now download Mysql Cluster package on each host:

# cd /usr/local ; wget http://cdn.mysql.com//Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.12-1.el6.i686.rpm-bundle.tar .

Extract the downloaded bundle:

# tar xvf MySQL-Cluster*

Install rpm package:

# rpm -ivh MySQL-Cluster*rpm

Now, get the IP of the management host, which will be required for web based installation.

Choose “Management Host/server” and run python auto installer setup with the following command:

# su – “non_root_user”

$ /usr/bin/ndb_setup.py -n -N IP

The installer will run via web, go to browser and open with URL http://IP:8081/welcome.html. Follow the installation procedure, as given in the referred URL:

http://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-install-auto-using.html

Once installation is done, we can check the status with following commands while running it on the Management Host.

# ndb_mgm -e show

# ndb_mgm -e “all status”

# ndb_mgm -e “all report memory”

Finally, perform installation check while creating a sample/test database.

First get the MySQL shell/prompt on “SQL Host”, where SQL service node/component is being installed in the NDB Cluster.

mysql> CREARE DATABASE znetndbtestdb ; use znetndbtestdb ;

mysql> CREATE TABLE samples (id INT NOT NULL PRIMARY KEY) engine=ndb;

mysql> INSERT INTO samples VALUES (1),(2),(3),(4);

mysql> SELECT * FROM samples;

mysql> quit

This database should reflect in other SQL Host in the NDB Cluster. Just verify it and test it.

If all goes good, you have installation successfully done! Enjoy! 🙂

Further, do not forget to read “MySQL Cluster Evaluation Guide – Designing, Evaluating and Benchmarking MySQL Cluster” to actually evaluate it.

Feel free to drop any comments in the section below.

Services ZNetLive offer:

Domain Name Search

Buy Shared Hosting

Managed WordPress Hosting Plans

Buy VPS Hosting

Dedicated Server Rental