SlideShare a Scribd company logo
1 of 65
Download to read offline
MySQL Cluster Engineering
January 31, 2020
Frazer Clement
MySQL Ndb 8.0 Cluster tutorial
2 © 2020 Oracle
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon in
making purchasing decisions. The development, release, timing, and pricing of any features
or functionality described for Oracle’s products may change and remains at the sole
discretion of Oracle Corporation.
Statements in this presentation relating to Oracle’s future plans, expectations, beliefs,
intentions and prospects are “forward-looking statements” and are subject to material risks
and uncertainties. A detailed discussion of these factors and other risks that affect our
business is contained in Oracle’s Securities and Exchange Commission (SEC) filings,
including our most recent reports on Form 10-K and Form 10-Q under the heading “Risk
Factors.” These filings are available on the SEC’s website or on Oracle’s website at 
http://www.oracle.com/investor. All information in this presentation is current as of January
2020 and Oracle undertakes no duty to update any statement in light of new information or
future events.
Safe harbor statement
3 © 2020 Oracle
You can follow the steps on your own machine, using a VirtualBox VM for simplicity
You will need to install VirtualBox and the NdbVM virtual machine.
●
There are USB sticks available with :
●
[VirtualBox install binaries for Windows, Mac OS X, Linux generic]
●
VM appliance (NdbVM.ova) for importing NdbVM into VirtualBox
●
~4GB RAM, ~ x GB disk space
Steps :
1) Copy files from USB stick onto your machine
2) Install VirtualBox
3) Import VM appliance into VirtualBox to create a VM (wait...)
4) Start the VM
How to follow the tutorial on your machine
4 © 2020 Oracle
Introduction
MySQL Ndb Cluster 8.0
Installation
Configuration
Starting a cluster
Exploring the cluster
High Availability
Backup and Restore
Joins, Foreign Keys, JSON
NdbInfo views
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb Cluster 8.0 tutorial
MGMD
NDBD
NDBD
NDBD
NDBD
NDBD
NDBD
MY MY MY
Some (sub)sections are optional and
can be skipped as necessary
5 © 2020 Oracle
●
Learn about MySQL Ndb Cluster 8.0
●
See MySQL Cluster 8.0 setup and running
●
See some of the features of MySQL Cluster
●
Setup and use your own MySQL Cluster
Introduction : Goals
6 © 2020 Oracle
●
Discussion, Slides, Demonstration
●
Follow along on your own machine in a virtual machine
●
VM contains a text file with instructions :
/home/ndb/cluster_tutorial.txt
●
Instructions can be followed, commands pasted in, example output
compared with your own
●
Some sections can be skipped
Introduction : Tutorial format
7 © 2020 Oracle
5.1   Kill one data node
========================
For this tutorial, all data node processes are running in the same
VM, but we can identify them by their ­­nodeid= suffix.
We can use this suffix to kill both the Angel and Worker processes
around the same time using the pkill command.
Shell >
­­­­­­­­­­
ps ­ef | grep ndbmtd
pkill ­f nodeid=1
ps ­ef | grep ndbmtd
­­­­­­­­­­
    Example output :
      ndb@ndb­VirtualBox:~$ ps ­ef | grep ndbmtd
      ndb       3033     1  0 18:41 ?        00:00:01 ndbmtd –ndb­nodeid=1
      ndb       3035  3033  2 18:41 ?        00:04:57 ndbmtd –ndb­nodeid=1
      ndb       3040     1  0 18:41 ?        00:00:02 ndbmtd –ndb­nodeid=2
      ...
