This document provides instructions for a tutorial on installing and configuring MySQL Cluster 8.0 on a VirtualBox virtual machine. It describes importing a pre-configured VM appliance, then creating directory structures and configuration files to set up a MySQL Cluster with one management node, four data nodes, and three MySQL server nodes for testing high availability features.
2. 6 Backup and Restore 50
6.1 Taking a backup 51
6.2 OPT : Looking at backup filesets 52
6.3 OPT : Restoring a backup 54
6.3.1 Restoring metadata 55
6.3.2 Restoring data 57
6.3.3 Checking restored data 59
7 Joins, Foreign keys, JSON 60
7.1 Joining 61
7.2 Foreign keys 64
7.3 OPT : JSON 67
8 OPT : NdbInfo views 71
9 OPT : Synchronized Privileges 77
10 OPT : Addnode and rebalance data 80
10.1 Add nodes to configuration 82
10.2 Perform rolling restart of data nodes 84
10.3 Perform rolling restart of the MySQLD nodes 86
10.4 Start the new data nodes and create a nodegroup 87
10.5 Rebalance data across the nodes 89
11 Other features of MySQL Cluster 92
=============================================
1 Installation of MySQL Cluster 8.0 software
=============================================
1.1 VirtualBox VM 3
1.1.1 Importing the NdbVM appliance to create a VM 3
1.1.2 Using the NdbVM VM 3
1.1.3 Checking the installed software 4
MySQL Cluster 8.0 can be deployed on a number of platforms
including Linux, Solaris (SPARC/x86), MacOS and Windows.
On these platforms there are also multiple ways to install
the MySQL Cluster software including :
Using packages from Oracle for your OS
Using packages from your OS distributor
Using Docker container images from Oracle
Using generic binaries from Oracle
Additionally there are a number of ways to setup and run
MySQL Cluster once the software is installed :
Manually
Using MySQL Cluster Manager (MCM)
Using MySQL Cluster Installer
Using dbDeployer or other tools
These options (and more) are documented online at :
https://dev.mysql.com/doc/refman/8.0/en/mysqlclusterinstallation.html
The documentation acts as a tutorial and should be consulted
if attempting this elsewhere.
MySQL Cluster 8.0 tutorial v1.5 2/92
13. ==========================
3 Starting MySQL Cluster
==========================
3.1 Starting the Management server (MGMD) 13
3.1.1 Looking at the MGMD process 14
3.1.2 OPT : Looking at the MGMD files 14
3.2 Starting the Data nodes (NDBD) 14
3.2.1 Looking at the data node processes 16
3.2.2 OPT : Looking at the Data node files 17
3.3 Starting the MySQL Server processes (MySQLD) 18
3.3.1 Connecting as a MySQL client 18
Now that we have the binaries installed, and directories and
configuration files created, we are ready to start the cluster.
The cluster will be started in these steps :
Start management server (MGMD)
Start data nodes (NDBD)
Initialise and start MySQL Servers (MySQLD)
3.1 Starting the Management server (MGMD)
===========================================
The management server needs to be given :
The path to the cluster configuration file
A path to a location where it can store processed
configuration files.
Shell >
cd /home/ndb/cluster1/mgmd1
ndb_mgmd f /home/ndb/cluster1/cluster1_conf.ini
configdir=/home/ndb/cluster1/mgmd1/config
Example output
ndb@ndbVirtualBox:~/cluster1/mgmd1$ ndb_mgmd f
/home/ndb/cluster1/cluster1_conf.ini configdir=/home/ndb/cluster1/mgmd1/config
MySQL Cluster Management Server mysql8.0.19 ndb8.0.19
MySQL Cluster 8.0 tutorial v1.5 13/92
21. 4.3.1 Insert data 26
4.3.2 Read data using SQL 27
4.3.3 Read data using NdbApi 28
4.4 OPT : Look at binary logs 29
In this section we will have a look at the cluster which has been
started.
4.1 Using ndb_mgm
=================
The easiest way to get an overview of your cluster is to use the
management client, known as ndb_mgm.
This ndb_mgm tool provides a command line shell allowing queries
and commands to be sent over TCP to the management server (MGMD).
In this tutorial the management server is running on the default
host and port, so rather than issue :
ndb_mgm ndbconnectstring=localhost:1186
we can just type :
ndb_mgm
Shell >
ndb_mgm
Example output
ndb@ndbVirtualBox:~$ ndb_mgm
NDB Cluster Management Client
ndb_mgm>
The management client can be exited by typing :
exit
The most commonly used command in ndb_mgm is SHOW.
ndb_mgm >
MySQL Cluster 8.0 tutorial v1.5 21/92
22. show
Example output
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
[ndbd(NDB)] 4 node(s)
id=1 @127.0.0.1 (mysql8.0.19 ndb8.0.19, Nodegroup: 0, *)
id=2 @127.0.0.1 (mysql8.0.19 ndb8.0.19, Nodegroup: 0)
id=3 @127.0.0.1 (mysql8.0.19 ndb8.0.19, Nodegroup: 1)
id=4 @127.0.0.1 (mysql8.0.19 ndb8.0.19, Nodegroup: 1)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1 (mysql8.0.19 ndb8.0.19)
[mysqld(API)] 7 node(s)
id=11 @127.0.0.1 (mysql8.0.19 ndb8.0.19)
id=12 @127.0.0.1 (mysql8.0.19 ndb8.0.19)
id=13 @127.0.0.1 (mysql8.0.19 ndb8.0.19)
id=14 (not connected, accepting connect from any host)
id=15 (not connected, accepting connect from any host)
id=16 (not connected, accepting connect from any host)
id=17 (not connected, accepting connect from any host)
This output shows the 4 data nodes, 1 MGMD and 3 MySQLDs connected to
our cluster. All are connected from localhost (127.0.0.1).
As the cluster configuration is set to NoOfReplicas=2, each Nodegroup
contains 2 data nodes, and with 4 nodes, we have 2 Nodegroups (0 and 1)
Note that the ndb_mgm command can take a command to execute as a
parameter, so that it is also possible to run the show command
directly from the shell
e.g. :
Shell >
ndb_mgm e show
ndb_mgm has a number of other commands that can be seen using
the help command, including:
MySQL Cluster 8.0 tutorial v1.5 22/92
29. Example output :
ndb@ndbVirtualBox:~$ ndb_select_all dtutorial attendees
person_id name
9 "R Rackham"
7 "Alcazar"
3 "Snowy Dog"
6 "Dr Muller"
2 "B Castafiore"
4 "Nestor"
5 "Rastapopoulos"
1 "P Calculus"
8 "Ottokar"
9 rows returned
NDBT_ProgramExit: 0 OK
4.4 Look at binary logs
=========================
*** OPTIONAL : Read, or follow along in your VM ***
The MySQLD configuration is set up so that MySQLD1 and MySQLD2 write
binary logs (binlogs) containing changes to data stored in MySQL
Cluster, but MySQLD3 does not.
Note that MySQLD3 is configured to have a Binary log, but it will
only contain changes made locally on MySQLD3 to local schema objects.
mysql1 >
show variables like '%log_bin';
show binlog events;
Example output :
mysql1> show variables like '%log_bin';
+++
| Variable_name | Value |
+++
| log_bin | ON |
| ndb_log_bin | ON |
| sql_log_bin | ON |
+++
3 rows in set (0.00 sec)
mysql1> show binlog events;
MySQL Cluster 8.0 tutorial v1.5 29/92
48. id=2 (not connected, accepting connect from localhost)
id=3 (not connected, accepting connect from localhost)
id=4 (not connected, accepting connect from localhost)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1 (mysql8.0.19 ndb8.0.19)
[mysqld(API)] 7 node(s)
id=11 (not connected, accepting connect from any host)
id=12 (not connected, accepting connect from any host)
id=13 (not connected, accepting connect from any host)
id=14 (not connected, accepting connect from any host)
id=15 (not connected, accepting connect from any host)
id=16 (not connected, accepting connect from any host)
id=17 (not connected, accepting connect from any host)
ndb@ndbVirtualBox:~$ ps ef | grep mysqld
ndb 4547 3648 1 23:45 pts/2 00:00:03 mysqld defaults
file=/home/ndb/cluster1/mysqld1/mysqld.cnf
ndb 4548 3648 1 23:45 pts/2 00:00:03 mysqld defaults
file=/home/ndb/cluster1/mysqld2/mysqld.cnf
ndb 4549 3648 1 23:45 pts/2 00:00:03 mysqld defaults
file=/home/ndb/cluster1/mysqld3/mysqld.cnf
ndb 4743 3648 0 23:49 pts/2 00:00:00 grep color=auto mysqld
Notes
The data nodes have all failed.
The management node is available.
The management node reports that no MySQLDs are
available.
However they are running, just unable to connect to
the cluster as the data nodes are not up.
Now try to access cluster table data via mysql, this will fail.
Access to noncluster tables is ok.
Shell >
mysql2 e "select * from tutorial.attendees"
mysql2 e "select count(1) from mysql.user"
Expected output :
ndb@ndbVirtualBox:~$ mysql2 e "select * from tutorial.attendees"
ERROR 1296 (HY000) at line 1: Got error 4009 'Cluster Failure' from NDBCLUSTER
ndb@ndbVirtualBox:~$ mysql2 e "select count(1) from mysql.user"
++
MySQL Cluster 8.0 tutorial v1.5 48/92