MySQL Cluster
is a technology for automatically shared database management system. i.e this
technology create two or more replicas of the same data base in different
nodes. Basically mysql clustering is
asynchronous communication technology.
The
basics steps for establish mysql clustering is given below:
Step 1:
Download supported version of mysql clustering
installation zip file from http://www.mysql.com/downloads/cluster/
Step 2:
Extract the zip file and copy the contents
inside the folder to c:\Users\user1\mysqlc
Step 3:
Run the
command prompt window as administrator role, And execute the following commands
for create clustering directories
C:\Users\user1>
mkdir my_cluster my_cluster\ndb_data my_cluster\mysqld_data my_cluster\conf
C:\Users\user1>
mkdir my_cluster\mysqld_data\mysql my_cluster\mysqld_data\ndbinfo
my_cluster\mysqld_data\performance_schema
Step 4:
Create
configuration files for clustering; here I am using two systems
(192.168.168.20,192.168.168.21)
Config.ini
[ndbd default]
noofreplicas=2
[ndbd]
hostname=192.168.168.20
NodeId=4
[ndbd]
hostname=192.168.168.21
NodeId=3
[ndb_mgmd]
NodeId = 102
hostname=192.168.168.20
[ndb_mgmd]
NodeId = 101
hostname=192.168.168.21
[mysqld]
NodeId=52
hostname=192.168.168.20
[mysqld]
NodeId=51
hostname=192.168.168.21
my.cnf (This
file is for the system with IP address 192.168.168.21)
[mysqld]
ndb-nodeid=51
ndbcluster
datadir=c:\\Users\\user1\\my_cluster\\mysqld_data
basedir=c:\\Users\\user1\\mysqlc
port=5000
server-id=51
log-bin
my.cnf (This
file is for the system with IP address 192.168.168.20)
[mysqld]
ndb-nodeid=52
ndbcluster
datadir=c:\\Users\\user1\\my_cluster\\mysqld_data
basedir=c:\\Users\\user1\\mysqlc
port=5000
server-id=52
log-bin
**
Save both files(config.inf & my.cnf) in the location
‘C:\Users\User1\my_cluster\conf’
Step 5:
Execute the following command for copy
the contents from mysqlc to clustering folders
C:\Users\user1>copy
mysqlc\data\mysql my_cluster\mysqld_data\mysql
C:\Users\user1>copy
mysqlc\data\ndbinfo my_cluster\mysqld_data\ndbinfo
C:\Users\user1>copy
mysqlc\data\performance_schema my_cluster\mysqld_data\performance_schema
Note : Execute steps 1-5 in both systems
Step 6:
Here we start the
clustering process. Before that execute the code in both systems
C:\Users\user1>cd my_cluster
C:\Users\user1\my_cluster>start /B c:\Users\user1\mysqlc\bin\ndb_mgmd
-f conf\config.ini --initial --
configdir=c:\Users\user1\my_cluster\conf
After that execute the following code in 192.168.168.20
C:\Users\user1\my_cluster>start /B
c:\Users\user1\mysqlc\bin\ndbd -c 192.168.168.20:1186
And then execute the following code in 192.168.168.21
C:\Users\user1\my_cluster>start /B
c:\Users\user1\mysqlc\bin\ndbd -c 192.168.168.21:1186
For
connecting API in between the systems execute the following command in both systems.
c:\Users\user1\my_cluster>start /B
c:\Users\user1\mysqlc\bin\mysqld --defaults-file=conf\my.cnf
After this execution, we execute the the below command in both
systems
c:\Users\user1\mysqlc\bin\ndb_mgm -e show
then we get the following output
Step 7 :
Now the setup is completed, so we can start the mysql command prompt as
c:\Users\user1\my_cluster>c:\Users\user1\mysqlc\bin\mysql
-h 127.0.0.1 -P5000 -u root
mysql> create database
clusterdb;use clusterdb;
mysql> create table simples
(id int not null primary key) engine=ndb;
mysql> insert into simples values
(1),(2),(3),(4);