Introduction : /home/ndb/cluster_tutorial.txt
8 © 2020 Oracle
MySQL Ndb Cluster
MySQL (Ndb) Cluster is used in critical applications where the highest availability and
highest write scalability with low stable latency and efficiency are required :
- Telecoms core networks
- Massive online games
- Stock exchange trade analysis
- Web site session stores
- Single sign-on and authentication use cases
- …
MySQL Cluster is backed by Oracle, with Oracle Support contracts available
MySQL Cluster is mature, proven and dependable.
MySQL Cluster is fully documented open source.
https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster.html
9 © 2020 Oracle
MySQL Ndb Cluster
MySQL (Ndb) Cluster is a distributed, highly available and scalable version of MySQL
MySQL Cluster allows MySQL Server instances to access and operate on data stored in a
separate set of servers known as Data nodes.
Data nodes provide a highly available and scalable transactional query and data service to a
number of MySQL Servers, or other clients.
NDBD
NDBD
MY
NDBD
NDBD
MY
NDBD
NDBD
MY
NDBD
NDBD
MY
NDBD
NDBD
MY
NDBD
NDBD
MY
NDBD
NDBD
MY
NDBD
NDBD
MYSQL
DATA
10 © 2020 Oracle
MySQL Ndb Cluster concepts : Distributed system
- MySQL Cluster is a shared nothing system - processes on different machines communicate
with each other to form a cluster of nodes
- Data nodes collaborate to store tables and indexes, and
implement constraints, transactions, joins, backup, checkpointing
and other high availability features
- Data and indexes are automatically partitioned (sharded) across
Nodegroups
- All data is query-able, modifiable and consistent at all times
- Row locking and two phase commit is used within and between
Nodegroups
- Data nodes have a native (NoSQL) interface called NdbApi, accessible
from C++, Java, ...
- MySQLD nodes provide a SQL interface and the MySQL async replication interface
(Binlogs), implemented using NdbApi, alongside all the usual MySQL functionality
NDBD
NDBD
MY
NDBD
NDBD
MY
11 © 2020 Oracle
MySQL Ndb Cluster concepts : Replicas and Scaling
- Up to 4 data nodes (NDBD) replicate their data synchronously within a NodeGroup for high
availability and read scaling.
- A cluster can scale out online by adding nodegroups, increasing the total resources
available and scaling write throughput
- A cluster can scale out SQL capacity and redundancy online by adding MySQLD or other
clients
NDBD
NDBD
NDBD
NDBD
1-4 replicas
NDBD
NDBD
NDBD
NDBD
NDBD
NDBD
NDBD
NDBD
MY MY MY
Scale out Nodegroups Scale out MySQL Servers
12 © 2020 Oracle
MySQL Ndb Cluster concepts : Online operations
MySQL Cluster supports online operations for high availability - queries and writing
transactions experience minimal disturbance during :
- Schema changes
- Add column
- Add index / Drop index
- Operations
- Backup
- Software upgrade
- Hardware upgrade
- Scale out nodegroups
- Scale out MySQLDs
- Incidents
- Node failure
- Node recovery
99.9999%
13 © 2020 Oracle
MySQL Ndb Cluster concepts : MySQL Server
Ndb storage engine implementation
Handler / Storage Engine Api
SQL parsing, optimisation, execution
Client threads
NdbApi
Network communication with data nodes
MySQL clients MySQL clients MySQL clients
Generic
MySQL
Server code
Generic NdbApi
code
Glue
SQL
Handler Api calls
NdbApi calls
'Protocol 6'
14 © 2020 Oracle
MySQL Ndb Cluster concepts : Data node
Replication thread
Main thread
LDM threads
TC threads
Send threads
Request
processing
threads
TC and LDM threads
do most work, must
be well fed by Send +
Receive threads
Receive threads IO threads
Connect threads Watchdog
15 © 2020 Oracle
MySQL Ndb Cluster 8.0
MySQL Cluster is a distributed, highly available, scalable version of MySQL
MySQL Cluster 8.0 combines the latest version of MySQL Server 8.0 with an enhanced
MySQL Cluster storage engine
MySQL Cluster storage engine enhancements in 8.0 :
- Row sizes up to 30kB
- Improved automatic configuration and resource sharing
- Enhanced backup parallelism
- Enhanced join pushdown parallelism
- Enhanced disk I/O
- Up to 144 data nodes in a cluster
- 2, 3 or 4 way synchronous replication within a NodeGroup
MySQL Cluster 8.0.19 Generally Available January 13, 2020
MySQL Cluster 8.0 continues to evolve...
8.0.19
16 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation
Configuration
Starting a cluster
Exploring the cluster
High Availability
Backup and Restore
Joins, Foreign Keys, JSON
NdbInfo views
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
Installation
- MySQL Cluster installation options
- Tutorial installation steps
17 © 2020 Oracle
Installation
MySQL Cluster 8.0 can be deployed on Linux, Solaris (x86 + SPARC), Mac OS and Windows
There are multiple ways to install MySQL Cluster 8.0 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
- Manually
- Compiling from source
Other options, for different scenarios :
- Using MySQL Cluster Manager (MCM), or Mysql Cluster Installer
- Using dbDeployer or other tools
https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-installation.html
18 © 2020 Oracle
Tutorial installation
For this tutorial we will run MySQL Cluster 8.0 in an VirtualBox VM containing :
- A ‘minimal’ Ubuntu 18.04 ‘Desktop’ installation
- MySQL Cluster 8.0.19 (Community GPL) installed from Debian packages
Using a VM like this allows the tutorial to be followed on various operating systems in an
isolated and repeatable way without OS specific distractions or interactions with existing
installed software.
The VM is available as a VirtualBox ‘appliance’ file (NdbVM.ova) which can be imported into
VirtualBox to create a VM on your machine.
First step : Copy all the files from the USB stick onto your machine
19 © 2020 Oracle
Tutorial Installation : Install VirtualBox
The USB stick contains install binaries for VirtualBox
6.1.2 for Windows, Mac OSX and generic Linux and
a short README about installation (and removal) in
tutorial/VirtualBox/README.
Alternatively VirtualBox can be downloaded from :
https://www.virtualbox.org/wiki/Downloads
Full documentation on how to install is available here :
https://www.virtualbox.org/manual/UserManual.html
Second step : Install VirtualBox onto your machine (if you do not already have it)
20 © 2020 Oracle
Tutorial Installation : Import NdbVM.ova appliance
Third step : Import the NdbVM.ova appliance to create the NdbVM virtual machine
1. Open the VirtualBox VM Manager
2. Select the File → Import Appliance menu option
3. Select the NdbVM.ova file you copied
4. On the Appliance Settings dialog, ensure that the appliance is configured with 4GB of
(virtual) RAM
5. Click Import and Wait for it to complete
…
21 © 2020 Oracle
Tutorial Installation : Start the NdbVM VM
Once the Import has completed, select the
NdbVM instance and click the Start icon.
The VM will boot, and eventually auto-login to a
desktop.
The VM is created with a user called ndb, with
password ndbcluster and home directory
/home/ndb
The desktop contains a link to the
cluster_tutorial.txt file
22 © 2020 Oracle
Tutorial Installation : Using the NdbVM VM
The terminal icon can be used to open a terminal
running the bash shell.
The bash shell prompt shows the current directory.
The terminal supports multiple tabs (File→New Tab).
There are a number of editors installed including :
- nano
- vi ( Exit vi with ESC :!q or ESC :!wq )
- gedit
You can see that MySQL Cluster 8.0.19 is installed
by running > mysql --version
23 © 2020 Oracle
Tutorial Installation : Reading the tutorial instructions
The tutorial instructions are available in a text
file in /home/ndb, also linked from the desktop.
Double clicking on the icon opens the instructions
in gedit, from where they can easily be read,
copied + pasted etc.
The terminal and editor icons on the left of the
Desktop (or ALT - TAB) can be used to swap
between applications.
24 © 2020 Oracle
Tutorial Installation
In this tutorial we discuss a number of binaries installed as part of MySQL Cluster 8.0
ndb_mgmd Management Server
ndbmtd Data node
mysqld MySQL Server
ndb_mgm Management client shell
mysql MySQL client shell
mysqlbinlog MySQL binlog file tool
mysqladmin MySQL Server admin tool
ndb_restore Backup restoration tool
ndb_desc NdbApi table description tool
ndb_select_all NdbApi table SELECT * tool
ndb_select_count NdbApi table SELECT COUNT(1) tool
ndb_error_reporter Error report gathering tool
ndbinfo_select_all NdbInfo tool
ndb_waiter State change handling tool
25 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration
Starting a cluster
Exploring the cluster
High Availability
Backup and Restore
Joins, Foreign Keys, JSON
NdbInfo views
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
Configuration
- Create directories for each cluster process
- Create a cluster configuration file
- Create MySQLD configuration files
- Initialise MySQLD data directories
26 © 2020 Oracle
Configuration
Configuration summary
- Four Data nodes (1,2,3,4), two per
NodeGroup {1,2}, {3,4}
- One Management server (10)
- Three MySQLDs :
- MySQLD1 Binlogging (11)
- MySQLD2 Binlogging (12)
- MySQLD3 (13)
Full instructions in section 2 of cluster_tutorial.txt
MGMD
NDBD
NDBD
NDBD
NDBD
MY MY MY11 12 13
1
2 4
3
10
27 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration √
Starting a cluster
Exploring the cluster
High Availability
Backup and Restore
Joins, Foreign Keys, JSON
NdbInfo views
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
Starting a cluster
- Starting the Management Server (MGMD)
- Starting the Data nodes (NDBD)
- Starting the MySQL Servers (MySQLD)
- Connecting to the MySQL Servers
28 © 2020 Oracle
Starting a cluster
Start the management node (MGMD)
MGMD 10
2
29 © 2020 Oracle
Starting a cluster
Start the management node (MGMD)
Start the data nodes (NDBD)
MGMD 10
NDBD
NDBD
NDBD
NDBD1
4
3
2
30 © 2020 Oracle
Starting a cluster
Start the management node (MGMD)
Start the data nodes (NDBD)
Start the MySQLD nodes
MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
2
31 © 2020 Oracle
Starting a cluster
Start the management node (MGMD)
Start the data nodes (NDBD)
Start the MySQLD nodes
User mysql clients to connect to
MySQLDs
Full instructions in section 3 of cluster_tutorial.txt MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
mysql1 mysql2 mysql3
32 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration √
Starting a cluster √
Exploring the cluster
High Availability
Backup and Restore
Joins, Foreign Keys, JSON
NdbInfo views
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
Exploring the cluster
- Using ndb_mgm
- Looking at logs (optional)
- Work with data
- Look at binary logs (optional)
33 © 2020 Oracle
Exploring the cluster : Using ndb_mgm
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
­­­­­­­­­­­­­­­­­­­­­
[ndbd(NDB)] 4 node(s)
id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0, *)
id=2 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0)
id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1)
id=4 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
[mysqld(API)] 7 node(s)
id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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)
2
MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
mysql1 mysql2 mysql3
ndb_mgmSHOW
34 © 2020 Oracle
Exploring the cluster : Inserting data
mysql1> create database tutorial;
Query OK, 1 row affected (0.14 sec)
 
