Skip to main content

Installation and Configuration of MySQL Cluster on CentOS 7

MySQL Cluster is designed to provide a MySQL compatible database with high availability and low latency. The MySQL Cluster technology is implemented through the NDB (Network DataBase) and NDBCLUSTER storage engines and provides shared-nothing clustering and auto-sharding for MySQL database systems.
To implement a MySQL Cluster, we have to install three types of nodes. Each node type will be installed on its own server. The components are:
1. Management Node - NDB_MGMD/MGM
    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.
2. Data Nodes - NDBD/NDB
    This is the layer where the process of synchronizing and data replication between nodes happens.
3. SQL Nodes - MySQLD/API
    The interface servers that are used by the applications to connect to the database cluster.
We will configure the management node, two data nodes, and two SQL nodes.

Prerequisites

The OS is CentOS 7 - 64bit.
3 CentOS servers or virtual machines. I will use the hostnames and IP addresses as shown below:
Management Node
        node0 = 192.168.34.3
Data Nodes
        node1 = 192.168.34.4
        node2 = 192.168.34.5
SQL Nodes
        node3 = 192.168.34.6
        node4 = 192.168.34.7

Step 1 - Setup Management Node

The first step is to create the "Management Node" with CentOS 7 node0 and IP 192.168.34.3. Make sure you are logged into the node0 server as the root user.

A. Download the MySQL Cluster software

Download it from the MySQL site with wget.

# cd ~
# wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.4/MySQL-Cluster-gpl-7.4.24-1.el7.x86_64.rpm-bundle.tar

# tar –xvf MySQL-Cluster-gpl-7.4.24-1.el7.x86_64.rpm-bundle.tar

B. Install and Remove Packages

Before you install the rpm package for MySQL Cluster, you need to install perl-Data-Dumper that is required by the MySQL-Cluster server. And you need to remove MariaDB-libs before we can install MySQL Cluster.

# yum -y install perl-Data-Dumper

# yum -y remove mariadb-libs

C. Install MySQL Cluster
Install MySQL Cluster package with these rpm commands:

cd ~
rpm -Uvh MySQL-Cluster-client-gpl-7.4.10-1.el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-server-gpl-7.4.10-1.el7.x86_64.rpm
rpm -Uvh MySQL-Cluster-shared-gpl-7.4.10-1.el7.x86_64.rpm

Note!! Do step A to C on all nodes on the clusters

D. Configure MySQL Cluster
Create a new directory for the configuration files.

mkdir -p /var/lib/mysql-cluster

Then create a new configuration file for the cluster management named "config.ini" in the mysql-cluster directory.
cd /var/lib/mysql-cluster
vi config.ini

Paste the configuration below:

[ndb_mgmd default]

# Directory for MGM node log files

DataDir=/var/lib/mysql-cluster

 

[ndb_mgmd]

#Management Node node0

HostName=192.168.34.3

 

[ndbd default]

NoOfReplicas=2      # Number of replicas

DataMemory=256M     # Memory allocate for data storage

IndexMemory=128M    # Memory allocate for index storage

#Directory for Data Node

DataDir=/var/lib/mysql-cluster

 

[ndbd]

#Data Node node1

HostName=192.168.34.4

 

[ndbd]

#Data Node node2

HostName=192.168.34.5

 

[mysqld]

#SQL Node node1

HostName=192.168.34.4

 

[mysqld]

#SQL Node node2

HostName=192.168.34.5
Save the file and exit.
E. Start the Management Node
Next start the management node with the command below:

# ndb_mgmd --config-file=/var/lib/mysql-cluster/config.ini

The result should be similar to this:

MySQL Cluster Management Server mysql-5.6.44 ndb-7.4.24
2019-06-06 10:20:49 [MgmtSrvr] INFO     -- The default config directory '/usr/mysql-cluster' does not exist. Trying to create it...
2019-06-06 10:20:49 [MgmtSrvr] INFO     -- Sucessfully created config directory

The management node is started, now you can use command "ndb_mgm" to monitor the node:

# ndb_mgm
   show


You can see the management node has been started with: mysql-5.6 and ndb-7.4.

Step 2 - Setup the MySQL Cluster Data Nodes

We will use 2 CentOS servers for the Data Nodes.
·         node1 = 192.168.34.4
·         node2 = 192.168.34.5

Repeat A to C in Step 1

D. Configure Data Node
Create a new configuration file in the /etc directory with the vi editor:

# vi /etc/my.cnf

Paste configuration below:

[mysqld]
ndb-nodeid=5
ndbcluster
# Define default Storage Engine used by MySQL
default_storage_engine=ndbcluster
ndb-connectstring=192.168.34.3

[mysql_cluster]
ndb-connectstring=192.168.34.3     # IP address of Management Node

Save the file and exit.

Then create the new directory for the database data that we defined in the management node config file "config.ini".

# mkdir -p /var/lib/mysql-cluster

Now start the data node/ndbd:

# ndbd

NB!! Make sure firewall is disabled or configured to allow access on port 1186

Results:


E. Redo step 2.A - 2.D on node2 server.
As we have 2 data nodes, redo the steps 2.A - 2.D on our second data node.

Step 3 - Setup SQL Node

This step contains the setup for the SQL Node that provides the application access to the database. We use the 2 CentOS servers of data nodes for the SQL Nodes:
·         node1 = 192.168.34.6
·         node2 = 192.168.34.7

Repeat A to C in Step 1

D. Configure the SQL Node
Create a new my.cnf file in the /etc directory:

# vi /etc/my.cnf

Paste configuration below:

[mysqld]
ndbcluster
ndb-connectstring=192.168.34.3     # IP address of Management Node

[mysql_cluster]
ndb-connectstring=192.168.34.3     # IP address of Management Node

Save the file and exit.
Start the SQL Node by starting the MySQL server:

# mysqld_safe --user=mysql &

NB!! Do not start mysql as root
E. Redo step 3.A - 3.D on node2 server.
Please redo the steps 3.A - 3.D on the second mysql server (node2).
The SQL node is started, now you can use command "ndb_mgm" to monitor the node:

# ndb_mgm
show






Comments

Popular posts from this blog

Oracle Database 19c Step by Step Installation On Oracle Linux 7.6

This post describes the installation of Oracle Database 19c 64-bit on Oracle Linux 7.6  x86-64 bit. The Linux server needs a minimum of 3G swap and secure Linux set to permissive. An example of this type of Linux installation can be seen here . Download Software Download the Oracle software from oracle edelivery . Oracle Installation Prerequisites Automatic Setup Use the "oracle-database-preinstall-19c" package to perform all your prerequisite setup. # yum install -y oracle-database-preinstall-19c If you are using RHEL7 or CentOS7, you can pick up the PRM from the OL7 repository and install it. It will pull the dependencies from your normal repositories. # yum install -y https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm Hosts File Set a fully qualified name for the server in the "/etc/hosts" file. < IP-address > < fully-qualified-machine-name > < machin...

How to Delete Old Trace & Dump files with ADRCI

The ADRCI command interpreter has multiple features:- Create a package with incident or problem information for Oracle Support Analyze diagnostic data within the Automatic Diagnostic Repository (ADR) Run health checks In this post, we'll be concentrating on deleting the old diagnostic files with ADRCI. Set your environment and run the ADRCI utility: $ adrci Use the following command to list the ADR homes: adrci> show home ADR Homes: diag/rdbms/db11g/DB11G diag/tnslsnr/sol10/listener Choose the ADR home from the list above: adrci> set home diag/rdbms/db11g/DB11G Check the current retention policy: adrci> show control Check the following columns in the output: LONGP_POLICY:- It is set to 365 days by default. It is responsible for Incidents and Health Monitor warnings. SHORTP_POLICY:- It is set to 30 days by default. It manages the trace and core dump files. Use the following commands to change the retention policy: Specify the time in hours: 10 Days = 240 ...

Oracle Database 12C Error Codes, Solutions and Suggestions from ORA-19700 to ORA-20000

Oracle 12C Error Codes, Solutions and Suggestions from ORA 19700 to ORA 20000 ORA-19700: device type exceeds maximum length of string Cause:  The device type indicated is invalid. Action:  Supply a correct device type and retry the allocation. ORA-19701: device name exceeds maximum length of  string Cause:  The device name indicated is invalid. Action:  Supply a correct device name and retry the allocation. ORA-19702: device parameter exceeds maximum length of  string ORA-19703: device command string exceeds maximum length of  string Cause:  The device command string exceeds maximum length. Action:  Correct the command and retry the operation. ORA-19704: file name exceeds maximum length of  string Cause:  The specified file name, which was a parameter to a copy, backup, or restore operation, exceeds the maximum file name length for this operating system. Action:  Retry the operation with a s...