MySQL InnoDB Cluster Tutorial presented at Oracle CodeOne 2019.
Abstract:
MySQL InnoDB Cluster is the easiest and safest solution for achieving MySQL high availability. Attend this tutorial to learn how to set up a cluster in five minutes. You will see how to migrate from traditional asynchronous replication to InnoDB Cluster with minimal downtime and will also discover MySQL Shell and see how to configure MySQL Router.
Note:
Live demos not available in the slide deck. If you're interested in knowing more about those, feel free to contact me.
3. 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 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
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 / 34
4. 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.
4 / 34
5. 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.
4 / 34
6. Components:
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.
4 / 34
7. 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.
5 / 34
8. 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.
5 / 34
9. 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
Flexible and Modern - X Protocol
SQL and NoSQL together
Protocol Buffers
Asynchronous API
Developer friendly
MySQL InnoDB Cluster - Goals
Copyright @ 2019 Oracle and/or its affiliates.
5 / 34
12. High Available Distributed MySQL DB
Open Source
Fault tolerance
Automatic failover
Active/Active update anywhere (limits apply)
Automatic membership management
Adding/removing members
Network partitions, failures
Conflict detection and resolution
Prevents data loss
MySQL Group Replication
Copyright @ 2019 Oracle and/or its affiliates.
7 / 34
13. MySQL Group Replication
Implementation of Replicated Database State Machine
Total Order - Writes
XCOM - Paxos implementation
8.0+: Member provisioning using CLONE plugin.
Configurable Consistency Guarantees
eventual consistency
8.0+: per session & global read/write consistency
Using MySQL replication framework by design
binary logs
relay logs
GTIDs: Global Transaction IDs
Generally Available since MySQL 5.7
Supported on all platforms: linux, windows, solaris, macosx, freebsd
Copyright @ 2019 Oracle and/or its affiliates.
8 / 34
14. 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.
9 / 34
15. 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.
9 / 34
16. 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
Configurable Consistency Levels
Eventual
Full Consistency -- no stale reads
MySQL Group Replication - Use Cases
Copyright @ 2019 Oracle and/or its affiliates.
9 / 34
17. 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
Configurable 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.
9 / 34
19. Database Administration Interface
"MySQL Shell provides the developer and DBA with a
single intuitive, flexible, 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
Copyright @ 2019 Oracle and/or its affiliates.
10 / 34
20. DEMO
MySQL Shell
Starting an application (sysbench)
Create Cluster
Copyright @ 2019 Oracle and/or its affiliates.
11 / 34
22. Transparent Access to Database Arch.
"provide transparent routing between your application and
back-end MySQL Servers"
Transparent client connection routing
Load balancing
Application connection failover
Stateless design offers easy HA client routing
Router as part of the application stack
Little to no configuration needed
Native support for InnoDB clusters
Understands Group Replication topology
Utilizes metadata schema on each member
Currently 2 TCP Ports: PRIMARY and NON-PRIMARY
traffic
MySQL Router
Copyright @ 2019 Oracle and/or its affiliates.
12 / 34
23. DEMO
Install & Use MySQL Router
Router REST Interface
Shell Extensions
Copyright @ 2019 Oracle and/or its affiliates.
13 / 34
24. MySQL - Node Provisioning with CLONE
added in MySQL 8.0.17
Provision members that have no data
Takes Physical snapshot of data
Using standard MySQL connection (3306)
Built-in the MySQL Server
Fully integrated in MySQL InnoDB Cluster
https://mysqlhighavailability.com/mysql-innodb-cluster-automatic-node-provisioning
https://mysqlhighavailability.com/a-breakthrough-in-usability-automatic-node-provisioning
Copyright @ 2019 Oracle and/or its affiliates.
14 / 34
25. DEMO
Add third node to the group
Show CLONE
Extended Status
Copyright @ 2019 Oracle and/or its affiliates.
15 / 34
26. MySQL Group Replication - Communication
Asynchronous Replication
Copyright @ 2019 Oracle and/or its affiliates.
16 / 34
27. MySQL Group Replication - Communication
Semi Synchronous Replication
Copyright @ 2019 Oracle and/or its affiliates.
17 / 34
28. MySQL Group Replication - Communication
Group Replication
Copyright @ 2019 Oracle and/or its affiliates.
18 / 34
29. DEMO
Stop the primary node
Kill the primary node
setInstanceOption & setOption
switch primary member online
Copyright @ 2019 Oracle and/or its affiliates.
19 / 34
30. MySQL Group Replication - Network Partitions
Copyright @ 2019 Oracle and/or its affiliates.
20 / 34
31. Quorum based Network Partition Handling
Prevents Split-Brain
Ensure uneven amount of nodes
view of <=50% of total members: Minority
view of >50% of total members: Majority
will accept reads/writes
MySQL Group Replication - Network Partitions
Copyright @ 2019 Oracle and/or its affiliates.
20 / 34
32. Quorum based Network Partition Handling
Prevents Split-Brain
Ensure uneven amount of nodes
view of <=50% of total members: Minority
view of >50% of total members: Majority
will accept reads/writes
In case of event of loss of majority:
a minority partition can be forced ONLINE
Nodes in minority:
MySQL Router: moves away traffic
Fencing: members become READ_ONLY or
ABORT_SERVER
MySQL Group Replication - Network Partitions
Copyright @ 2019 Oracle and/or its affiliates.
20 / 34
33. MySQL Group Replication - Network Partitions
Majority
1. wait 5 seconds, then suspect minority is gone
2. expel minority after group_replication_member_expel_timeout seconds
(default 0, immediately) do not put the variable too high, between suspect and expel
members cannot be added/removed
no new leader can be elected
Minority
1. wait 5 seconds before suspecting itself to lost connection to the majority
2. wait group_replication_unreachable_majority_timeout (default 0, forever)
3. when timeout: group_replication_autorejoin_tries (default 0 times)
retries every 5 minutes
4. After group_replication_exit_state_action
READ_ONLY: allow stale reads to be served (latest default)
ABORT_SERVER: Shutdown MySQL
Copyright @ 2019 Oracle and/or its affiliates.
21 / 34
35. EVENTUAL (default)
BEFORE_ON_PRIMARY_FAILOVER
BEFORE
AFTER
BEFORE_AND_AFTER
MySQL Group Replication - Consistency
Default consistency guarantee is EVENTUAL
Write some data on nodeA,
Read same data immediately on nodeB,
data might be there yet... or not yet.
(Writes remain ordered and write consistency is never compromised)
Consistency level is configurable since MySQL 8.0.14 The scope can be SESSION or GLOBAL.
The possible values are:
Copyright @ 2019 Oracle and/or its affiliates.
23 / 34
36. MySQL Group Replication - Consistency - EVENTUAL
Copyright @ 2019 Oracle and/or its affiliates.
24 / 34
37. MySQL Group Replication - Consistency - BEFORE
BEFORE READ or WRITE: wait for all trx to be applied
Impact on READ & WRITE: added response time: at least network latency
Copyright @ 2019 Oracle and/or its affiliates.
25 / 34
38. MySQL Group Replication - Consistency - AFTER
AFTER WRITE: wait for all trx to be applied
Impact on WRITE only: added response time: at least network latency
Copyright @ 2019 Oracle and/or its affiliates.
26 / 34
39. MySQL Group Replication - Consistency - BEFORE_AND_AFTER
BEFORE READ or WRITE: wait for all trx to be applied
AFTER WRITE: wait for all trx to be applied
Copyright @ 2019 Oracle and/or its affiliates.
27 / 34
41. MySQL Group Replication - Performance
8.0 has Writeset based parallel replication
used during distributed recovery & Group Replication
non conflicting transactions can be executed in parallel
COMMITs remain ordered
Copyright @ 2019 Oracle and/or its affiliates.
29 / 34
43. MySQL Group Replication - Performance
in default consistency level (EVENTUAL)
expected additional response time is ± network latency between members
only at trx COMMIT
Copyright @ 2019 Oracle and/or its affiliates.
31 / 34
44. MySQL InnoDB Cluster - Continuously Evolving
Copyright @ 2019 Oracle and/or its affiliates.
32 / 34
46. Session Survey
Help us make the content even better.
Please complete the session survey in the
Mobile App.
https://dev.mysql.com/
http://www.mysql.com
https://mysqlhighavailability.com/
Copyright @ 2019 Oracle and/or its affiliates.
34 / 34