mysql1> use tutorial;
Database changed
mysql1> # Note the 'engine=ndb' suffix
mysql1> create table attendees(person_id int primary key, 
name varchar(30)) engine=ndb;
Query OK, 0 rows affected (0.53 sec)
mysql1>  
mysql1> insert into attendees values (1, "P Calculus");
Query OK, 1 row affected (0.00 sec)
mysql1> insert into attendees values (2, "B Castafiore");
Query OK, 1 row affected (0.00 sec)
mysql1> insert into attendees values (3, "Snowy Dog");
Query OK, 1 row affected (0.00 sec)
…
mysql1> insert into attendees values (9, "R Rackham");
Query OK, 1 row affected (0.00 sec)
2
MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
mysql1 mysql2 mysql3
ndb_mgm
tutorial.attendees
INSERT
35 © 2020 Oracle
Exploring the cluster : Reading data
mysql1> select * from 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 in set (0.00 sec)
mysql2> select * from attendees;
…
mysql3> select * from attendees;
…
Shell > ndb_select_all ­dtutorial attendees
2
MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
mysql1 mysql2 mysql3
ndb_mgm
tutorial.attendees
SELECT
ndb_select_all
Full instructions in section 4 of
cluster_tutorial.txt
36 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration √
Starting a cluster √
Exploring the cluster √
High Availability
Backup and Restore
Joins, Foreign Keys, JSON
NdbInfo views
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
High Availability
- Kill one data node process
- Suspend another data node process (optional)
- Restart one data node process and kill another
- Kill one binlogging MySQLD process
- Kill all MySQLD processes (optional)
- Restart all MySQLD processes (optional)
- Kill all data nodes
- Restart all data nodes
37 © 2020 Oracle
High Availability : Kill one data node process
2
MGMD 10
NDBD
4
3
MY MY MY11 12 13
NDBD NDBD
mysql1 mysql2 mysql3
ndb_mgm
tutorial.attendees
SELECT SELECT
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
­­­­­­­­­­­­­­­­­­­­­
[ndbd(NDB)] 4 node(s)
id=1 (not connected, accepting connect from localhost)
id=2 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0, *)
id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1)
id=4 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
[mysqld(API)] 7 node(s)
id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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)
38 © 2020 Oracle
High Availability : Suspend another data node process (opt)
tutorial.attendees
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
­­­­­­­­­­­­­­­­­­­­­
[ndbd(NDB)] 4 node(s)
id=1 (not connected, accepting connect from localhost)
id=2 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0, *)
id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1)
id=4 (not connected, accepting connect from localhost)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
[mysqld(API)] 7 node(s)
id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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)
2
MGMD 10
NDBD
4
3
MY MY MY11 12 13
NDBD NDBD
mysql1 mysql2 mysql3
ndb_mgm
SELECT SELECT
SUSPEND
39 © 2020 Oracle
High Availability : Restart one data node + kill another
tutorial.attendees
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
­­­­­­­­­­­­­­­­­­­­­
[ndbd(NDB)] 4 node(s)
id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0)
id=2 (not connected, accepting connect from localhost)
id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1, *)
id=4 (not connected, accepting connect from localhost)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
[mysqld(API)] 7 node(s)
id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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)
MGMD 10
NDBD NDBD1 3
MY MY MY11 12 13
mysql1 mysql2 mysql3
ndb_mgm
SELECT SELECT
ndb_select_all
40 © 2020 Oracle
High Availability : Kill one Binlogging MySQLD process
tutorial.attendees
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
­­­­­­­­­­­­­­­­­­­­­
[ndbd(NDB)] 4 node(s)
id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0)
id=2 (not connected, accepting connect from localhost)
id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1, *)
id=4 (not connected, accepting connect from localhost)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
[mysqld(API)] 7 node(s)
id=11 (not connected, accepting connect from any host)
id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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)
MGMD 10
NDBD NDBD1 3
MY MY12 13
mysql2 mysql3
ndb_mgm
41 © 2020 Oracle
High Availability : Kill all MySQLD processes (opt)
tutorial.attendees
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
­­­­­­­­­­­­­­­­­­­­­
[ndbd(NDB)] 4 node(s)
id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0)
id=2 (not connected, accepting connect from localhost)
id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1, *)
id=4 (not connected, accepting connect from localhost)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.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)
MGMD 10
NDBD NDBD1 3
ndb_mgm
ndb_select_all
42 © 2020 Oracle
High Availability : Restart all MySQLD processes (opt)
tutorial.attendees
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
­­­­­­­­­­­­­­­­­­­­­
[ndbd(NDB)] 4 node(s)
id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0)
id=2 (not connected, accepting connect from localhost)
id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1, *)
id=4 (not connected, accepting connect from localhost)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
[mysqld(API)] 7 node(s)
id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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)
MGMD 10
NDBD NDBD1 3
MY MY MY11 12 13
mysql1 mysql2 mysql3
ndb_mgm
SELECT SELECT
43 © 2020 Oracle
High Availability : Kill all data node processes
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
­­­­­­­­­­­­­­­­­­­­­
[ndbd(NDB)] 4 node(s)
id=1 (not connected, accepting connect from localhost)
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  (mysql­8.0.19 ndb­8.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)
MGMD 10
MY MY MY11 12 13
mysql1 mysql2 mysql3
ndb_mgm
SELECT SELECT
44 © 2020 Oracle
High Availability : Restart all data node processes
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
­­­­­­­­­­­­­­­­­­­­­
[ndbd(NDB)] 4 node(s)
id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0, *)
id=2 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0)
id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1)
id=4 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1)
[ndb_mgmd(MGM)] 1 node(s)
id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
[mysqld(API)] 7 node(s)
id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19)
id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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)
2
MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
mysql1 mysql2 mysql3
ndb_mgm
SELECT SELECT SELECT
ndb_select_all
tutorial.attendees
Full instructions in section 5 of
cluster_tutorial.txt
45 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration √
Starting a cluster √
Exploring the cluster √
High Availability √
Backup and Restore
Joins, Foreign Keys, JSON
NdbInfo views
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
Backup and Restore
- Taking a backup
- Looking at backup filesets (optional)
- Restoring a backup (optional)
46 © 2020 Oracle
Backup and Restore : Taking a backup
2
MGMD 10
NDBD NDBD1
4NDBD NDBD
ndb_mgm
3
START BACKUP
1-1
1-2
1-3
1-4
1-1 1-2 1-3 1-4
ndb@ndb­VirtualBox:~/cluster1/ndbd1/BACKUP/BACKUP­1$ ls ­lh
total 60K
­rw­rw­r­­ 1 ndb ndb  14K Jan 23 16:36 BACKUP­1­0.1.Data
­rw­rw­r­­ 1 ndb ndb  29K Jan 23 16:36 BACKUP­1.1.ctl
­rw­rw­r­­ 1 ndb ndb   52 Jan 23 16:36 BACKUP­1.1.log
ndb@ndb­VirtualBox:~/cluster1/ndbd2/BACKUP/BACKUP­1$ ls ­lh
total 60K
­rw­rw­r­­ 1 ndb ndb  14K Jan 23 16:36 BACKUP­1­0.2.Data
­rw­rw­r­­ 1 ndb ndb  29K Jan 23 16:36 BACKUP­1.2.ctl
­rw­rw­r­­ 1 ndb ndb   52 Jan 23 16:36 BACKUP­1.2.log
ndb@ndb­VirtualBox:~/cluster1/ndbd3/BACKUP/BACKUP­1$ ls ­lh
total 60K
­rw­rw­r­­ 1 ndb ndb  14K Jan 23 16:36 BACKUP­1­0.3.Data
­rw­rw­r­­ 1 ndb ndb  29K Jan 23 16:36 BACKUP­1.3.ctl
­rw­rw­r­­ 1 ndb ndb   52 Jan 23 16:36 BACKUP­1.3.log
...
47 © 2020 Oracle
Backup and Restore : Restoring a backup (optional)
2
MGMD 10
NDBD NDBD1
4NDBD NDBD
ndb_mgm
3
ndb_restore –restore­meta ­b1 ­n1 1-1
1-1 1-2 1-3 1-4
ndb_restore –restore­data ­b1 ­n1 1-1
ndb_restore –restore­data ­b1 ­n2 1-2
ndb_restore –restore­data ­b1 ­n3 1-3
ndb_restore –restore­data ­b1 ­n4 1-4
Data restore can be very parallel.
In 8.0, ndb_restore is thread-parallel
Backup is logical, target cluster
topology can be different
Metadata/schema can also be
restored or altered via MySQLD
Full instructions in section 6 of cluster_tutorial.txt
48 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration √
Starting a cluster √
Exploring the cluster √
High Availability √
Backup and Restore √
Joins, Foreign Keys, JSON
NdbInfo views
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
Joins, Foreign keys and JSON
MySQL Cluster is a relational database, supporting
cross-table joins, foreign key constraints and other
useful features.
We can see some of these features in use by adding
some more data to the tutorial database.
49 © 2020 Oracle
Joins, Foreign keys and JSON : Joins
Add two new tables, with a common
primary key
Execute a join across them.
NDBD 1 NDBD 2
NDBD 3 NDBD 4
MYSQLD1
mysql1
1
2
3 3
3
4
4 4
4
5 5
55
6
50 © 2020 Oracle
Joins, Foreign keys and JSON : Foreign keys
Add two new tables, and foreign key constraints
51 © 2020 Oracle
Joins, Foreign keys and JSON : JSON
Store invites as JSON documents.
Then add foreign key constraints on
the JSON content.
Full instructions in section 7 of cluster_tutorial.txt
52 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration √
Starting a cluster √
Exploring the cluster √
High Availability √
Backup and Restore √
Joins, Foreign Keys, JSON √
NdbInfo views
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
NdbInfo views
The NdbInfo database contains views on
dynamically generated NdbInfo tables.
These tables are dynamically generated by the data
nodes to give visibility into all kinds of internal state
of the cluster.
In this section we look at some of the view
definitions.
53 © 2020 Oracle
NdbInfo views
mysql1> show tables;
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| Tables_in_ndbinfo               |
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| arbitrator_validity_detail      |
| arbitrator_validity_summary     |
| blocks                          |
| cluster_locks                   |
| cluster_operations              |
| cluster_transactions            |
| config_nodes                    |
| config_params                   |
| config_values                   |
| counters                        |
| cpustat                         |
| cpustat_1sec                    |
| cpustat_20sec                   |
| cpustat_50ms                    |
| dict_obj_info                   |
| dict_obj_types                  |
| disk_write_speed_aggregate      |
| disk_write_speed_aggregate_node |
| disk_write_speed_base           |
| diskpagebuffer                  |
| diskstats_1sec                  |
| error_messages                  |
| locks_per_fragment              |
| logbuffers                      |
| logspaces                       |
| membership                      |
| memory_per_fragment             |
| memoryusage                     |
| nodes                           |
| operations_per_fragment         |
| pgman_time_track_stats          |
| processes                       |
| resources                       |
| restart_info                    |
| server_locks                    |
              
| server_operations               |
| server_transactions             |
| table_distribution_status       |
| table_fragments                 |
| table_info                      |
| table_replicas                  |
| tc_time_track_stats             |
| threadblocks                    |
| threads                         |
| threadstat                      |
| transporters                    |
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
47 rows in set (0.00 sec)
54 © 2020 Oracle
NdbInfo views
mysql1> select * from transporters where remote_node_id=11;
+­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­
+­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­­­­­­­+
| node_id | remote_node_id | status    | remote_address | bytes_sent | bytes_received | connect_count | 
overloaded | overload_count | slowdown | slowdown_count |
+­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­
+­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­­­­­­­+
|       1 |             11 | CONNECTED | 127.0.0.1      |   34078060 |       29591428 |             1 |      
    0 |              0 |        0 |              0 |
|       2 |             11 | CONNECTED | 127.0.0.1      |   34001980 |       29545264 |             1 |      
    0 |              0 |        0 |              0 |
