NDB Cluster is a technology that enables clustering of in-memory databases in a shared-nothing system. The shared-nothing architecture enables the system to work with very inexpensive hardware, and with a minimum of specific requirements for hardware or software.
Find a file
2025-07-08 06:09:27 +00:00
cluster-components-1.png MySQL NDB Cluster concept drawing 2024-06-27 19:16:59 +00:00
README.md Update file README.md 2025-07-08 06:09:27 +00:00

Installation MySQL NDBCluster Ubuntu 24.04 Noble

Sample IP Subnett 10.0.0.0/24

Node 1 	(MGM)       : 10.0.0.245
Node 2, 3 (Data)    : 10.0.0.246, 10.0.0.247
Node 4, 5 (MySQL)   : 10.0.0.246, 10.0.0.247

Installation on: DATA / MySQL Nodes (10.0.0.246 og 10.0.0.247)##

Updates and preparations

sudo apt update -y
sudo apt upgrade -y
sudo apt install libclass-methodmaker-perl -y
sudo apt install libaio1t64 libmecab2 -y			

libaio1 was replaced with libaio1t64 in Ubuntu 24.04 Noble

sudo dpkg -i *.deb

sudo mkdir -p /var/lib/mysql/
sudo chown -R mysql:mysql /var/lib/mysql/

sudo nano /etc/systemd/system/ndbd.service

[Unit]
Description=MySQL NDB Data Node Daemon
After=network.target auditd.service

[Service]
Type=forking
ExecStart=/usr/sbin/ndbd
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

sudo systemctl enable ndbd

sudo nano /etc/mysql/my.cnf

[mysqld]
ndbcluster
ndb-connectstring=10.0.0.245 #IP of Managament Node
mysql_native_password=ON
skip_name_resolve

[mysql_cluster]
ndb-connectstring=10.0.0.245 #IP of Managament Node

Installation on: Management Node (10.0.0.245)

mkdir -p /usr/mysql-cluster

nano /usr/mysql-cluster/config.ini

(You probably have to CHOWN or CHMOD according to which user the process [ndb_mgmd] runs as)

[ndbd default] # Options affecting ndbd processes on all data nodes:
NoOfReplicas=2  # Number of replicas
DataMemory=6G
TransactionMemory=1G
TransactionBufferMemory=1G
# NoOfFragmentLogFiles=10000

## Important, do NOT forget this if you expect a good sized database
## The default tablespace is very limited 
InitialLogFileGroup=name=lg_1;undo_buffer_size=200M; undo_lg_1.log:200M; undo_lg_2.log:150M
InitialTablespace=name=ts_1;extent_size=16M;ts_1.dat:2G

## Performance related, each parameter should be researched before activated ##
# MaxNoOfConcurrentOperations=100000
# MaxNoOfTables=4096
# MaxNoOfTriggers=3500
# MaxNoOfAttributes=25000

[ndb_mgmd]
# Management process options:
hostname=10.0.0.245  # Hostname of the Management NOde
datadir=/usr/mysql-cluster  # Directory for the log files

[ndbd]
hostname=10.0.0.246  # Hostname/IP of the first data node
nodeid=2  # Node ID for this data node
datadir=/var/lib/mysql/  # Remote directory for the data files

[ndbd]
hostname=10.0.0.247  # Hostname/IP of the second data node
nodeid=3 # Node ID for this data node
datadir=/var/lib/mysql/  # Remote directory for the data files

[mysqld]
nodeid=4
hostname=10.0.0.246 #SQL Node 1

[mysqld]
nodeid=5
hostname=10.0.0.247 #SQL Node 2

sudo nano /etc/systemd/system/ndb_mgmd.service

[Unit]
Description=MySQL NDB Cluster Management Server
After=network.target auditd.service

[Service]
Type=forking
ExecStart=/usr/sbin/ndb_mgmd -f /usr/mysql-cluster/config.ini
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable ndb_mgmd service and reload systemd to apply changes

sudo systemctl enable ndb_mgmd sudo systemctl daemon-reload

On management Node, it runs the first initial apply of config.ini to the nbdcluster.

ndb_mgmd --initial --config-file=/usr/mysql-cluster/config.ini

Run this on each of the Data nodes once nbd_mgmd is running (can check "sudo tail -f xxx_1_cluster.log")

ndbd

When each data node running ndbd output something similar to the below... start MySQL

2023-02-16 04:28:00 [ndbd] INFO     -- Angel connected to '10.0.0.245:1186'
2023-02-16 04:28:00 [ndbd] INFO     -- Angel allocated nodeid: 2

sudo service mysql start

(start or restart)

ndb_mgm -e show

(On either [data] node run the above command to see cluster status)

The output will be like below

Connected to management server at 10.0.0.245 port 1186 (using cleartext)
Cluster Configuration
---------------------
[ndbd(NDB)]	2 node(s)
id=2	@10.0.0.246  (mysql-8.4.0 ndb-8.4.0, Nodegroup: 0, *)
id=3	@10.0.0.247  (mysql-8.4.0 ndb-8.4.0, Nodegroup: 0)

[ndb_mgmd(MGM)]	1 node(s)
id=1	@10.0.0.245  (mysql-8.4.0 ndb-8.4.0)

[mysqld(API)]	2 node(s)
id=4	@10.0.0.246  (mysql-8.4.0 ndb-8.4.0)
id=5	@10.0.0.247  (mysql-8.4.0 ndb-8.4.0)

Cluster Maintenance

Shut down cluster

# On either of the Data nodes (node 2 or 3) run command sudo ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> shutdown
Connected to management server at 10.100.10.80 port 1186 (using cleartext)
Node 2: Cluster shutdown initiated
Node 3: Cluster shutdown initiated
Node 2: Node shutdown completed.
Node 3: Node shutdown completed.
3 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.

# Shut down MySQL service on both data nodes (node 2 and 3)
sudo service mysql stop

Start Cluster Master Node

# On master node (Node 1) run command:
sudo service ndb_mgmd start

# Verify that service started on master node
sudo service ndb_mgmd status

# Starting the NDB cluster can take a long time, especially on large databases.
# So monitor the startup progress on Node 2 or 3 

ndb_mgm
show 
ndb_mgm> show

Cluster Configuration
---------------------
[ndbd(NDB)]	2 node(s)
id=2	@10.100.10.81  (mysql-8.4.0 ndb-8.4.0, starting, Nodegroup: 0, *)
id=3	@10.100.10.82  (mysql-8.4.0 ndb-8.4.0, starting, Nodegroup: 0)

[ndb_mgmd(MGM)]	1 node(s)
id=1	@10.100.10.80  (mysql-8.4.0 ndb-8.4.0)

[mysqld(API)]	2 node(s)
id=4 (not connected, accepting connect from 10.100.10.81)
id=5 (not connected, accepting connect from 10.100.10.82)

ndb_mgm> ALL REPORT MemoryUsage
Node 2: Data usage is 57%(718194 32K pages of total 1242554)
Node 2: Index usage is 11%(68166 32K pages of total 592526)
Node 3: Data usage is 57%(716424 32K pages of total 1242554)
Node 3: Index usage is 11%(68166 32K pages of total 594296)

Start Cluster API Node 2 and Node 3

# On API node (Node 2 and 3) run command:
sudo ndbd

Start Cluster MySQL on Node 2 and Node 3

# Make sure that the cluster is actually up and running before you start MySQL.
ndb_mgm
ndb_mgm> show

# Then when the cluster is running properly, run the below command on MySQL node (Node 2 and 3):
sudo service mysql start