ROLE INTERNAL IP
mysql1 master / app 192.168.56.11
mysql2 replica 192.168.56.12
mysql3 n/a 192.168.56.13
The document outlines steps to migrate an asynchronous MySQL replication setup to a MySQL InnoDB Cluster configuration. It describes cloning data from mysql2 to mysql3, creating an InnoDB Cluster with mysql3, configuring asynchronous replication from mysql1 to mysql3, adding mysql2 to the cluster, and bootstrapping a MySQL Router.
1 of 64
More Related Content
MySQL 8.0 InnoDB Cluster - Easiest Tutorial
1. Kenny Gryp
MySQL Product Manager
InnoDB & HA
Frédéric Descamps
MySQL Community Manager
EMEA & APAC
MySQL InnoDB Cluster
Easiest Tutorial !
2 / 65
2.
Safe Harbor
The following is intended to outline our general product direction. It is intended for information purpose 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 up in making purchasing decisions. The development, release, timing and pricing of any
features or functionality described for Oracle´s product may change and remains at the sole discretion of Oracle
Corporation.
Statement in this presentation relating to Oracle´s future plans, expectations, beliefs, intentions and ptospects
are "forward-looking statements" and are subject to material risks and uncertainties. A detailed discussion of
these factors and other risks that a ect our business is contained in Oracle´s Securities and Exchange
Commission (SEC) lings, including our most recent reports on Form 10-K and Form 10-Q under the heading
"Risk Factors". These lings are available on the SEC´s website or on Oracle´s website at
h p://www.oracle.com/investor. All information in this presentation is current as of September 2019 and Oracle
undertakes no duty to update any statement in light of new information or future events.
Copyright @ 2019 Oracle and/or its affiliates.
3 / 65
3. about us
Who are we ?
Copyright @ 2019 Oracle and/or its affiliates.
4 / 65
4. Kenny Gryp
@gryp
MySQL Product Manager
(InnoDB & HA)
born in Belgium 🇧🇪
Copyright @ 2019 Oracle and/or its affiliates.
5 / 65
7. Setup your workstation
Install VirtualBox 6.0
On the USB key, COPY MySQLInnoDBCluster_PLEU19.ova and click on it
Ensure you have vboxnet0 network interface
Older VirtualBox: VirtualBox Pref. -> Network -> Host-Only Networks -> +
New VirtualBox: Global Tools -> Host Network Manager -> +
Copyright @ 2019 Oracle and/or its affiliates.
8 / 65
8. Login on your workstation
Start all virtual machines (mysql1, mysql2 & mysql3)
Try to connect to all VM´s from your terminal or pu y (root password is X) :
ssh root@192.168.56.11 mysql1
ssh root@192.168.56.12 mysql2
ssh root@192.168.56.13 mysql3
Copyright @ 2019 Oracle and/or its affiliates.
9 / 65
9. MySQL InnoDB Cluster
"A single product — MySQL — with high availability and scaling features baked in;
providing an integrated end-to-end solution that is easy to use."
Copyright @ 2019 Oracle and/or its affiliates.
10 / 65
10. MySQL InnoDB Cluster
"A single product — MySQL — with high availability and scaling features baked in;
providing an integrated end-to-end solution that is easy to use."
Copyright @ 2019 Oracle and/or its affiliates.
11 / 65
11. Components:
MySQL Server
MySQL Group Replication
MySQL Shell
MySQL Router
MySQL InnoDB Cluster
"A single product — MySQL — with high availability and scaling features baked in;
providing an integrated end-to-end solution that is easy to use."
Copyright @ 2019 Oracle and/or its affiliates.
12 / 65
12. One Product: MySQL
All components developed together
Integration of all components
Full stack testing
MySQL InnoDB Cluster - Goals
Copyright @ 2019 Oracle and/or its affiliates.
13 / 65
13. One Product: MySQL
All components developed together
Integration of all components
Full stack testing
Easy to Use
One client: MySQL Shell
Integrated orchestration
Homogenous servers
MySQL InnoDB Cluster - Goals
Copyright @ 2019 Oracle and/or its affiliates.
14 / 65
15. MySQL Group Replication
Highly Available Distributed MySQL Database
Copyright @ 2019 Oracle and/or its affiliates.
16 / 65
16. Open Source
Fault tolerance
Automatic failover
Active/Active update anywhere
Automatic membership management
Adding/removing members
Network partitions, failures
Con ict detection and resolution
Consistency!
MySQL Group Replication
Highly Available Distributed MySQL Database
Copyright @ 2019 Oracle and/or its affiliates.
17 / 65
17. MySQL Group Replication
Implementation of Replicated Database State Machine
Total Order - Writes
XCOM - Paxos implementation
8.0+: Member provisioning using CLONE plugin.
Con gurable Consistency Guarantees
eventual consistency
8.0+: per session & global read/write consistency
Using MySQL replication framework by design
GTIDs, binary logs, relay logs
Generally Available since MySQL 5.7
Supported on all platforms: linux, windows, solaris, macosx, freebsd
Copyright @ 2019 Oracle and/or its affiliates.
18 / 65
18. Consistency: No Data Loss (RPO=0)
in event of failure of (primary) member
Split brain prevention (Quorum)
MySQL Group Replication - Use Cases
Copyright @ 2019 Oracle and/or its affiliates.
19 / 65
19. Consistency: No Data Loss (RPO=0)
in event of failure of (primary) member
Split brain prevention (Quorum)
Highly Available: Automatic Failover
Primary members are automatically elected
Automatic Network Partition handling
MySQL Group Replication - Use Cases
Copyright @ 2019 Oracle and/or its affiliates.
20 / 65
20. Consistency: No Data Loss (RPO=0)
in event of failure of (primary) member
Split brain prevention (Quorum)
Highly Available: Automatic Failover
Primary members are automatically elected
Automatic Network Partition handling
Read Scaleout
Add/Remove members as needed
Replication Lag handling with Flow Control
Con gurable Consistency Levels
Eventual
Full Consistency -- no stale reads
MySQL Group Replication - Use Cases
Copyright @ 2019 Oracle and/or its affiliates.
21 / 65
21. Consistency: No Data Loss (RPO=0)
in event of failure of (primary) member
Split brain prevention (Quorum)
Highly Available: Automatic Failover
Primary members are automatically elected
Automatic Network Partition handling
Read Scaleout
Add/Remove members as needed
Replication Lag handling with Flow Control
Con gurable Consistency Levels
Eventual
Full Consistency -- no stale reads
Active/Active environments
Write to many members at the same time
ordered writes within the group (XCOM)
guaranteed consistency
Good write performance
due to Optimistic Locking
(workload dependent)
MySQL Group Replication - Use Cases
Copyright @ 2019 Oracle and/or its affiliates.
22 / 65
22. "MySQL Shell provides the developer and
DBA with a single intuitive, exible, and
powerful interface for all MySQL related
tasks!"
MySQL Shell : Database Admin Interface
Copyright @ 2019 Oracle and/or its affiliates.
23 / 65
23. "MySQL Shell provides the developer and
DBA with a single intuitive, exible, and
powerful interface for all MySQL related
tasks!"
Open Source
Multi-Language: JavaScript, Python, and
SQL
Naturally scriptable
Supports Document and Relational
models
Exposes full Development and Admin
API
Classic MySQL protocol and X protocol
MySQL Shell : Database Admin Interface
Copyright @ 2019 Oracle and/or its affiliates.
24 / 65
25. 1 2
3
ASYNCHRONOUS
all database servers are
using MySQL 8.0.17
LAB1: Current situation
Copyright @ 2019 Oracle and/or its affiliates.
26 / 65
26. 1 2
3
ASYNCHRONOUS
launch run_app.sh on
mysql1 into a screen
session
verify that mysql2 is a
running replica
LAB1: Current situation
Copyright @ 2019 Oracle and/or its affiliates.
27 / 65
27. Summary
ROLE INTERNAL IP
mysql1 master / app 192.168.56.11
mysql2 replica 192.168.56.12
mysql3 n/a 192.168.56.13
Copyright @ 2019 Oracle and/or its affiliates.
28 / 65
28. Summary
ROLE INTERNAL IP
mysql1 master / app 192.168.56.11
mysql2 replica 192.168.56.12
mysql3 n/a 192.168.56.13
write this down somewhere !
Copyright @ 2019 Oracle and/or its affiliates.
29 / 65
31. 1 2
3
ASYNCHRONOUS
C
L O
N E
These are the 7 steps for
the migration:
1) We transfer the data
from mysql2 (replica) to our
new MySQL Server mysql3
The plan
Copyright @ 2019 Oracle and/or its affiliates.
32 / 65
32. 1 2
3
ASYNCHRONOUS
2) We create a MySQL
InnoDB Cluster on mysql3
The plan
Copyright @ 2019 Oracle and/or its affiliates.
33 / 65
33. 1 2
3
ASYNCHRONOUS
ASYNCHRONOUS
3) We setup our MySQL
InnoDB Cluster to become
a replica from the
production server (mysql1).
The plan
Copyright @ 2019 Oracle and/or its affiliates.
34 / 65
34. 1
2 3
ASYNCHRONOUS
4) We remove mysql2 as
replica of mysql1 and we
add it in the MySQL
InnoDB Cluster
The plan
Copyright @ 2019 Oracle and/or its affiliates.
35 / 65
35. 1
2 3
ASYNCHRONOUS
5) We bootstrap and start a
MySQL Router (on mysql1).
The plan
Copyright @ 2019 Oracle and/or its affiliates.
36 / 65
36. 1
2 3
6) We stop our application
and we restart it pointing
to the MySQL Router
The plan
Copyright @ 2019 Oracle and/or its affiliates.
37 / 65
37. 1 2 3
7) We add mysql1 in the
MySQL InnoDB Cluster
The plan
Copyright @ 2019 Oracle and/or its affiliates.
38 / 65
38. LAB2: Admin User Creation
We will rst create an admin account on mysql1 and mysql3 (mysql2 will get it replicated)
that we will use throughout the tutorial:
mysql1> CREATE USER clusteradmin@'%' identi ed by 'mysql';
mysql1> GRANT ALL PRIVILEGES ON *.* TO clusteradmin@'%'
WITH GRANT OPTION;
mysql3> CREATE USER clusteradmin@'%' identi ed by 'mysql';
mysql3> GRANT ALL PRIVILEGES ON *.* TO clusteradmin@'%'
WITH GRANT OPTION;
Copyright @ 2019 Oracle and/or its affiliates.
39 / 65
39. LAB2: Beautiful MySQL Shell
You can setup a be er shell environment :
# mysqlsh
mysql-js> shell.options.setPersist('history.autoSave', 1)
mysql-js> shell.options.setPersist('history.maxSize', 5000)
# cp /usr/share/mysqlsh/prompt/prompt_256pl+aw.json ~/.mysqlsh/prompt.json
# mysqlsh clusteradmin@mysql2
Copyright @ 2019 Oracle and/or its affiliates.
40 / 65
40.
We will use the new CLONE plugin to transfer
the data from mysql2 to mysql3.
Please note that installing a plugin requires
a connection using the classic protocol
(3306)
1 2
3
ASYNCHRONOUS
C
L O
N E
LAB2: Transfer the data to mysql3
Copyright @ 2019 Oracle and/or its affiliates.
41 / 65
41. LAB2: Transfer the data to mysql3
We start by installing the CLONE plugin on mysql2:
JS> c clusteradmin@mysql2:3306
mysql2>JS> sql
mysql2>sql> INSTALL PLUGIN clone SONAME 'mysql_clone.so';
Then we install it on mysql3 and we con gure it to use mysql2 as donor and we start the
cloning process:
mysql3>sql> c clusteradmin@mysql3:3306
mysql3>sql> INSTALL PLUGIN clone SONAME 'mysql_clone.so';
mysql3>sql> SET GLOBAL clone_valid_donor_list='mysql2:3306';
mysql3>sql> CLONE INSTANCE FROM clusteradmin@mysql2:3306 IDENTIFIED BY 'mysql';
Copyright @ 2019 Oracle and/or its affiliates.
42 / 65
43. LAB3: MySQL InnoDB Cluster Creation
We will operate everything from one Shell, for the example, we will use mysql1. Let's start
by con guring mysql3 to be have all required se ings to be part of a MySQL InnoDB
Cluster:
JS> dba.con gureInstance('clusteradmin@mysql3')
Then we connect to it and we create our cluster:
JS> c clusteradmin@mysql3
mysql3>JS> cluster=dba.createCluster('PLEU19')
You can check the result of the cluster like this:
mysql3>JS> cluster.status()
Copyright @ 2019 Oracle and/or its affiliates.
44 / 65
44.
Let's con gure asynchronous replication on
mysql3 to get the tra c from mysql1.
1 2
3
ASYNCHRONOUS
ASYNCHRONOUS
LAB4: Asynchronous Replication
Copyright @ 2019 Oracle and/or its affiliates.
45 / 65
45. LAB4: Asynchronous Replication
Con gure & start asynchronous replication on mysql3:
sql> c clusteradmin@mysql3
mysql3>sql> CHANGE MASTER TO MASTER_HOST='mysql1', MASTER_PORT=3306,
MASTER_USER='repl', MASTER_PASSWORD='X',
MASTER_AUTO_POSITION=1, MASTER_SSL=1;
mysql3>sql> START SLAVE;
Copyright @ 2019 Oracle and/or its affiliates.
46 / 65
46.
Let's add now mysql2 to the MySQL InnoDB
Cluster.
1
2 3
ASYNCHRONOUS
LAB5: Add a new instance to our cluster
Copyright @ 2019 Oracle and/or its affiliates.
47 / 65
47. LAB5: Add a new instance to our cluster
Now we will join mysql2 to the MySQL InnoDB Cluster.
Copyright @ 2019 Oracle and/or its affiliates.
48 / 65
48. LAB5: Add a new instance to our cluster
Now we will join mysql2 to the MySQL InnoDB Cluster.
The rst step is stop the asynchronous replication on mysql2:
js> c clusteradmin@mysql2
mysql2>js> sql stop slave;
mysql2>js> sql reset slave all;
Copyright @ 2019 Oracle and/or its affiliates.
49 / 65
49. LAB5: Add a new instance to our cluster
Now we will join mysql2 to the MySQL InnoDB Cluster.
The rst step is stop the asynchronous replication on mysql2:
js> c clusteradmin@mysql2
mysql2>js> sql stop slave;
mysql2>js> sql reset slave all;
In the MySQL Shell of mysql1, we con gure the mysql2 and we add it to the cluster:
JS> c clusteradmin@mysql3
mysql3>JS> cluster=dba.getCluster()
mysql3>JS> dba.con gureInstance('clusteradmin@mysql2')
mysql3>JS> cluster.addInstance('clusteradmin@mysql2')
Copyright @ 2019 Oracle and/or its affiliates.
50 / 65
50.
We have now already a cluster of 2 nodes
running. We will bootstrap a MySQL Router
1
2 3
ASYNCHRONOUS
LAB6: MySQL Router
Copyright @ 2019 Oracle and/or its affiliates.
51 / 65
51. "provide transparent routing between your application
and back-end MySQL Servers"
MySQL Router
Transparent Access to Database Architecture
Copyright @ 2019 Oracle and/or its affiliates.
52 / 65
52. "provide transparent routing between your application
and back-end MySQL Servers"
Transparent client connection routing
Load balancing
Application connection failover
Stateless design o ers easy HA client routing
Router as part of the application stack
Li le to no con guration needed
Native support for InnoDB clusters
Understands Group Replication topology
Utilizes metadata schema on each member
Currently 2 TCP Ports: PRIMARY and NON-PRIMARY
tra c (for Classic and X Protocol)
MySQL Router
Transparent Access to Database Architecture
Copyright @ 2019 Oracle and/or its affiliates.
53 / 65
53. LAB6: MySQL Router
MySQL Router will be used on the application server (mysql1):
[root]# mysqlrouter --bootstrap=clusteradmin@mysql3:3306 --user=mysqlrouter
Copyright @ 2019 Oracle and/or its affiliates.
54 / 65
54. LAB6: MySQL Router
MySQL Router will be used on the application server (mysql1):
[root]# mysqlrouter --bootstrap=clusteradmin@mysql3:3306 --user=mysqlrouter
We can start the Router:
[root]# systemctl start mysqlrouter
Copyright @ 2019 Oracle and/or its affiliates.
55 / 65
55.
Now we will point our application to the
MySQL Router, this is the only downtime
during our migration.
1
2 3
LAB7: Using the MySQL InnoDB Cluster
Copyright @ 2019 Oracle and/or its affiliates.
56 / 65
56. LAB7: Using the MySQL InnoDB Cluster
In the screen session where the application is running (screen -rx), we stop it (^C) and we
restart it connecting to the Router:
[root]# run_app.sh mysql1 router
Copyright @ 2019 Oracle and/or its affiliates.
57 / 65
57.
It's time to add the last node in our MySQL
InnoDB Cluster.
And don't forget to stop slave on mysql3 !
1 2 3
LAB8: 3 nodes MySQL InnoDB Cluster
Copyright @ 2019 Oracle and/or its affiliates.
58 / 65
58. LAB8: 3 nodes MySQL InnoDB Cluster
We will now add the mysql1 to the cluster exactly as we did with mysql2:
JS> dba.con gureInstance('clusteradmin@mysql1')
mysql3>JS> c clusteradmin@mysql3
mysql3>JS> cluster=dba.getCluster()
mysql3>JS> cluster.addInstance('clusteradmin@mysql1')
Copyright @ 2019 Oracle and/or its affiliates.
59 / 65
59. LAB8: 3 nodes MySQL InnoDB Cluster
We will now add the mysql1 to the cluster exactly as we did with mysql2:
JS> dba.con gureInstance('clusteradmin@mysql1')
mysql3>JS> c clusteradmin@mysql3
mysql3>JS> cluster=dba.getCluster()
mysql3>JS> cluster.addInstance('clusteradmin@mysql1')
JS> cluster.status()
{
"clusterName": "PLEU19",
"defaultReplicaSet": {
"name": "default",
"primary": "mysql3:3306",
"ssl": "REQUIRED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
...
Copyright @ 2019 Oracle and/or its affiliates.
60 / 65
61. Upgrade to MySQL 8.0
It's time to upgrade to MySQL 8.0, the fastest MySQL adoption release ever !
Copyright @ 2019 Oracle and/or its affiliates.
62 / 65