|       3 |             11 | CONNECTED | 127.0.0.1      |   34091396 |       29551204 |             1 |      
    0 |              0 |        0 |              0 |
|       4 |             11 | CONNECTED | 127.0.0.1      |   34006516 |       29548688 |             1 |      
    0 |              0 |        0 |              0 |
+­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­
+­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­­­­­­­+
4 rows in set (0.02 sec)
Full instructions in section 8 of cluster_tutorial.txt
55 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration √
Starting a cluster √
Exploring the cluster √
High Availability √
Backup and Restore √
Joins, Foreign Keys, JSON √
NdbInfo views √
Synchronized Privileges
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
Synchronized Privileges
In MySQL Cluster 8.0, the Synchronized Privileges
feature allows user accounts and privileges to be
synchronized across all MySQLDs attached to a
cluster.
56 © 2020 Oracle
Synchronized Privileges
2
MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
ndb_mgm
root root root
audrey
hercule hercule hercule ndb_stored_user privilege
MySQLD - local users
Full instructions in section 9 of
cluster_tutorial.txt
57 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration √
Starting a cluster √
Exploring the cluster √
High Availability √
Backup and Restore √
Joins, Foreign Keys, JSON √
NdbInfo views √
Synchronized Privileges √
Addnode and Rebalance data
MySQL Ndb 8.0 Cluster tutorial
Addnode and Rebalance data
MySQL Cluster allows a cluster to be scaled without
any downtime, by adding MySQLD nodes, or data
nodes.
Next we will try out this functionality by adding a
new nodegroup (two data nodes) to our cluster, and
then rebalancing some of our tables across the
larger cluster.
Full instructions in section 10 of
cluster_tutorial.txt
58 © 2020 Oracle
Addnode and Rebalance data : Initial state
First we will add some more rows to the beer_pref table to better show balance
    insert into beer_pref select person_id+9, beer from beer_pref;
    …
    insert into beer_pref select person_id+288, beer from beer_pref;
Then we look at the balance across the four existing data nodes using a query on the
memory_per_fragment NdbInfo view :
      +­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­+
      | node_id | sum(fixed_elem_count) |
      +­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­+
      |       1 |                   293 |
      |       2 |                   293 |
      |       3 |                   283 |
      |       4 |                   283 |
      +­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­+
59 © 2020 Oracle
Addnode and Rebalance data : Change configuration
Next we modify the cluster configuration file to add two new data nodes, numbers 5 and 6
    
     +[ndbd]
     +NodeId = 5
     +HostName = localhost
     +DataDir = /home/ndb/cluster1/ndbd5
     +
     +[ndbd]
     +NodeId = 6
     +HostName = localhost
     +DataDir = /home/ndb/cluster1/ndbd6
     +
60 © 2020 Oracle
Addnode and Rebalance data : Rolling restart
Next we perform a rolling restart of all
the nodes so that they pick up the
new configuration.
MGMD
NDBD 1
NDBD 2
NDBD 3
NDBD 4
MySQLD1
MySQLD2
MySQLD3
2
MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
61 © 2020 Oracle
Addnode and Rebalance data : Start new datanodes
Next we create directories for the new
datanodes, and start them up.
They are not usable for data until a
nodegroup is created for them.
2
MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
NDBD
6
5
NDBD
62 © 2020 Oracle
Addnode and Rebalance data : Create nodegroup
Next we create a new nodegroup containing
the new nodes.
Now the new nodes will be used to store
partitions of any newly created tables.
Existing tables continue to only use the original
nodegroups until they are reorganized.
2
MGMD 10
NDBD NDBD1
4
3
MY MY MY11 12 13
NDBD NDBD
NDBD
6
5
NDBD
63 © 2020 Oracle
Addnode and Rebalance data : Rebalance data
Finally we will rebalance the beer_pref table using an ALTER TABLE command :
            ALTER TABLE REORGANIZE PARTITION beer_pref;
Then we look at the balance across the six data nodes using a query on the
memory_per_fragment NdbInfo view :
      +­­­­­­­­­+­­­­­­­­­­+
      | node_id | rowcount |
      +­­­­­­­­­+­­­­­­­­­­+
      |       1 |      198 |
      |       2 |      198 |
      |       3 |      188 |
      |       4 |      188 |
      |       5 |      190 |
      |       6 |      190 |
      +­­­­­­­­­+­­­­­­­­­­+
64 © 2020 Oracle
Introduction √
MySQL Ndb Cluster 8.0 √
Installation √
Configuration √
Starting a cluster √
Exploring the cluster √
High Availability √
Backup and Restore √
Joins, Foreign Keys, JSON √
NdbInfo views √
Synchronized Privileges √
Addnode and Rebalance data √
MySQL Ndb 8.0 Cluster tutorial summary
There are many other features not described in this
tutorial including :
- Asynchronous replication
- Index statistics
- Main memory vs Disk column storage
- Online index build
- Online upgrade
- Optimisation
The full set of features are described in the manual
which can be found at :
https://dev.mysql.com/doc/refman/8.0/en/mysql-
cluster.html
MySQL Cluster development continues alongside
the development of the MySQL Server version 8.0
65 © 2020 Oracle

More Related Content

What's hot

What's hot (20)

MySQL Database Architectures - 2020-10
MySQL Database Architectures -  2020-10MySQL Database Architectures -  2020-10
MySQL Database Architectures - 2020-10
 
Redis introduction
Redis introductionRedis introduction
Redis introduction
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & Operations
 
MariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & OptimizationMariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & Optimization
 
MariaDB 10: The Complete Tutorial
MariaDB 10: The Complete TutorialMariaDB 10: The Complete Tutorial
MariaDB 10: The Complete Tutorial
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
MySQL NDB Cluster 8.0 SQL faster than NoSQL
MySQL NDB Cluster 8.0 SQL faster than NoSQL MySQL NDB Cluster 8.0 SQL faster than NoSQL
MySQL NDB Cluster 8.0 SQL faster than NoSQL
 
MySQL Load Balancers - Maxscale, ProxySQL, HAProxy, MySQL Router & nginx - A ...
MySQL Load Balancers - Maxscale, ProxySQL, HAProxy, MySQL Router & nginx - A ...MySQL Load Balancers - Maxscale, ProxySQL, HAProxy, MySQL Router & nginx - A ...
MySQL Load Balancers - Maxscale, ProxySQL, HAProxy, MySQL Router & nginx - A ...
 
MySQL Data Encryption at Rest
MySQL Data Encryption at RestMySQL Data Encryption at Rest
MySQL Data Encryption at Rest
 
Deploying PostgreSQL on Kubernetes
Deploying PostgreSQL on KubernetesDeploying PostgreSQL on Kubernetes
Deploying PostgreSQL on Kubernetes
 
New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)
New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)
New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)
 
Percona Xtrabackup - Highly Efficient Backups
Percona Xtrabackup - Highly Efficient BackupsPercona Xtrabackup - Highly Efficient Backups
Percona Xtrabackup - Highly Efficient Backups
 
InnoDb Vs NDB Cluster
InnoDb Vs NDB ClusterInnoDb Vs NDB Cluster
InnoDb Vs NDB Cluster
 
PostGreSQL Performance Tuning
PostGreSQL Performance TuningPostGreSQL Performance Tuning
PostGreSQL Performance Tuning
 
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...
DataOpsbarcelona 2019:  Deep dive into MySQL Group Replication... the magic e...DataOpsbarcelona 2019:  Deep dive into MySQL Group Replication... the magic e...
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...
 
State of the Dolphin - May 2022
State of the Dolphin - May 2022State of the Dolphin - May 2022
State of the Dolphin - May 2022
 
MySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptxMySQL_MariaDB-성능개선-202201.pptx
MySQL_MariaDB-성능개선-202201.pptx
 
Introduction to Galera Cluster
Introduction to Galera ClusterIntroduction to Galera Cluster
Introduction to Galera Cluster
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOps
 

Similar to MySQL Cluster 8.0 tutorial

Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Geir Høydalsvik
 

Similar to MySQL Cluster 8.0 tutorial (20)

MySQL 8: Ready for Prime Time
MySQL 8: Ready for Prime TimeMySQL 8: Ready for Prime Time
MySQL 8: Ready for Prime Time
 
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...MySQL High Availability Solutions  -  Avoid loss of service by reducing the r...
MySQL High Availability Solutions - Avoid loss of service by reducing the r...
 
MySQL on Docker and Kubernetes
MySQL on Docker and KubernetesMySQL on Docker and Kubernetes
MySQL on Docker and Kubernetes
 
20200613 my sql-ha-deployment
20200613 my sql-ha-deployment20200613 my sql-ha-deployment
20200613 my sql-ha-deployment
 
Metadata Synchronization in MySQL NDB Cluster 8.0
Metadata Synchronization in MySQL NDB Cluster 8.0Metadata Synchronization in MySQL NDB Cluster 8.0
Metadata Synchronization in MySQL NDB Cluster 8.0
 
