Tuesday, November 16, 2010

How to : Installing and testing Mysql NDB Cluster on Centos Tutorial

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.

scripts,

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.

useradd mysql


setup the Mysql service.

cd /usr/local/mysql

# you must be in this folder to run the install script
./scripts/mysql_install_db
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.

image

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

mkdir /ndb
cp /usr/local/mysql/support-files/config.medium.ini /ndb/config.ini

then change the config.ini just created as the following content.

[NDBD DEFAULT]
NoOfReplicas: 2
DataDir: /ndb

[MGM DEFAULT]
PortNumber: 1186
DataDir: /ndb

[NDB_MGMD]
Id: 1

[NDBD]
Id: 2
[NDBD]
Id: 3
[API]
Id: 4

after saving the chagnes to /ndb/config.init, run a commant ndb_mgmtd –f /ndb/config.ini –-ini to initialize the ndb folder

cd /usr/local/mysql/bin
./ndb_mgmd -f /ndb/config.ini  --init
./ndb_mgm

Only mgmt node is active in this cluster now.
image

run ./ndb twice to start Two  NDB Data Nodes.
image

run the show in ndb_mgm to refersh the status. Two data ndoes are back.
image 

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.

[mysqld]
ndbcluster
ndb-connectstring=localhost

restart the mysql service. API node is On now

image

let’s run a helloworld test.
image

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.

image

run ndb_mgm, all report memory
image

No comments:

 
Locations of visitors to this page