| Article Index |
|---|
| How to configure a MySQL cluster on CentOS / Redhat |
| 2nd Step - Setting up a storage server (NDBD) node 1 and node 2 |
| How to shut down and restart the cluster |
| All Pages |
In this article learn how to configure a MySQL cluster with three nodes, one being the management node and two storage nodes.
Well folks, I hope this article will be useful to someone. I am going to clear and quick on the installation and configuration. I hope you enjoy, comments and criticisms are welcome for the betterment of future articles.
Well, let's get our hands dirty.
Let's see our work environment.
- DB1 - 172.16.3.241 - Management Server (MGM) node.
- DB2 - 172.16.3.242 - Storage Server (NDBD) node 1.
- DB3 - 172.16.3.243 - Storage Server (NDBD) node 2.
1st step - Configuration management server (MGM)
First install the following packages via yum:
# yum install perl-HTML*
# yum install perl-DBD-MySQL
Link to download the MySQL packages used in this tutorial: http://download.softagency.net/MySQL/Downloads/MySQL-5.0/
Installing packages:
# rpm -ivh MySQL-ndb-management-5.0.90-1.glibc23.i386.rpm
# rpm -ivh MySQL-ndb-tools-5.0.90-1.glibc23.i386.rpm
Create directory:
# mkdir /var/lib/mysql-cluster
# cd /var/lib/mysql-cluster
# vi config.ini
NoOfReplicas=2
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the .world. database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Management Section (MGM)
[NDB_MGMD]
#NodeId = 1
# IP address of the management node
HostName=172.16.3.241
# Storage Server Section (NDBD)
[NDBD]
#NodeId = 2
# IP address of the Storage Server (NDBD) node 1
HostName=172.16.3.242
DataDir=/var/lib/mysql
BackupDataDir=/var/lib/backup
DataMemory=100M
[NDBD]
#NodeId = 3
# IP address of the Storage Server (NDBD) node 2
HostName=172.16.3.243
DataDir=/var/lib/mysql
BackupDataDir=/var/lib/backup
DataMemory=100M
# one [MYSQLD] per storage node
# 2 Clientes MySQL
[MYSQLD]
#NodeId = 5
[MYSQLD]
#NodeId = 6
After configuring the IP addresses of servers in the configuration file config.ini, it is necessary to start the Management Service:
# ndb_mgmd
Command to enter the administration console:
# ndb_mgm
Command "SHOW" shows the nodes that are connected to the cluster:
ndb_mgm> show
Command "HELP" for further information:
ndb_mgm> help
As we don't have any other node yet, let's create them!
2nd Step - Setting up a storage server (NDBD) node 1 and node 2
First install the following packages via yum:
# yum install perl-HTML*
# yum install perl-DBD-MySQL
Install packages:
# rpm -ivh MySQL-shared-5.0.90-1.glibc23
# rpm -ivh MySQL-client-5.0.90-1.glibc23
# rpm -ivh MySQL-ndb-tools-5.0.90-1.glibc23
# rpm -ivh MySQL-server-5.0.90-1.glibc23
# rpm -ivh MySQL-ndb-storage-5.0.90-1.glibc23
Each node of the storage servers requires a my.cnf file:
# vi /etc/my.cnf
[client]
socket=/var/lib/mysql/mysql.sock
[mysqld]
ndbcluster
#IP of the management server(MGM)
ndb-connectstring=172.16.3.241
default-storage-engine=NDBCLUSTER
[mysql_cluster]
#IP of the management server(MGM)
ndb-connectstring=172.16.3.241
Now start the process "ndbd" on each node "DB2"and "D3B"
# ndbd --initial
or
# ndbd
Note: You must use "initial" if there is any change in the configuration of config.ini on the management server.
Then start the MySQL server:
# service mysqld start
How to shut down and restart the cluster
On the management server (MGM) use the commands below.
This command causes the ndb_mgm, ndb_mgmd and any ndbd processes shut down:
# ndb_mgm -e shutdown
Command for restarting the cluster:
# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
On storage servers (NDBD) use the following command on each node "DB2"and "DB3".
Command to start The "ndbd"
# ndbd
Command to start The MySQL:
# service mysql start
If everything is configured correctly, the cluster must be up.
Type the following command on the management server (MGM) for administration of the nodes:
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @172.16.3.242 (Version: 5.0.90, Nodegroup: 0)
id=3 @172.16.3.243 (Version: 5.0.90, Nodegroup: 0, Master)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @172.16.3.241 (Version: 5.0.90)
[mysqld(API)] 3 node(s)
id=4 @172.16.3.242 (Version: 5.0.90)
id=5 @172.16.3.243 (Version: 5.0.90)
ndb_mgm>
Lets create a test database in the storage servers (NDBD), "DB2"or "DB3"
# mysql
mysql> use test;
mysql> CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER;
As the table ctest "was created using the database engine" NDBCLUSTER ", all changes in the database changed in any one of the nodes will be automatically replicated to the others.
We can do a simple test including a row in the table "ctest" in one of the nodes and check that the line was automatically sent to the table ctest "of another node.
mysql> INSERT INTO ctest () VALUES (1);
mysql> SELECT * FROM ctest
Last Updated (Saturday, 08 January 2011 03:56)




Comments
RSS feed for comments to this post.