AS I mentioned in How to Create a Mysql NDB cluster on a PC, windows 7 tutorial, It requires the same prerequisites to run a simple NDB cluster. I will go over a tutorial to create a one Mgmt node, Two storage Node One Api Node clusters in one single Centos instance.
Download the Linux version of Mysql cluster community edition which is free to use .
Unzip it and copy the folder to /usr/local/mysql, here you may copy to a folder like /usr/local/mysql_xxx where xxx is the edition, then put a link named mysql to that folder.
tar -zxvf mysql-cluster-gpl-7.1.8-linux-x86_64-glibc23.tar.gz#unzip it
cp -r mysql-cluster-gpl-7.1.8-linux-x86_64-glibc23 /usr/local/ln -s /usr/local/mysql-cluster-gpl-7.1.8-linux-x86_64-glibc23/ /usr/local/mysql
Create a user named mysql.
setup the Mysql service.
cd /usr/local/mysql# you must be in this folder to run the install script
once done, copy the demon script
cp support-files/mysql.server /etc/init.d/mysql
chown -R mysql:mysql /usr/local/mysql/data
Now you can run service mysql start to startup a regular mysql service.
Time to create a NDB config ini, there are some templates file like config-xxx.ini in the support-files directory, just copy and paste. and change the nodes per you requirement.
I will put a config file in /ndb/config.ini
and put all NDB data into /ndb/folder
then change the config.ini just created as the following content.
after saving the chagnes to /ndb/config.init, run a commant ndb_mgmtd –f /ndb/config.ini –-ini to initialize the ndb folder
run the show in ndb_mgm to refersh the status. Two data ndoes are back.
one more step left, change the mysqld API Node to point to ndb cluster ( ask it to pickup the ndb engine and ndb node configuration. all it need is the connectiong to ndb mgm node, node will push all information to API nodes.)
Create one file in /etc/my.cnf as content below.
Now you can run several utility to make sure the data is distributed to two NDB data nodes evenly.
|ndb_desc –d hello foo -p|
here two partitions, one has two records, one has one record.