MySQL Shell - the best DBA tool ?
MySQL Shell - the best DBA tool ? MySQL Shell - the best DBA tool ?
MySQL Shell - the best DBA tool ?
 
Midwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL FeaturesMidwest PHP Presentation - New MSQL Features
Midwest PHP Presentation - New MSQL Features
 
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
Simplifying MySQL, Pre-FOSDEM MySQL Days, Brussels, January 30, 2020.
 
My sql8 innodb_cluster
My sql8 innodb_clusterMy sql8 innodb_cluster
My sql8 innodb_cluster
 
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015MySQL's NoSQL  -- Texas Linuxfest August 22nd 2015
MySQL's NoSQL -- Texas Linuxfest August 22nd 2015
 
the State of the Dolphin - October 2020
the State of the Dolphin - October 2020the State of the Dolphin - October 2020
the State of the Dolphin - October 2020
 
State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20
State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20
State of the Dolphin 2020 - 25th Anniversary of MySQL with 8.0.20
 
Upgrade from MySQL 5.7 to MySQL 8.0
Upgrade from MySQL 5.7 to MySQL 8.0Upgrade from MySQL 5.7 to MySQL 8.0
Upgrade from MySQL 5.7 to MySQL 8.0
 
Ohio Linux Fest -- MySQL's NoSQL
Ohio Linux Fest -- MySQL's NoSQLOhio Linux Fest -- MySQL's NoSQL
Ohio Linux Fest -- MySQL's NoSQL
 
MySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentationMySQL Replication Update - DEbconf 2020 presentation
MySQL Replication Update - DEbconf 2020 presentation
 
MySQL 8.0 InnoDB Cluster - Easiest Tutorial
MySQL 8.0 InnoDB Cluster - Easiest TutorialMySQL 8.0 InnoDB Cluster - Easiest Tutorial
MySQL 8.0 InnoDB Cluster - Easiest Tutorial
 
Percona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodePercona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio Code
 
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
 
InnoDB Cluster Experience (MySQL User Camp)
InnoDB Cluster Experience (MySQL User Camp)InnoDB Cluster Experience (MySQL User Camp)
InnoDB Cluster Experience (MySQL User Camp)
 
NoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSONNoSQL and MySQL: News about JSON
NoSQL and MySQL: News about JSON
 

More from Frazer Clement

More from Frazer Clement (8)

MySQL Cluster Local Checkpoint (LCP) evolution in 7.6 (2019)
MySQL Cluster Local Checkpoint (LCP) evolution in 7.6 (2019)MySQL Cluster Local Checkpoint (LCP) evolution in 7.6 (2019)
MySQL Cluster Local Checkpoint (LCP) evolution in 7.6 (2019)
 
MySQL Cluster Schema management (2014)
MySQL Cluster Schema management (2014)MySQL Cluster Schema management (2014)
MySQL Cluster Schema management (2014)
 
MySQL Cluster page management (2014)
MySQL Cluster page management (2014)MySQL Cluster page management (2014)
MySQL Cluster page management (2014)
 
MySQL Cluster Asynchronous replication (2014)
MySQL Cluster Asynchronous replication (2014) MySQL Cluster Asynchronous replication (2014)
MySQL Cluster Asynchronous replication (2014)
 
Breakthrough performance with MySQL Cluster (2012)
Breakthrough performance with MySQL Cluster (2012)Breakthrough performance with MySQL Cluster (2012)
Breakthrough performance with MySQL Cluster (2012)
 
MySQL Cluster overview + development slides (2014)
MySQL Cluster overview + development slides (2014) MySQL Cluster overview + development slides (2014)
MySQL Cluster overview + development slides (2014)
 
MySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial textMySQL Cluster 8.0 tutorial text
MySQL Cluster 8.0 tutorial text
 
200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4
200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4
200 million qps on commodity hardware : Getting started with MySQL Cluster 7.4
 

Recently uploaded

Recently uploaded (20)

WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in Uganda
 
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
 
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
 
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
 
Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital Businesses
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid Environments
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration Tooling
 
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
 

