Managing a MySQL NDB Cluster installation with its potential for multiple nodes and sites can prove challenging for most DBAs. MySQL Cluster Manager was developed to alleviate this challenge.
MySQL Cluster Manager, or MCM, is a component of MySQL NDB Cluster Carrier Grade Edition, and provides a command-line interface that automates common management tasks, including configuring, starting and stopping the MySQL NDB Cluster, and much, much more. In this blog we will dive into the basics of downloading and installing MCM, and bootstrapping a cluster on a single host.
MCM Operations, Components, and Concepts
MCM supports, and greatly simplifies, a number of operations that typically involve a large number of manual commands to perform for a DBA, such as
- Configuring and starting MySQL NDB Cluster
- Upgrades
- Adding and removing cluster nodes
- Adding and removing site hosts
- Configuration changes
- Backup and restore
The three main components of MCM are:
- mcmd – the MCM agent binary
- mcm – the MCM client
- NDB – the MySQL NDB Cluster binaries
There are 4 basic terminology concepts you should know before starting to use MCM:
- Host – a physical/cloud host, or VM
- Site – a managed group of hosts on which a cluster may be configured
- Package – a logical name for a set of install paths across hosts in a site
- Cluster – a logical name for a set of cluster processes running across hosts in a site
Each host in the site needs to run the mcmd process to orchestrate its local NDB processes.
MCM runs its group communication system (XCOM) as a messaging bus between all mcmd processes in a site, ensuring message delivery, ordering, and (eventual) consistency.
Install
MySQL Cluster Manager can be downloaded from the My Oracle Support (MOS) website or on Oracle Software Delivery Cloud at http://edelivery.oracle.com.
Download the appropriate package for your platform. In this blogpost we will use OCI cloud VMs running Oracle Linux 8, although MCM works equally well on multiple platforms, as well as on-premise hardware. You will also need to download a MySQL NDB Cluster package. There is a convenience package provided for generic linux, that bundles MCM and MySQL NDB Cluster in a single tarball. To make the examples more general, we will use the generic linux tarballs in the following examples.
Extract the tarball to the desired install location
$ cd /export/home/tmp/foo
$ tar zxvf ./mcm-8.4.4-linux-glibc2.28-x86-64bit.tar.gz
...
$ tar zxvf ./mysql-cluster-commercial-8.4.4-linux-glibc2.28-x86_64.tar.gz
...
$ cd mcm-8.4.4-linux-glibc2.28-x86-64bit
$ ln -s ../mysql-cluster-commercial-8.4.4-linux-glibc2.28-x86_64 cluster
MCM expects to find the default NDB install in a folder named cluster, hence we softlink the extracted cluster folder.
$ tree -L 1
.
|-- cluster -> ../mysql-cluster-commercial-8.4.4-linux-glibc2.28-x86_64
`-- mcm8.4.4
Version
mcmd will display its version information in normal MySQL fashion using the --version option
$ ./bin/mcmd --version
MySQL Cluster Manager v8.4.4 on linux-glibc2.28 (64-bit) (MySQL Enterprise - Commercial)
Bootstrap
MCMs --bootstrap option is the simplest way to get your NDB cluster up and running.
In about 30 seconds it starts a newly created MySQL NDB Cluster instance, with two datanodes, one management server, and two mysqlds already connected and running.
$ ./bin/mcmd --bootstrap
MySQL Cluster Manager 8.4.4 (64bit) started
Connect with "/export/home/tmp/foo/mcm-8.4.4-linux-glibc2.28-x86-64bit/mcm8.4.4/bin/mcm" -h lagoon -P 1862
Configuring default cluster 'mycluster'...
Setting default_storage_engine to ndbcluster...
Starting default cluster 'mycluster' version '8.4.4-cluster'...
Cluster 'mycluster' started successfully
ndb_mgmd lagoon:1186
ndbmtd lagoon
ndbmtd lagoon
mysqld lagoon:3306
mysqld lagoon:3307
ndbapi *
Connect to the database by running "/export/home/tmp/foo/mcm-8.4.4-linux-glibc2.28-x86-64bit/cluster/bin/mysql" -h 127.0.0.1 -P 3306 -u root
The bootstrap option creates a site named mysite, a package named mypackage, and a cluster named mycluster. Do note that the NDB cluster created with the –bootstrap option has certain limitations. The option is there to help you get going in a flash.
The mcm client
The MCM command line client is mcm, found in the ./bin folder of the MCM install.
$ ./bin/mcm --version
./bin/mcm Ver 8.4.4-commercial for Linux on x86_64 (MySQL Enterprise Server - Commercial)
It shares command line options and most functionality with the familiar mysql client, although with slightly different defaults.
You may connect to any of the hosts/mcmd processes in the site to manage your cluster.
$ ./bin/mcm
Welcome to the MySQL Cluster Manager client. Commands end with ; or \g.
Your connection id is 1
Agent version: 8.4.4 MySQL Cluster Manager
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mcm>
Basic usage
Using the mcm client we can now have a look at our bootstrapped NDB cluster.
The MCM list commands command shows all available management commands:
mcm> list commands;
+---------------------------------------------------------------------------------------------+
| Help |
+---------------------------------------------------------------------------------------------+
| COMMANDS |
| |
| abort backup Abort an ongoing cluster backup. |
| add hosts Add hosts to site. |
| add package Add a package alias. |
| add process Add cluster process. |
| autotune Autotune a cluster to given use-case template. |
| backup agents Backup the agents repository and metadata. |
| backup cluster Backup a cluster. |
| change log-level Change the log-level |
| change process Change process type. |
| collect logs Collect log files. |
| create certs Create certificates. |
| create cluster Create a cluster. |
| create site Create a site. |
| delete backup Delete backup image. |
| delete cluster Delete a cluster. |
| delete package Delete a package. |
| delete site Delete a site. |
| get Get configuration variables. |
| import cluster Import a running cluster. |
| import config Import the configuration of a running cluster. |
| list backups List backup images. |
| list clusters List all clusters. |
| list commands List the help text. |
| list hosts List hosts in site. |
| list nextnodeids List next nodeids to be allocated. |
| list packages List all packages. |
| list processes List processes. |
| list sites List all sites. |
| list warnings List warnings. |
| remove hosts Remove hosts from site. |
| remove process Remove a cluster process. |
| reset Reset configuration variables. |
| restart cluster Restart a cluster. |
| restore cluster Restore a cluster. |
| rotate log Rotate the mcmd log. |
| set Set configuration variables. |
| show settings Show agent settings. |
| show status Show cluster, process, operation, progress or backup status. |
| show warnings Show warnings. |
| start cluster Start a cluster. |
| start process Start a cluster process. |
| stop agents Stop agents in site. |
| stop cluster Stop a cluster. |
| stop process Stop a cluster process. |
| update process Update a cluster process. |
| upgrade cluster Upgrade a cluster. |
| version Print version information. |
| |
| GLOBAL OPTIONS |
| Options that can be used with all commands |
| |
| --help|-? Print detailed help. |
| |
| Use '<COMMAND> --help' to see verbose help for individual commands. |
+---------------------------------------------------------------------------------------------+
56 rows in set (0.00 sec)
There are a couple of list commands to list sites, packages, and clusters:
mcm> list sites;
+--------+------+-------+--------+
| Site | Port | Local | Hosts |
+--------+------+-------+--------+
| mysite | 1862 | Local | lagoon |
+--------+------+-------+--------+
1 row in set (0.10 sec)
mcm> list packages mysite;
+-----------+------------------------------------------------------------------+--------+
| Package | Path | Hosts |
+-----------+------------------------------------------------------------------+--------+
| mypackage | /export/home/tmp/foo/mcm-8.4.4-linux-glibc2.28-x86-64bit/cluster | lagoon |
+-----------+------------------------------------------------------------------+--------+
1 row in set (0.10 sec)
mcm> list clusters mysite;
+-----------+-----------+
| Cluster | Package |
+-----------+-----------+
| mycluster | mypackage |
+-----------+-----------+
1 row in set (0.10 sec)
Using the show status command we can inspect our newly bootstrapped cluster
mcm> show status mycluster;
+-----------+-------------------+---------+
| Cluster | Status | Comment |
+-----------+-------------------+---------+
| mycluster | fully operational | |
+-----------+-------------------+---------+
1 row in set (0.10 sec)
or with more details per process
mcm> show status --process mycluster;
+--------+----------+--------+---------+-----------+-----------+
| NodeId | Process | Host | Status | Nodegroup | Package |
+--------+----------+--------+---------+-----------+-----------+
| 145 | ndb_mgmd | lagoon | running | | mypackage |
| 1 | ndbmtd | lagoon | running | 0 | mypackage |
| 2 | ndbmtd | lagoon | running | 0 | mypackage |
| 146 | mysqld | lagoon | running | | mypackage |
| 147 | mysqld | lagoon | running | | mypackage |
| 148 | ndbapi | * | added | | |
+--------+----------+--------+---------+-----------+-----------+
6 rows in set (0.10 sec)
Managing MySQL NDB Cluster
We can stop and start the complete cluster
mcm> stop cluster mycluster;
+------------------------------+
| Command result |
+------------------------------+
| Cluster stopped successfully |
+------------------------------+
1 row in set (15.73 sec)
mcm> show status mycluster;
+-----------+---------+---------+
| Cluster | Status | Comment |
+-----------+---------+---------+
| mycluster | stopped | |
+-----------+---------+---------+
1 row in set (0.11 sec)
mcm> start cluster mycluster;
+------------------------------+
| Command result |
+------------------------------+
| Cluster started successfully |
+------------------------------+
1 row in set (12.83 sec)
… or individual processes of the cluster, in this case mysqld 146.
mcm> stop process 146 mycluster;
+------------------------------+
| Command result |
+------------------------------+
| Process stopped successfully |
+------------------------------+
1 row in set (6.11 sec)
mcm> show status --process mycluster;
+--------+----------+--------+---------+-----------+-----------+
| NodeId | Process | Host | Status | Nodegroup | Package |
+--------+----------+--------+---------+-----------+-----------+
| 145 | ndb_mgmd | lagoon | running | | mypackage |
| 1 | ndbmtd | lagoon | running | 0 | mypackage |
| 2 | ndbmtd | lagoon | running | 0 | mypackage |
| 146 | mysqld | lagoon | stopped | | mypackage |
| 147 | mysqld | lagoon | running | | mypackage |
| 148 | ndbapi | * | added | | |
+--------+----------+--------+---------+-----------+-----------+
6 rows in set (0.10 sec)
mcm> start process 146 mycluster;
+------------------------------+
| Command result |
+------------------------------+
| Process started successfully |
+------------------------------+
1 row in set (2.50 sec)
Configuration parameters for NDB can be altered using the get and set commands.
mcm> get -d port:mysqld mycluster;
+------+-------+----------+---------+----------+---------+-------+---------+
| Name | Value | Process1 | NodeId1 | Process2 | NodeId2 | Level | Comment |
+------+-------+----------+---------+----------+---------+-------+---------+
| port | 3306 | mysqld | 146 | | | | |
| port | 3307 | mysqld | 147 | | | | |
+------+-------+----------+---------+----------+---------+-------+---------+
2 rows in set (0.10 sec)
To clean up completely, we delete the cluster, package, the site, and finally stop all agents
mcm> delete cluster mycluster;
+------------------------------+
| Command result |
+------------------------------+
| Cluster deleted successfully |
+------------------------------+
1 row in set (0.30 sec)
mcm> delete package mypackage;
+------------------------------+
| Command result |
+------------------------------+
| Package deleted successfully |
+------------------------------+
1 row in set (0.10 sec)
mcm> delete site mysite;
+---------------------------+
| Command result |
+---------------------------+
| Site deleted successfully |
+---------------------------+
1 row in set (0.10 sec)
mcm> stop agents mysite;
+-----------------------------+
| Command result |
+-----------------------------+
| Agents stopped successfully |
+-----------------------------+
1 row in set (0.10 sec)
With the last command mcmd exits.
There is an extensive manual covering MCM at https://dev.mysql.com/doc/mysql-cluster-manager/8.4/en/.
Summary
As demonstrated, MySQL Cluster Manager simplifies and improves ease of use of MySQL NDB Cluster. It is simple to install and setup, easy to get going, robust, and handles complex and time consuming manual operations. In the next blog we will cover management of a multi-host setup, backup and restore, scaling and upgrade of NDB.
Now, get going – and enjoy!
