Set up a MySQL NDB cluster part 1


I received feedback that some people find it weird that i post how to solve the issue of Ruby app unable to do migration on MySQL NDB, rather than posting how to create an NDB cluster.

It is pretty fortunate (or unfortunate 😦 ) that i get the chance to create a new NDB cluster on GCE (Google Cloud Engine) again from scratch, hence I will do a demonstration again. The OS is CentOS 6.

The installation is pretty long as it involves at least 5 instances for it to have some reasonable level of High Availability. Hence I break it down into 2 parts.

Step 1: Create 5 instances. 2 for SQL, 1 for Management, 2 for Data. I name those instances as:


Step 2: In all the 5 instance, set SELinux to disabled in /etc/selinux/config

Step 3: In all the 5 instances, remove all mysql libraries in CentOS with the command below. Yes, ALL!!!

sudo yum remove mysql mysql-libs

Step 4: Download and unzip MySQL NDB bundle into all your instance. This bundle contains everything but later you will see that you just need only 2 RPM files.


tar xvf MySQL-Cluster-gpl-7.3.6-2.el6.x86_64.rpm-bundle.tar

Optional: You can add in a separate disk on the data instances to store data. Do take note, GCE offers extremely high IOPS for their SSD disk, I called it the Highway 401 of Cloud Computing =).

Screen Shot 2014-09-23 at 4.41.34 PM

Having high IOPS is good if you have heavy traffic writing to SSD. Imagine vehicles as IOPS / data and you will see what I mean.


Step 6: In all the instances, install the mysql NDB server. After that do a restart for all the instances.

rpm -Uhv MySQL-Cluster-server-gpl-7.3.6-2.el6.x86_64.rpm

Do take note that you will see the following message at the end of the installation:

“A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !You will find that password in ‘/root/.mysql_secret’.You must change that password on your first connect,no other statement but ‘SET PASSWORD’ will be accepted.See the manual for the semantics of the ‘password expired’ flag.”

You will be using it later on the sql nodes of the cluster, but do take note of that message.

Step 7: Install the MySQL NDB client on the 2 SQL instance

rpm -Uhv MySQL-Cluster-client-gpl-7.3.6-2.el6.x86_64.rpm

Step 8: On the Management Instance, set up a configuration file at /var/lib/mysql-cluster/config.ini with the following configuration.

[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2    # Number of replicas
DataMemory=80M    # How much memory to allocate for data storage
IndexMemory=18M   # How much memory to allocate for index storage

[ndb_mgmd] # Management process options:
hostname=ndb-mgmt-1          # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster  # Directory for MGM node log files

# Options for data node "A":
# (one [ndbd] section per data node)
hostname=ndb-data-1           # Hostname or IP address
datadir=/data   # Directory for this data node's data files

# Options for data node "B":
hostname=ndb-data-2           # Hostname or IP address
datadir=/data   # Directory for this data node's data files

# SQL node options:
hostname=ndb-sqld-1           # Hostname or IP address

# SQL node options:
hostname=ndb-sqld-2           # Hostname or IP address

Step 9: Run the NDB management command

ndb_mgmd --initial -f /var/lib/mysql-cluster/config.ini

I wouldn’t go into the configurations of the ndb, you can google for the links. But it is important to note that the NDB is the controlling hub of all the data and sql nodes in the NDB cluster. From the management instance it is possible to add in more data node if your database grows, or sql nodes if your traffic grows.

In my part 2, I will elaborate how to run the sql and data nodes and get the cluster to work.


2 thoughts on “Set up a MySQL NDB cluster part 1

  1. Bob

    thanks for the guide! 🙂

    Question though…
    “sudo yum remove mysql mysql-libs”
    mysql-libs is required by postfix and crontab.

    Did you remove postfix and crontab as well or how did you get around that dependency issue?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s