MySQL Cluster 8.0 tutorial

  • 1. MySQL Cluster Engineering January 31, 2020 Frazer Clement MySQL Ndb 8.0 Cluster tutorial
  • 2. 2 © 2020 Oracle The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation. Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and prospects are “forward-looking statements” and are subject to material risks and uncertainties. A detailed discussion of these factors and other risks that affect our business is contained in Oracle’s Securities and Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q under the heading “Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website at  http://www.oracle.com/investor. All information in this presentation is current as of January 2020 and Oracle undertakes no duty to update any statement in light of new information or future events. Safe harbor statement
  • 3. 3 © 2020 Oracle You can follow the steps on your own machine, using a VirtualBox VM for simplicity You will need to install VirtualBox and the NdbVM virtual machine. ● There are USB sticks available with : ● [VirtualBox install binaries for Windows, Mac OS X, Linux generic] ● VM appliance (NdbVM.ova) for importing NdbVM into VirtualBox ● ~4GB RAM, ~ x GB disk space Steps : 1) Copy files from USB stick onto your machine 2) Install VirtualBox 3) Import VM appliance into VirtualBox to create a VM (wait...) 4) Start the VM How to follow the tutorial on your machine
  • 4. 4 © 2020 Oracle Introduction MySQL Ndb Cluster 8.0 Installation Configuration Starting a cluster Exploring the cluster High Availability Backup and Restore Joins, Foreign Keys, JSON NdbInfo views Synchronized Privileges Addnode and Rebalance data MySQL Ndb Cluster 8.0 tutorial MGMD NDBD NDBD NDBD NDBD NDBD NDBD MY MY MY Some (sub)sections are optional and can be skipped as necessary
  • 5. 5 © 2020 Oracle ● Learn about MySQL Ndb Cluster 8.0 ● See MySQL Cluster 8.0 setup and running ● See some of the features of MySQL Cluster ● Setup and use your own MySQL Cluster Introduction : Goals
  • 6. 6 © 2020 Oracle ● Discussion, Slides, Demonstration ● Follow along on your own machine in a virtual machine ● VM contains a text file with instructions : /home/ndb/cluster_tutorial.txt ● Instructions can be followed, commands pasted in, example output compared with your own ● Some sections can be skipped Introduction : Tutorial format
  • 7. 7 © 2020 Oracle 5.1   Kill one data node ======================== For this tutorial, all data node processes are running in the same VM, but we can identify them by their ­­nodeid= suffix. We can use this suffix to kill both the Angel and Worker processes around the same time using the pkill command. Shell > ­­­­­­­­­­ ps ­ef | grep ndbmtd pkill ­f nodeid=1 ps ­ef | grep ndbmtd ­­­­­­­­­­     Example output :       ndb@ndb­VirtualBox:~$ ps ­ef | grep ndbmtd       ndb       3033     1  0 18:41 ?        00:00:01 ndbmtd –ndb­nodeid=1       ndb       3035  3033  2 18:41 ?        00:04:57 ndbmtd –ndb­nodeid=1       ndb       3040     1  0 18:41 ?        00:00:02 ndbmtd –ndb­nodeid=2       ... Introduction : /home/ndb/cluster_tutorial.txt
  • 8. 8 © 2020 Oracle MySQL Ndb Cluster MySQL (Ndb) Cluster is used in critical applications where the highest availability and highest write scalability with low stable latency and efficiency are required : - Telecoms core networks - Massive online games - Stock exchange trade analysis - Web site session stores - Single sign-on and authentication use cases - … MySQL Cluster is backed by Oracle, with Oracle Support contracts available MySQL Cluster is mature, proven and dependable. MySQL Cluster is fully documented open source. https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster.html
  • 9. 9 © 2020 Oracle MySQL Ndb Cluster MySQL (Ndb) Cluster is a distributed, highly available and scalable version of MySQL MySQL Cluster allows MySQL Server instances to access and operate on data stored in a separate set of servers known as Data nodes. Data nodes provide a highly available and scalable transactional query and data service to a number of MySQL Servers, or other clients. NDBD NDBD MY NDBD NDBD MY NDBD NDBD MY NDBD NDBD MY NDBD NDBD MY NDBD NDBD MY NDBD NDBD MY NDBD NDBD MYSQL DATA
  • 10. 10 © 2020 Oracle MySQL Ndb Cluster concepts : Distributed system - MySQL Cluster is a shared nothing system - processes on different machines communicate with each other to form a cluster of nodes - Data nodes collaborate to store tables and indexes, and implement constraints, transactions, joins, backup, checkpointing and other high availability features - Data and indexes are automatically partitioned (sharded) across Nodegroups - All data is query-able, modifiable and consistent at all times - Row locking and two phase commit is used within and between Nodegroups - Data nodes have a native (NoSQL) interface called NdbApi, accessible from C++, Java, ... - MySQLD nodes provide a SQL interface and the MySQL async replication interface (Binlogs), implemented using NdbApi, alongside all the usual MySQL functionality NDBD NDBD MY NDBD NDBD MY
  • 11. 11 © 2020 Oracle MySQL Ndb Cluster concepts : Replicas and Scaling - Up to 4 data nodes (NDBD) replicate their data synchronously within a NodeGroup for high availability and read scaling. - A cluster can scale out online by adding nodegroups, increasing the total resources available and scaling write throughput - A cluster can scale out SQL capacity and redundancy online by adding MySQLD or other clients NDBD NDBD NDBD NDBD 1-4 replicas NDBD NDBD NDBD NDBD NDBD NDBD NDBD NDBD MY MY MY Scale out Nodegroups Scale out MySQL Servers
  • 12. 12 © 2020 Oracle MySQL Ndb Cluster concepts : Online operations MySQL Cluster supports online operations for high availability - queries and writing transactions experience minimal disturbance during : - Schema changes - Add column - Add index / Drop index - Operations - Backup - Software upgrade - Hardware upgrade - Scale out nodegroups - Scale out MySQLDs - Incidents - Node failure - Node recovery 99.9999%
  • 13. 13 © 2020 Oracle MySQL Ndb Cluster concepts : MySQL Server Ndb storage engine implementation Handler / Storage Engine Api SQL parsing, optimisation, execution Client threads NdbApi Network communication with data nodes MySQL clients MySQL clients MySQL clients Generic MySQL Server code Generic NdbApi code Glue SQL Handler Api calls NdbApi calls 'Protocol 6'
  • 14. 14 © 2020 Oracle MySQL Ndb Cluster concepts : Data node Replication thread Main thread LDM threads TC threads Send threads Request processing threads TC and LDM threads do most work, must be well fed by Send + Receive threads Receive threads IO threads Connect threads Watchdog
  • 15. 15 © 2020 Oracle MySQL Ndb Cluster 8.0 MySQL Cluster is a distributed, highly available, scalable version of MySQL MySQL Cluster 8.0 combines the latest version of MySQL Server 8.0 with an enhanced MySQL Cluster storage engine MySQL Cluster storage engine enhancements in 8.0 : - Row sizes up to 30kB - Improved automatic configuration and resource sharing - Enhanced backup parallelism - Enhanced join pushdown parallelism - Enhanced disk I/O - Up to 144 data nodes in a cluster - 2, 3 or 4 way synchronous replication within a NodeGroup MySQL Cluster 8.0.19 Generally Available January 13, 2020 MySQL Cluster 8.0 continues to evolve... 8.0.19
  • 16. 16 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation Configuration Starting a cluster Exploring the cluster High Availability Backup and Restore Joins, Foreign Keys, JSON NdbInfo views Synchronized Privileges Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial Installation - MySQL Cluster installation options - Tutorial installation steps
  • 17. 17 © 2020 Oracle Installation MySQL Cluster 8.0 can be deployed on Linux, Solaris (x86 + SPARC), Mac OS and Windows There are multiple ways to install MySQL Cluster 8.0 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 - Manually - Compiling from source Other options, for different scenarios : - Using MySQL Cluster Manager (MCM), or Mysql Cluster Installer - Using dbDeployer or other tools https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-installation.html
  • 18. 18 © 2020 Oracle Tutorial installation For this tutorial we will run MySQL Cluster 8.0 in an VirtualBox VM containing : - A ‘minimal’ Ubuntu 18.04 ‘Desktop’ installation - MySQL Cluster 8.0.19 (Community GPL) installed from Debian packages Using a VM like this allows the tutorial to be followed on various operating systems in an isolated and repeatable way without OS specific distractions or interactions with existing installed software. The VM is available as a VirtualBox ‘appliance’ file (NdbVM.ova) which can be imported into VirtualBox to create a VM on your machine. First step : Copy all the files from the USB stick onto your machine
  • 19. 19 © 2020 Oracle Tutorial Installation : Install VirtualBox The USB stick contains install binaries for VirtualBox 6.1.2 for Windows, Mac OSX and generic Linux and a short README about installation (and removal) in tutorial/VirtualBox/README. Alternatively VirtualBox can be downloaded from : https://www.virtualbox.org/wiki/Downloads Full documentation on how to install is available here : https://www.virtualbox.org/manual/UserManual.html Second step : Install VirtualBox onto your machine (if you do not already have it)
  • 20. 20 © 2020 Oracle Tutorial Installation : Import NdbVM.ova appliance Third step : Import the NdbVM.ova appliance to create the NdbVM virtual machine 1. Open the VirtualBox VM Manager 2. Select the File → Import Appliance menu option 3. Select the NdbVM.ova file you copied 4. On the Appliance Settings dialog, ensure that the appliance is configured with 4GB of (virtual) RAM 5. Click Import and Wait for it to complete …
  • 21. 21 © 2020 Oracle Tutorial Installation : Start the NdbVM VM Once the Import has completed, select the NdbVM instance and click the Start icon. The VM will boot, and eventually auto-login to a desktop. The VM is created with a user called ndb, with password ndbcluster and home directory /home/ndb The desktop contains a link to the cluster_tutorial.txt file
  • 22. 22 © 2020 Oracle Tutorial Installation : Using the NdbVM VM The terminal icon can be used to open a terminal running the bash shell. The bash shell prompt shows the current directory. The terminal supports multiple tabs (File→New Tab). There are a number of editors installed including : - nano - vi ( Exit vi with ESC :!q or ESC :!wq ) - gedit You can see that MySQL Cluster 8.0.19 is installed by running > mysql --version
  • 23. 23 © 2020 Oracle Tutorial Installation : Reading the tutorial instructions The tutorial instructions are available in a text file in /home/ndb, also linked from the desktop. Double clicking on the icon opens the instructions in gedit, from where they can easily be read, copied + pasted etc. The terminal and editor icons on the left of the Desktop (or ALT - TAB) can be used to swap between applications.
  • 24. 24 © 2020 Oracle Tutorial Installation In this tutorial we discuss a number of binaries installed as part of MySQL Cluster 8.0 ndb_mgmd Management Server ndbmtd Data node mysqld MySQL Server ndb_mgm Management client shell mysql MySQL client shell mysqlbinlog MySQL binlog file tool mysqladmin MySQL Server admin tool ndb_restore Backup restoration tool ndb_desc NdbApi table description tool ndb_select_all NdbApi table SELECT * tool ndb_select_count NdbApi table SELECT COUNT(1) tool ndb_error_reporter Error report gathering tool ndbinfo_select_all NdbInfo tool ndb_waiter State change handling tool
  • 25. 25 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration Starting a cluster Exploring the cluster High Availability Backup and Restore Joins, Foreign Keys, JSON NdbInfo views Synchronized Privileges Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial Configuration - Create directories for each cluster process - Create a cluster configuration file - Create MySQLD configuration files - Initialise MySQLD data directories
  • 26. 26 © 2020 Oracle Configuration Configuration summary - Four Data nodes (1,2,3,4), two per NodeGroup {1,2}, {3,4} - One Management server (10) - Three MySQLDs : - MySQLD1 Binlogging (11) - MySQLD2 Binlogging (12) - MySQLD3 (13) Full instructions in section 2 of cluster_tutorial.txt MGMD NDBD NDBD NDBD NDBD MY MY MY11 12 13 1 2 4 3 10
  • 27. 27 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration √ Starting a cluster Exploring the cluster High Availability Backup and Restore Joins, Foreign Keys, JSON NdbInfo views Synchronized Privileges Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial Starting a cluster - Starting the Management Server (MGMD) - Starting the Data nodes (NDBD) - Starting the MySQL Servers (MySQLD) - Connecting to the MySQL Servers
  • 28. 28 © 2020 Oracle Starting a cluster Start the management node (MGMD) MGMD 10
  • 29. 2 29 © 2020 Oracle Starting a cluster Start the management node (MGMD) Start the data nodes (NDBD) MGMD 10 NDBD NDBD NDBD NDBD1 4 3
  • 30. 2 30 © 2020 Oracle Starting a cluster Start the management node (MGMD) Start the data nodes (NDBD) Start the MySQLD nodes MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD
  • 31. 2 31 © 2020 Oracle Starting a cluster Start the management node (MGMD) Start the data nodes (NDBD) Start the MySQLD nodes User mysql clients to connect to MySQLDs Full instructions in section 3 of cluster_tutorial.txt MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD mysql1 mysql2 mysql3
  • 32. 32 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration √ Starting a cluster √ Exploring the cluster High Availability Backup and Restore Joins, Foreign Keys, JSON NdbInfo views Synchronized Privileges Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial Exploring the cluster - Using ndb_mgm - Looking at logs (optional) - Work with data - Look at binary logs (optional)
  • 33. 33 © 2020 Oracle Exploring the cluster : Using ndb_mgm ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration ­­­­­­­­­­­­­­­­­­­­­ [ndbd(NDB)] 4 node(s) id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0, *) id=2 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0) id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1) id=4 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1) [ndb_mgmd(MGM)] 1 node(s) id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) [mysqld(API)] 7 node(s) id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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) 2 MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD mysql1 mysql2 mysql3 ndb_mgmSHOW
  • 34. 34 © 2020 Oracle Exploring the cluster : Inserting data mysql1> create database tutorial; Query OK, 1 row affected (0.14 sec)   mysql1> use tutorial; Database changed mysql1> # Note the 'engine=ndb' suffix mysql1> create table attendees(person_id int primary key,  name varchar(30)) engine=ndb; Query OK, 0 rows affected (0.53 sec) mysql1>   mysql1> insert into attendees values (1, "P Calculus"); Query OK, 1 row affected (0.00 sec) mysql1> insert into attendees values (2, "B Castafiore"); Query OK, 1 row affected (0.00 sec) mysql1> insert into attendees values (3, "Snowy Dog"); Query OK, 1 row affected (0.00 sec) … mysql1> insert into attendees values (9, "R Rackham"); Query OK, 1 row affected (0.00 sec) 2 MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD mysql1 mysql2 mysql3 ndb_mgm tutorial.attendees INSERT
  • 35. 35 © 2020 Oracle Exploring the cluster : Reading data mysql1> select * from 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 in set (0.00 sec) mysql2> select * from attendees; … mysql3> select * from attendees; … Shell > ndb_select_all ­dtutorial attendees 2 MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD mysql1 mysql2 mysql3 ndb_mgm tutorial.attendees SELECT ndb_select_all Full instructions in section 4 of cluster_tutorial.txt
  • 36. 36 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration √ Starting a cluster √ Exploring the cluster √ High Availability Backup and Restore Joins, Foreign Keys, JSON NdbInfo views Synchronized Privileges Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial High Availability - Kill one data node process - Suspend another data node process (optional) - Restart one data node process and kill another - Kill one binlogging MySQLD process - Kill all MySQLD processes (optional) - Restart all MySQLD processes (optional) - Kill all data nodes - Restart all data nodes
  • 37. 37 © 2020 Oracle High Availability : Kill one data node process 2 MGMD 10 NDBD 4 3 MY MY MY11 12 13 NDBD NDBD mysql1 mysql2 mysql3 ndb_mgm tutorial.attendees SELECT SELECT ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration ­­­­­­­­­­­­­­­­­­­­­ [ndbd(NDB)] 4 node(s) id=1 (not connected, accepting connect from localhost) id=2 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0, *) id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1) id=4 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1) [ndb_mgmd(MGM)] 1 node(s) id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) [mysqld(API)] 7 node(s) id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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)
  • 38. 38 © 2020 Oracle High Availability : Suspend another data node process (opt) tutorial.attendees ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration ­­­­­­­­­­­­­­­­­­­­­ [ndbd(NDB)] 4 node(s) id=1 (not connected, accepting connect from localhost) id=2 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0, *) id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1) id=4 (not connected, accepting connect from localhost) [ndb_mgmd(MGM)] 1 node(s) id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) [mysqld(API)] 7 node(s) id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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) 2 MGMD 10 NDBD 4 3 MY MY MY11 12 13 NDBD NDBD mysql1 mysql2 mysql3 ndb_mgm SELECT SELECT SUSPEND
  • 39. 39 © 2020 Oracle High Availability : Restart one data node + kill another tutorial.attendees ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration ­­­­­­­­­­­­­­­­­­­­­ [ndbd(NDB)] 4 node(s) id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0) id=2 (not connected, accepting connect from localhost) id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1, *) id=4 (not connected, accepting connect from localhost) [ndb_mgmd(MGM)] 1 node(s) id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) [mysqld(API)] 7 node(s) id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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) MGMD 10 NDBD NDBD1 3 MY MY MY11 12 13 mysql1 mysql2 mysql3 ndb_mgm SELECT SELECT ndb_select_all
  • 40. 40 © 2020 Oracle High Availability : Kill one Binlogging MySQLD process tutorial.attendees ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration ­­­­­­­­­­­­­­­­­­­­­ [ndbd(NDB)] 4 node(s) id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0) id=2 (not connected, accepting connect from localhost) id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1, *) id=4 (not connected, accepting connect from localhost) [ndb_mgmd(MGM)] 1 node(s) id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) [mysqld(API)] 7 node(s) id=11 (not connected, accepting connect from any host) id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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) MGMD 10 NDBD NDBD1 3 MY MY12 13 mysql2 mysql3 ndb_mgm
  • 41. 41 © 2020 Oracle High Availability : Kill all MySQLD processes (opt) tutorial.attendees ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration ­­­­­­­­­­­­­­­­­­­­­ [ndbd(NDB)] 4 node(s) id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0) id=2 (not connected, accepting connect from localhost) id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1, *) id=4 (not connected, accepting connect from localhost) [ndb_mgmd(MGM)] 1 node(s) id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.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) MGMD 10 NDBD NDBD1 3 ndb_mgm ndb_select_all
  • 42. 42 © 2020 Oracle High Availability : Restart all MySQLD processes (opt) tutorial.attendees ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration ­­­­­­­­­­­­­­­­­­­­­ [ndbd(NDB)] 4 node(s) id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0) id=2 (not connected, accepting connect from localhost) id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1, *) id=4 (not connected, accepting connect from localhost) [ndb_mgmd(MGM)] 1 node(s) id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) [mysqld(API)] 7 node(s) id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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) MGMD 10 NDBD NDBD1 3 MY MY MY11 12 13 mysql1 mysql2 mysql3 ndb_mgm SELECT SELECT
  • 43. 43 © 2020 Oracle High Availability : Kill all data node processes ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration ­­­­­­­­­­­­­­­­­­­­­ [ndbd(NDB)] 4 node(s) id=1 (not connected, accepting connect from localhost) 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  (mysql­8.0.19 ndb­8.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) MGMD 10 MY MY MY11 12 13 mysql1 mysql2 mysql3 ndb_mgm SELECT SELECT
  • 44. 44 © 2020 Oracle High Availability : Restart all data node processes ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration ­­­­­­­­­­­­­­­­­­­­­ [ndbd(NDB)] 4 node(s) id=1 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0, *) id=2 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 0) id=3 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1) id=4 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19, Nodegroup: 1) [ndb_mgmd(MGM)] 1 node(s) id=10 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) [mysqld(API)] 7 node(s) id=11 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=12 @127.0.0.1  (mysql­8.0.19 ndb­8.0.19) id=13 @127.0.0.1  (mysql­8.0.19 ndb­8.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) 2 MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD mysql1 mysql2 mysql3 ndb_mgm SELECT SELECT SELECT ndb_select_all tutorial.attendees Full instructions in section 5 of cluster_tutorial.txt
  • 45. 45 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration √ Starting a cluster √ Exploring the cluster √ High Availability √ Backup and Restore Joins, Foreign Keys, JSON NdbInfo views Synchronized Privileges Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial Backup and Restore - Taking a backup - Looking at backup filesets (optional) - Restoring a backup (optional)
  • 46. 46 © 2020 Oracle Backup and Restore : Taking a backup 2 MGMD 10 NDBD NDBD1 4NDBD NDBD ndb_mgm 3 START BACKUP 1-1 1-2 1-3 1-4 1-1 1-2 1-3 1-4 ndb@ndb­VirtualBox:~/cluster1/ndbd1/BACKUP/BACKUP­1$ ls ­lh total 60K ­rw­rw­r­­ 1 ndb ndb  14K Jan 23 16:36 BACKUP­1­0.1.Data ­rw­rw­r­­ 1 ndb ndb  29K Jan 23 16:36 BACKUP­1.1.ctl ­rw­rw­r­­ 1 ndb ndb   52 Jan 23 16:36 BACKUP­1.1.log ndb@ndb­VirtualBox:~/cluster1/ndbd2/BACKUP/BACKUP­1$ ls ­lh total 60K ­rw­rw­r­­ 1 ndb ndb  14K Jan 23 16:36 BACKUP­1­0.2.Data ­rw­rw­r­­ 1 ndb ndb  29K Jan 23 16:36 BACKUP­1.2.ctl ­rw­rw­r­­ 1 ndb ndb   52 Jan 23 16:36 BACKUP­1.2.log ndb@ndb­VirtualBox:~/cluster1/ndbd3/BACKUP/BACKUP­1$ ls ­lh total 60K ­rw­rw­r­­ 1 ndb ndb  14K Jan 23 16:36 BACKUP­1­0.3.Data ­rw­rw­r­­ 1 ndb ndb  29K Jan 23 16:36 BACKUP­1.3.ctl ­rw­rw­r­­ 1 ndb ndb   52 Jan 23 16:36 BACKUP­1.3.log ...
  • 47. 47 © 2020 Oracle Backup and Restore : Restoring a backup (optional) 2 MGMD 10 NDBD NDBD1 4NDBD NDBD ndb_mgm 3 ndb_restore –restore­meta ­b1 ­n1 1-1 1-1 1-2 1-3 1-4 ndb_restore –restore­data ­b1 ­n1 1-1 ndb_restore –restore­data ­b1 ­n2 1-2 ndb_restore –restore­data ­b1 ­n3 1-3 ndb_restore –restore­data ­b1 ­n4 1-4 Data restore can be very parallel. In 8.0, ndb_restore is thread-parallel Backup is logical, target cluster topology can be different Metadata/schema can also be restored or altered via MySQLD Full instructions in section 6 of cluster_tutorial.txt
  • 48. 48 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration √ Starting a cluster √ Exploring the cluster √ High Availability √ Backup and Restore √ Joins, Foreign Keys, JSON NdbInfo views Synchronized Privileges Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial Joins, Foreign keys and JSON MySQL Cluster is a relational database, supporting cross-table joins, foreign key constraints and other useful features. We can see some of these features in use by adding some more data to the tutorial database.
  • 49. 49 © 2020 Oracle Joins, Foreign keys and JSON : Joins Add two new tables, with a common primary key Execute a join across them. NDBD 1 NDBD 2 NDBD 3 NDBD 4 MYSQLD1 mysql1 1 2 3 3 3 4 4 4 4 5 5 55 6
  • 50. 50 © 2020 Oracle Joins, Foreign keys and JSON : Foreign keys Add two new tables, and foreign key constraints
  • 51. 51 © 2020 Oracle Joins, Foreign keys and JSON : JSON Store invites as JSON documents. Then add foreign key constraints on the JSON content. Full instructions in section 7 of cluster_tutorial.txt
  • 52. 52 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration √ Starting a cluster √ Exploring the cluster √ High Availability √ Backup and Restore √ Joins, Foreign Keys, JSON √ NdbInfo views Synchronized Privileges Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial NdbInfo views The NdbInfo database contains views on dynamically generated NdbInfo tables. These tables are dynamically generated by the data nodes to give visibility into all kinds of internal state of the cluster. In this section we look at some of the view definitions.
  • 53. 53 © 2020 Oracle NdbInfo views mysql1> show tables; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | Tables_in_ndbinfo               | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ | arbitrator_validity_detail      | | arbitrator_validity_summary     | | blocks                          | | cluster_locks                   | | cluster_operations              | | cluster_transactions            | | config_nodes                    | | config_params                   | | config_values                   | | counters                        | | cpustat                         | | cpustat_1sec                    | | cpustat_20sec                   | | cpustat_50ms                    | | dict_obj_info                   | | dict_obj_types                  | | disk_write_speed_aggregate      | | disk_write_speed_aggregate_node | | disk_write_speed_base           | | diskpagebuffer                  | | diskstats_1sec                  | | error_messages                  | | locks_per_fragment              | | logbuffers                      | | logspaces                       | | membership                      | | memory_per_fragment             | | memoryusage                     | | nodes                           | | operations_per_fragment         | | pgman_time_track_stats          | | processes                       | | resources                       | | restart_info                    | | server_locks                    |                | server_operations               | | server_transactions             | | table_distribution_status       | | table_fragments                 | | table_info                      | | table_replicas                  | | tc_time_track_stats             | | threadblocks                    | | threads                         | | threadstat                      | | transporters                    | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 47 rows in set (0.00 sec)
  • 54. 54 © 2020 Oracle NdbInfo views mysql1> select * from transporters where remote_node_id=11; +­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­ +­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­­­­­­­+ | node_id | remote_node_id | status    | remote_address | bytes_sent | bytes_received | connect_count |  overloaded | overload_count | slowdown | slowdown_count | +­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­ +­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­­­­­­­+ |       1 |             11 | CONNECTED | 127.0.0.1      |   34078060 |       29591428 |             1 |           0 |              0 |        0 |              0 | |       2 |             11 | CONNECTED | 127.0.0.1      |   34001980 |       29545264 |             1 |           0 |              0 |        0 |              0 | |       3 |             11 | CONNECTED | 127.0.0.1      |   34091396 |       29551204 |             1 |           0 |              0 |        0 |              0 | |       4 |             11 | CONNECTED | 127.0.0.1      |   34006516 |       29548688 |             1 |           0 |              0 |        0 |              0 | +­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­ +­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+­­­­­­­­­­+­­­­­­­­­­­­­­­­+ 4 rows in set (0.02 sec) Full instructions in section 8 of cluster_tutorial.txt
  • 55. 55 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration √ Starting a cluster √ Exploring the cluster √ High Availability √ Backup and Restore √ Joins, Foreign Keys, JSON √ NdbInfo views √ Synchronized Privileges Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial Synchronized Privileges In MySQL Cluster 8.0, the Synchronized Privileges feature allows user accounts and privileges to be synchronized across all MySQLDs attached to a cluster.
  • 56. 56 © 2020 Oracle Synchronized Privileges 2 MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD ndb_mgm root root root audrey hercule hercule hercule ndb_stored_user privilege MySQLD - local users Full instructions in section 9 of cluster_tutorial.txt
  • 57. 57 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration √ Starting a cluster √ Exploring the cluster √ High Availability √ Backup and Restore √ Joins, Foreign Keys, JSON √ NdbInfo views √ Synchronized Privileges √ Addnode and Rebalance data MySQL Ndb 8.0 Cluster tutorial Addnode and Rebalance data MySQL Cluster allows a cluster to be scaled without any downtime, by adding MySQLD nodes, or data nodes. Next we will try out this functionality by adding a new nodegroup (two data nodes) to our cluster, and then rebalancing some of our tables across the larger cluster. Full instructions in section 10 of cluster_tutorial.txt
  • 58. 58 © 2020 Oracle Addnode and Rebalance data : Initial state First we will add some more rows to the beer_pref table to better show balance     insert into beer_pref select person_id+9, beer from beer_pref;     …     insert into beer_pref select person_id+288, beer from beer_pref; Then we look at the balance across the four existing data nodes using a query on the memory_per_fragment NdbInfo view :       +­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­+       | node_id | sum(fixed_elem_count) |       +­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­+       |       1 |                   293 |       |       2 |                   293 |       |       3 |                   283 |       |       4 |                   283 |       +­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­+
  • 59. 59 © 2020 Oracle Addnode and Rebalance data : Change configuration Next we modify the cluster configuration file to add two new data nodes, numbers 5 and 6           +[ndbd]      +NodeId = 5      +HostName = localhost      +DataDir = /home/ndb/cluster1/ndbd5      +      +[ndbd]      +NodeId = 6      +HostName = localhost      +DataDir = /home/ndb/cluster1/ndbd6      +
  • 60. 60 © 2020 Oracle Addnode and Rebalance data : Rolling restart Next we perform a rolling restart of all the nodes so that they pick up the new configuration. MGMD NDBD 1 NDBD 2 NDBD 3 NDBD 4 MySQLD1 MySQLD2 MySQLD3 2 MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD
  • 61. 61 © 2020 Oracle Addnode and Rebalance data : Start new datanodes Next we create directories for the new datanodes, and start them up. They are not usable for data until a nodegroup is created for them. 2 MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD NDBD 6 5 NDBD
  • 62. 62 © 2020 Oracle Addnode and Rebalance data : Create nodegroup Next we create a new nodegroup containing the new nodes. Now the new nodes will be used to store partitions of any newly created tables. Existing tables continue to only use the original nodegroups until they are reorganized. 2 MGMD 10 NDBD NDBD1 4 3 MY MY MY11 12 13 NDBD NDBD NDBD 6 5 NDBD
  • 63. 63 © 2020 Oracle Addnode and Rebalance data : Rebalance data Finally we will rebalance the beer_pref table using an ALTER TABLE command :             ALTER TABLE REORGANIZE PARTITION beer_pref; Then we look at the balance across the six data nodes using a query on the memory_per_fragment NdbInfo view :       +­­­­­­­­­+­­­­­­­­­­+       | node_id | rowcount |       +­­­­­­­­­+­­­­­­­­­­+       |       1 |      198 |       |       2 |      198 |       |       3 |      188 |       |       4 |      188 |       |       5 |      190 |       |       6 |      190 |       +­­­­­­­­­+­­­­­­­­­­+
  • 64. 64 © 2020 Oracle Introduction √ MySQL Ndb Cluster 8.0 √ Installation √ Configuration √ Starting a cluster √ Exploring the cluster √ High Availability √ Backup and Restore √ Joins, Foreign Keys, JSON √ NdbInfo views √ Synchronized Privileges √ Addnode and Rebalance data √ MySQL Ndb 8.0 Cluster tutorial summary There are many other features not described in this tutorial including : - Asynchronous replication - Index statistics - Main memory vs Disk column storage - Online index build - Online upgrade - Optimisation The full set of features are described in the manual which can be found at : https://dev.mysql.com/doc/refman/8.0/en/mysql- cluster.html MySQL Cluster development continues alongside the development of the MySQL Server version 8.0
  • 65. 65 © 2020 Oracle