How To Create a Multi-Node MySQL Cluster on Ubuntu 20.04. In this post, we will introduce MySQL Cluster, and its major components. Then, we will explain how to set up three node MySQL cluster on Ubuntu 20.04.
A collection of commodity components, providing scalability and availability at a low cost, clusters, store and process the information on commodity nodes. This way, creating a database cluster for high end enterprise applications is relatively effortless. Cluster database architecture distinguishes itself through data responsibilities shared among different computer nodes.
Let’s start this article blog How To Create a Multi-Node MySQL Cluster on Ubuntu 20.04.
First of all, MySQL Cluster is a distributed database that merges linear scalability and high availability to provide in memory real time access with transactional consistencies created for a mission critical application.
This fault tolerant in memory clustered database entirely runs on cost effective commodity hardware. This way, in memory database clustering is performed in shared nothing systems. This architecture further enables the system to work with the least specific hardware and software requirements.
MySQL Clusters constitute the following components:
Data Nodes
With the help of Data Nodes, you can store data in a MySQLcluster environment. Actually, it imitates data nodes, making them available whenever one or more storage nodes fail. After, the stored data is visible to every MySQL server connected to the cluster. Moreover, data nodes handle the entire database transactions. However, some MySQL data, like permissions and stored procedures, cannot be stored in the cluster and should be updated on every MySQL server attached to the cluster.
Management Client
Additionally, this client program manages your cluster. Basically, it delivers every administrative functionality, like starting and stopping nodes, getting status information, and creating backups.
Applications
Applications connect to the MySQL cluster exactly as they connect to the MySQL cluster through MySQL Server. So, if you use another MySQL storage engine, they will use group applications. However, your application may specifically need to handle cluster specific features.
Management Server Nodes
Besides, Administration Server nodes handle system configuration an used it to reconfigure the cluster. As a result, the server node management should only run during system start up and reconfiguration. Other components of the MySQL cluster can work without relying on the Central Management Server node.
MySQL Server Nodes
Certainly, these nodes run on a MySQL server that has access to cluster storage. Multiple MySQL servers can be connected to a cluster. Consequently, it provides redundancy and performance through parallel processing. When you perform updates on one MySQL server, they are immediately reflected on other servers connected to the cluster.
How To Create a Multi-Node MySQL Cluster on Ubuntu 20.04
In this section, we will explain how to create three node MySQL cluster on a system running Ubuntu 20.04 server.
To demonstrate this article, we will use the following setup:
Step 1 - Install and Configure Cluster Manager
First, you will need to download and install the MySQL Cluster Manager package on the manager node. Please download the latest version of MySQL Cluster Manager from the MySQL official download page.
Add the following lines to define your manager node and data nodes:
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
[ndb_mgmd]
# Management process options:
hostname=192.168.10.10 # Hostname of the manager
datadir=/var/lib/mysql-cluster # Directory for the log files
[ndbd]
hostname=192.168.10.11 # Hostname/IP of the first data node
NodeId=2 # Node ID for this data node
datadir=/usr/local/mysql/data # Remote directory for the data files
[ndbd]
hostname=192.168.10.12 # Hostname/IP of the second data node
NodeId=3 # Node ID for this data node
datadir=/usr/local/mysql/data # Remote directory for the data files
[mysqld]
# SQL node options:
hostname=192.168.10.10 # In our case the MySQL server/client is on the same Droplet as the cluster manager
Save and close the file then start the manager with the following command:
ndb_mgmd -f /var/lib/mysql-cluster/config.ini
You will get the following output:
MySQL Cluster Management Server mysql-8.0.31 ndb-8.0.31
2022-10-23 04:31:49 [MgmtSrvr] INFO -- The default config directory '/usr/mysql-cluster' does not exist. Trying to create it...
2022-10-23 04:31:49 [MgmtSrvr] INFO -- Sucessfully created config directory
As you can see, the MySQL Cluster Manager is installed and running. Now, kill the running server and create a systemd file for Cluster manager:
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
[mysql_cluster]
# Options for NDB Cluster processes:
ndb-connectstring=192.168.10.10 # location of management server
6. Save and close the file then restart the MySQL service to apply the changes:
How To Create a Multi-Node MySQL Cluster on Ubuntu 20.04 Conclusion
In this post, we explained how to set up a multi-node MySQL cluster on Ubuntu 20.04 server. You can now use this setup in the production environment to achieve scalability and high availability.
In short, MySQL clusters replicates each other across multiple geographical built-in sites. Moreover, a shared nothing architecture with data locality awareness makes it a perfect choice for running on commodity hardware and globally distributed cloud infrastructure.
Why don’t you take a look at our blog with more MySQL content over here.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
3.84votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.