MySQL NDB Cluster has 3 major components:
We will discuss each of these 3 components in turn:
The Cluster management server is used to manage the other node of the cluster. We can create and configure new nodes, restart, delete, or backup nodes on the cluster from the management node. In nutshell, the management node is used to control the cluster engine and observe it as a monitoring tool:
Installing the management node binaries:
[root@mysqlndbmgm ~]# rpm -Uvh mysql-cluster-community-management-server-7.5.7-1.el7.x86_64.rpm Preparing... ################################# [100%] package mysql-cluster-community-management-server-7.5.7-1.el7.x86_64 is already installed [root@mysqlndbmgm ~]#
Configuration:
[root@mysqlndbmgm mysql-cluster]# cat >> /var/lib/mysql-cluster/config.ini << EOF [ndb_mgmd default] # Directory for MGM node log files DataDir=/var/lib/mysql-cluster [ndb_mgmd] #Management Node db1 HostName=192.168.0.100 [ndbd default] NoOfReplicas=2 # Number of replicas DataMemory=64M # Memory allocate for data storage IndexMemory=64M # Memory allocate for index storage #Directory for Data Node DataDir=/var/lib/mysql-cluster [ndbd] #Data Node db2 HostName=192.168.0.110 [ndbd] #Data Node db3 HostName=192.168.0.120 [mysqld] #SQL Node db4 HostName=192.168.0.210 [mysqld] #SQL Node db5 HostName=192.168.0.220 [root@mysqlndbmgm mysql-cluster]# EOF
Starting:
ndb_mgmd --config-file=/var/lib/mysql-cluster/config.iniShow configuration:
[root@mysqlsqlnodea ~]# ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: 192.168.0.100:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @192.168.0.110 (mysql-5.7.19 ndb-7.5.7, Nodegroup: 0, *) id=3 @192.168.0.120 (mysql-5.7.19 ndb-7.5.7, Nodegroup: 0) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.0.100 (mysql-5.7.19 ndb-7.5.7) [mysqld(API)] 2 node(s) id=4 @192.168.0.210 (mysql-5.7.19 ndb-7.5.7) id=5 @192.168.0.220 (mysql-5.7.19 ndb-7.5.7) ndb_mgm>
The interface servers that are used by the applications to connect to the database cluster. This is where the mysqld is started and the databases are available.
Installation:
[root@mysqlsqlnodea ~]# rpm -Uvh mysql-cluster-community-server-7.5.7-1.el7.x86_64.rpm warning: mysql-cluster-community-server-7.5.7-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ################################# [100%] package mysql-cluster-community-server-7.5.7-1.el7.x86_64 is already installed [root@mysqlsqlnodea ~]#
Configuration:
cat >> /etc/my.cnf << EOF [mysqld] ndb-connectstring=192.168.0.100:1186 ndb-nodeid=N ndbcluster datadir=/var/lib/mysql/data basedir=/var/lib/mysql server-id=N log-bin [mysql_cluster] ndb-connectstring=192.168.0.100 EOF
Starting a SQL Node:
service mysqld start
or on Linux 7+
systemctl start mysql
This is the layer where the process of synchronizing and data replication between nodes happens.
Installing the data node:
[root@mysqldatanodea ~]# rpm -Uvh mysql-cluster-community-data-node-7.5.7-1.el7.x86_64.rpm Preparing... ################################# [100%] package mysql-cluster-community-data-node-7.5.7-1.el7.x86_64 is already installed
Configuration:
[root@mysqldatanodea ~]# cat >> /etc/my.cnf << EOF [mysqld] ndbcluster ndb-connectstring=192.168.0.100 # IP address of Management Node [mysql_cluster] ndb-connectstring=192.168.0.100 # IP address of Management Node EOF
Starting NDB Data node
[root@mysqldatanodea ~]# ndbd 2017-10-17 11:13:58 [ndbd] INFO -- Angel connected to '192.168.0.100:1186' 2017-10-17 11:13:58 [ndbd] INFO -- Angel allocated nodeid: 2 [root@mysqldatanodea ~]#