Thursday, August 18, 2011

MySQL cluster (ndb engine) setup

Setup Mysql cluster with the NDB engine


Mysql Cluster is a high availability RDBMS that can be
downloaded from mysql.com.
It uses as a storage engine NDB which is an engine developed
by Ericsson based on shared nothing architecture.

The roles into the setup are split as follow:

- mysql server (this is a pure mysql server configured with the
engine NDB)
- data nodes (this is a storage node that runs ndbd daemon)
- management server (this will orchestrate all the actions into
the cluster)

My setup
mgmt_node    : 192.168.149.128
data_node_1  : 192.168.149.130
mysql_server : 192.168.149.131

[Installation]

mgmt_node
- install client and management rpms
128#rpm -ivh MySQL-Cluster-gpl-client-7.1.15-1.rhel5.i386.rpm
128#rpm -ivh MySQL-Cluster-gpl-management-7.1.15-1.rhel5.i386.rpm
128#rpm -ivh MySQL-Cluster-gpl-tools-7.1.15-1.rhel5.i386.rpm

data_node_1
- install storage
130#rpm -ivh MySQL-Cluster-gpl-storage-7.1.15-1.rhel5.i386.rpm

mysql_server
- install mysql server
131#rpm -ivh MySQL-Cluster-gpl-server-7.1.15-1.rhel5.i386.rpm
131#rpm -ivh MySQL-Cluster-gpl-client-7.1.15-1.rhel5.i386.rpm

[Configuration]

mgmt_node
- configure location
128# mkdir /mysql-cluster
- configuration file

128# cat > /mysql-cluster/config.ini << CONFIG
[NDBD DEFAULT]
NoOfReplicas=1
DataMemory=20M
IndexMemory=10M

[TCP DEFAULT]
portnumber=1186

[NDB_MGMD]
hostname=192.168.149.128
datadir=/mysql-cluster

# repeat this with the number of data nodes into the cluster
[NDBD]
hostname=192.168.149.130
datadir=/mysql-cluster/data

[MYSQLD]
hostname=192.168.149.131

CONFIG


data_node_1
- configure location
130# mkdir -p /mysql-cluster/data
- configuration file
130# cat > /etc/my.cnf << CONFIG
[MYSQLD]
ndbcluster
ndb-connectstring=192.168.149.128

[MYSQL_CLUSTER]
ndb-connectstring=192.168.149.128

CONFIG

mysql_server
- configure location
131# mkdir -p /mysql-cluster/data
- configuration file
131# cat > /etc/my.cnf << CONFIG
[MYSQLD]
ndbcluster
ndb-connectstring=192.168.149.128

[MYSQL_CLUSTER]
ndb-connectstring=192.168.149.128

CONFIG


[Startup]

mgmt_node
128#ndb_mgmd --initial -f /mysql-cluster/config.ini
MySQL Cluster Management Server mysql-5.1.56 ndb-7.1.15
2011-08-18 07:09:50 [MgmtSrvr] INFO     -- The default config directory
'/usr/mysql-cluster' does not exist. Trying to create
it...
2011-08-18 07:09:50 [MgmtSrvr] INFO     -- Sucessfully created config
directory
2011-08-18 07:09:50 [MgmtSrvr] WARNING  -- at line 7: [TCP] portnumber is
deprecated

data_node_1
130#ndbd --initial
Unable to connect with connect string: nodeid=0,192.168.149.128:1186
Retrying every 5 seconds. Attempts left: 12 11 10 9 8 7 6 5
2011-08-18 07:11:44 [ndbd] INFO     -- Angel connected to
'192.168.149.128:1186'
2011-08-18 07:11:44 [ndbd] INFO     -- Angel allocated nodeid: 2

mysql_node
131#/etc/init.d/mysql start
Starting MySQL.... SUCCESS!


[Running Operations]

128#ndb_mgm
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)]     1 node(s)
id=2    @192.168.149.130  (mysql-5.1.56 ndb-7.1.15, Nodegroup: 0, Master)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.149.128  (mysql-5.1.56 ndb-7.1.15)

[mysqld(API)]   1 node(s)
id=3    @192.168.149.131  (mysql-5.1.56 ndb-7.1.15)

3 comments:

Matty said...

close - ndb was developed by Ericsson, not Sony

Geert JM Vanderkelen said...

Few more comments/corrections:
* MySQL Server coming with MySQL Cluster is not _just_ the MySQL with the NDB storage engine. It has some more things differently, one example being that it defaults to Row-Based replication.
* Data Nodes store data (and indexes), yes, but they are doing far more. Actually, almost everything is done by them.
* Management Node (not server) is only there to provide the configuration to the other nodes, act as Arbitrator (can also be done by SQL Nodes) and log stuff. Actually, you don't strictly need it to when you have your nodes up.

silviu dicu said...

yes - Ericsson not Sony - thanks