The MySQL Cluster product seems to intimidate a lot of folks with its complexity. The North Texas MySQL Meetup had a presentation at the January meeting titled 'A Gentle Introduction to MySQL Cluster' where a cluster was setup on a single laptop. The presentation was full of information that needs to be shared to encourage others to try out this valuable piece of software.
The following covers how to set up a cluster on a single computer. The cluster will consist of two data nodes, a SQL node, and a management node. In this case the SQL node and the management node will be on one system. The data nodes will be virtual systems running on the same host. This is not the optimal performance configuration but it will let those new to MySQL Cluster try out the product with a minimal investment in equipment and time.
You will need two free software products -- Virtualbox and MySQl Cluster. You will also need a CDROM/DVD/ISO-image of your favorite supported operating system. In this example Virtualbox was installed on a MacBook and a copy of the Ubuntu desktop ISO was downloaded.
The latest MySQL Cluster binaries is 6.3 as this is written. For those of you not used to Cluster, the version number is out of sync with the MySQL Server GA release number so do not panic that 5.1 was just GA-ed and now 6.3 is on the loose.
The MacBook's IP is 192.168.15.101 in the examples while '103 and '104 are the virtual systems.
Install Virtualbox and then install at least two virtual systems. These two system will be the data nodes. In the example below, Ubuntu was installed, the virtual images were set to use the host's network card, and the software updates for Ubuntu where installed.
A new directory was created, /var/lib/mysql-cluster, and ownership was set to user mysql. Then the MySQL Cluster software binaries were downloaded. The software was installed in /usr/local and the instructions for installing a binary were followed.
Now repeat all that for the second data node and modify the following for your /etc/my.cnf
Install the MySql Cluster software on your SQL node, in this case the MacBook. Create a directory owned by mysql named /var/lib/mysql-cluster. Grab your favorite my.cnf from a previous installation or use one of the examples from the support-files directory and add the following.
You need put the following in you /var/lib/mysql-cluster and match it to your network addresses.
On the SQL/Management node, run ndb_mgmd and then open a new terminal window to run ndb_mgm. On each of the data nodes, run ndbd --initial (you can drop the --initial after the first successful start) then start mysqld with mysqld_safe --user=mysql&. Back to the SQL Node and start mysqld just like you did on the data nodes. In your window where you left ndb_mgm running, enter show and you should see something like
-- NDB Cluster -- Management Client --
Connected to Management Server at: 192.168.15.101:1186
[ndbd(NDB)] 2 node(s)
id=2 @192.168.15.104 (mysql-5.1.30 ndb-6.3.20, Nodegroup: 0, Master)
id=3 @192.168.15.103 (mysql-5.1.30 ndb-6.3.20, Nodegroup: 1)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.15.101 (mysql-5.1.30 ndb-6.3.20)
[mysqld(API)] 4 node(s)
id=4 @192.168.15.103 (mysql-5.1.30 ndb-6.3.20)
id=5 @192.168.15.104 (mysql-5.1.30 ndb-6.3.20)
id=6 @192.168.15.101 (mysql-5.1.30 ndb-6.3.20)
id=7 (not connected, accepting connect from any host)
Note that in this case Node #2 is the Master data node and in Nodegroup #0 while Node #3 is in Nodegroup #1. There are lots of good articles online on MySQL Cluster but I really recommend the MySQl 5.1 Cluster Certification Guide as a reference book.
So do not be afraid of the configuration complexity or worry that you need several computer systems with corresponding network gear. Give MySQL Cluster a try!