MySql NDB Clustering
MySql NDB Clustering
Clustering will add high availability to our database by distributing changes to different servers.
In the event that one of the instances fails, others are quickly available to continue serving.
A MySQL Cluster consists of one or more management nodes (ndb_mgmd) that store the
cluster’s configuration and control the data nodes (ndbd), where cluster data is stored. After
communicating with the management node, clients (MySQL clients, servers, or native APIs)
connect directly to these data nodes.
We need 3 types of nodes to set up the complete cluster. They are management node, data
nodes & SQL node.
* Management node/server is used to manage other servers/nodes in the cluster, to add new
nodes in the cluster, start/restart/delete nodes in the cluster.
* Data node/server is the main storage server of the database files, it replicates databases with
other data nodes. This is the database cluster. High memory and storage should be avail on
data node servers.
* SQL node/server is the MySQL server/client which is used by application/php to connect to the
database cluster, working as an API. Actually, SQL node is the gateway engine between
application/php and database file.
System config:
We are using all cenOs 7 servers.
Start config:
We have to download the cluster bundle package in root directory. We can use wget to
download this rpm bundle on all these servers.
Link:
https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-8.0.
21-1.el7.x86_64.rpm-bundle.tar
tar -xvzf
This command will extract all tar files from this downloaded bundle.
This package need to install and remove from all these server:
yum -y install perl-Data-Dumper
yum -y remove mariadb-libs
Now we need to configure the MySQL cluster. Create a new directory where we want to setup
the cluster configureation.
mkdir -p /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
nano -w config.ini
[ndb_mgmd]
NodeId=1
HostName=192.168.7.133
[ndbd default]
NoOfReplicas=2
DataMemory=256M
IndexMemory=128M
DataDir=/var/lib/mysql-cluster
[ndbd]
NodeId=2
HostName=192.168.7.130
[ndbd]
NodeId=3
HostName=192.168.7.135
[mysqld]
NodeId =5
HostName=192.168.7.132
[mysqld]
NodeId=6
HostName=192.168.7.134
We can skip to mention nodeId, it will select the default nodeId then.
Save the file.
ndb_mgmd --config-file=/var/lib/mysql-cluster/config.ini
[mysql_cluster]
ndb-connectstring=192.168.7.133
Make sure the firewall port is open for 1186 and SELinux is disable for all nodes.
Try run the command ‘ndbd’ for both node
ndbd
[mysql_cluster]
ndb-connectstring=192.168.7.133
Restart all mysql services:
service mysqld restart
Complete this:
mysql_secure_installation