1 / 217
2 / 217
3 / 217
August 2017
MySQL Innovation
Evolution is inevitable & why the MySQL Users Base´s feedback is
important
from 5.7 to 8.0, InnoDB Cluster, Document Store
 
 
Frédéric Descamps - MySQL Evangeslist - Oracle
4 / 217
 
Safe Harbor Statement
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 and timing of any features or
functionality described for Oracle´s product remains at the sole discretion of Oracle.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
5 / 217
about.me/lefred
Who am I ?
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
6 / 217
Frédéric Descamps -
弗雷德
@lefred
MySQL Evangelist
Hacking MySQL since 3.23
devops believer
part of MySQL Team since May 2016
living in Belgium 🇧🇪
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
7 / 217
MySQL 5.7 -> 8.0
Innovation
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
8 / 217
 
 
 
MySQL 5.7 (GA)
3x Better Performance
Replication Enhancements
Optimizer Cost Model
JSON Support
Improved Security
SYS & Performance Schema
GIS
 
 
MySQL InnoDB Cluster (GA)
MySQL Group Replication
MySQL Router
MySQL Shell
MySQL 8.0 (DMR)
Data Dictionary
Roles
Unicode
CTEs
Window Functions
Security
Replication
SysSchema
GIS
MySQL Innovation: 5.7 -> 8.0
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
9 / 217
100%
 
virtually all organizations require their
most critical systems to be highly available
!
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
10 / 217
100%
 
virtually all organizations require their
most critical systems to be highly available
!
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
11 / 217
 
  "High Availability becomes a core first
class feature of MySQL!"
MySQL InnoDB Cluster
 
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
12 / 217
MySQL InnoDB Cluster: vision
  "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 @ 2017 Oracle and/or its affiliates. All rights reserved.
13 / 217
MySQL InnoDB Cluster: vision
  "A single product - MySQL - with high availability and scaling features baked in;
providing an integrated end-to-end solution that is easy to use."
InnoDB
cluster
Ease-of-Use
Extreme Scale-Out
Out-of-Box Solution
Built-in HA
High Performance
Everything Integrated
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
14 / 217
One Product: MySQL
All components created together
Tested together
Packaged together
Easy to Use
One client: MySQL Shell
Easy packaging
Integrated orchestration
Homogenous servers
Flexible and Modern
SQL and NoSQL together
Protocol Buffers
Asynchronous API
Developer friendly
Support Read/Write Scale Out
Shared clusters
Federated system of N replica sets
supporting cross shard
operations
Each replica set manages a shard
MySQL InnoDB Cluster: goals
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
15 / 217
MySQL InnoDB Cluster: Users Base Feedback
Examples of improvements suggested by our users:
Disallow changes to members that have left the group (8.0.2) - BUG#84728,
BUG#84795, BUG#84733
Influence primary election by assigning promotion weights (8.0.2).
More information on Performance Schema tables (8.0.2).
Fine tuning options for the flow control mechanism (8.0.2).
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
16 / 217
MySQL powers the Web !
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
17 / 217
MySQL powers the Web !
and many more...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
18 / 217
Web applications evolution
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
19 / 217
Web applications evolution
Everything is already Mobile first or moving to mobile very soon
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
20 / 217
Web applications evolution
Everything is already Mobile first or moving to mobile very soon
 
 
...and it impacts our roadmap and new features priority
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
21 / 217
Evolution Driving Roadmap: 1995 vs 2017
 
There was no local.
Now everything is
contextual to me as
a user.
The Internet was
global, but full of
silos. Now we are
more connected than
ever.
In the past APIs were
cumbersome,
powered by SOAP
and XML-RPC.
There is now an
increased focus on
privacy and
protecting
information.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
22 / 217
Evolution Driving Roadmap: 1995 vs 2017
 
There was no local.
Now everything is
contextual to me as
a user.
The Internet was
global, but full of
silos. Now we are
more connected than
ever.
In the past APIs were
cumbersome,
powered by SOAP
and XML-RPC.
There is now an
increased focus on
privacy and
protecting
information.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
23 / 217
Evolution Driving Roadmap: MySQL 5.7 recap
Switched to
Boost.Geometry
library
R+Tree indexes for
InnoDB
Spatial Typed for
InnoDB
Optimized InnoDB
Temporary Tables
Optimized Packed
Sort Buffer
Switched InnoDB to
DYNAMIC row format
by default
Native JSON Data
Type
20+ JSON Functions
Generated Columns
for Functional Index
JSON Comparator
Short-hand JSON
operators
Secure by Default
Password Expiration
Password Policy
Remove old
password hash
Encrypted
Tablespaces, TDE
(Enterprise)
Firewall (Enterprise)
Audit (Enterprise)
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
24 / 217
Evolution Driving Roadmap: MySQL 8.0
Geography support
Spatial Reference
System (SRS)
Support
SQL/MM Information
Schema views
Standard compliant
axis ordering in
import/export
functions
Utf8mb4 as default
Up to 16x Faster
Performance
Based on Unicode 9.0
New collations with
Accents/Case sensitivity
Japanese Collation
Aggregate, Table
and Pretty Print
Functions
Sort Performance
Improvements
Optimizer support
for in-place update
JSON Shell
Roles
Encrypted REDO Log
and UNDO Space
Finer grained
system privileges
Atomicity in
Privilege
statements
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
25 / 217
Overview of improvements & new features
What's new in MySQL 8.0 ?
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
26 / 217
Fully Function, Properly Architected
Roles
Create and Drop Roles, Grant to Roles
Grant Roles to Roles. Grant Roles to
Users
Limit Hosts that can use roles, Define
Default Roles
And even visualize Roles with SQL
function ROLES_GRAHPHML()
MySQL 8.0: Security Roles
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
27 / 217
MySQL 8.0 vs MySQL 5.7 utf8mb4
UTF8MB4 is now the default charset set !
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
28 / 217
MySQL 8.0 vs MySQL 5.7 utf8mb3
No need to use the short-cut as in 5.7
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
29 / 217
MySQL 8.0: Boosts Developer Productivity
 
Improve support for the SQL standard
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
30 / 217
MySQL 8.0: Boosts Developer Productivity
New! CTEs and Recursive CTEs
New! Window Functions
New! SKIP LOCKED and NOWAIT
UUIDs and Bitwise Functions
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
31 / 217
WITH RECURSIVE qn AS
( SELECT 1 AS a
UNION ALL
SELECT 1+a FROM qn WHERE a<10
)
SELECT * FROM qn;
MySQL 8.0: recursive CTE (example)
 
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
32 / 217
WITH RECURSIVE qn AS
( SELECT 1 AS a
UNION ALL
SELECT 1+a FROM qn WHERE a<10
)
SELECT * FROM qn;
+------+
| a |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
+------+
10 rows in set (0.01 sec)
MySQL 8.0: recursive CTE (example)
 
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
33 / 217
SELECT row_number() over ()
as `row_num`,
`name`, `country`
FROM friends
ORDER BY country;
MySQL 8.0: Window Functions (example)
 
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
34 / 217
SELECT row_number() over ()
as `row_num`,
`name`, `country`
FROM friends
ORDER BY country;
+---------+--------+----------+
| row_num | name | country |
+---------+--------+----------+
| 1 | dim0 | Belgium |
| 2 | Kenny | Belgium |
| 3 | Luis | Portugal |
| 4 | Emily | USA |
| 5 | Stoker | USA |
+---------+--------+----------+
5 rows in set (0.00 sec)
MySQL 8.0: Window Functions (example)
 
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
35 / 217
SELECT seat_no
FROM seats
JOIN seat_rows USING (row_no)
WHERE seat_no IN (3,4)
AND seat_rows.row_no IN (12)
AND booked = 'NO'
FOR UPDATE OF seats SKIP LOCKED
FOR SHARE OF seats_rows NOWAIT;
MySQL 8.0: better handing of hot rows
 
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
36 / 217
SELECT seat_no
FROM seats
JOIN seat_rows USING (row_no)
WHERE seat_no IN (3,4)
AND seat_rows.row_no IN (12)
AND booked = 'NO'
FOR UPDATE OF seats SKIP LOCKED
FOR SHARE OF seats_rows NOWAIT;
SKIP LOCKED = non deterministically
skip over locked rows
NOWAIT = error immediately if a row is
already locked
MySQL 8.0: better handing of hot rows
 
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
37 / 217
Do more with a fewer number of servers
Take more advantages of new hardware:
SSD
multi-core processors
Greater density per server
Operator Friendliness
Increase Reliability
Improved Replication Throughput
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
38 / 217
MySQL 8.0: Makes Scale Easier
Better Observability: improving PFS (more instruments, better performance)
New operations
Higher Reliability: system tables are now in InnoDB and is used for Data Dictionary
Parallel Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
39 / 217
MySQL 8.0: Performance Schema
SQL error instrumentation
Indexes
Configuration Variables
New! Data Locks
New! Histograms
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
40 / 217
PFS : Performance Comparison
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
41 / 217
PFS : Performance Comparison
Over 30x faster!
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
42 / 217
MySQL 8.0: Invisible Indexes
Indexes are "hidden" to the MySQL Optimizer
not the same as "disabled indexes"
contents are fully up to date and maintained by DML
Two use cases:
Soft Delete (Recycle Bin)
Staged Rollout
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
43 / 217
MySQL 8.0: Persist Configuration
Persist GLOBAL Server Variables
SET PERSIST max_connections = 500;
Examples Include:
Of ine_mode
Read_Only
Requires no filesystem access
New! Captures timestamp and change user
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
44 / 217
MySQL 8.0: Parallel Replication
MySQL 5.7 added support for logical clock parallel replication
in early version (<5.7.3), the logical clock is group commit based
in next versions, the logical clock is interval based
MySQL 8.0 adds support for Write Set parallelism identification
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
45 / 217
MySQL 8.0: Replication Improvements
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
46 / 217
MySQL 8.0: Replication Improvements
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
47 / 217
Source code now documented with
Doxygen
Plugin Infrastructure!
Expanded Query Hints Support
Improved Scan Query Performance
Improved BLOB Storage
Improved Memcached Interface
Cost Model Improvements
Scalabibilty Improvements
Atomicity in Privileges
Parser Refactoring
Improvements to Temporary Tables
C++11 and Toolchain
Improvements
GTID_PURGED always settable
Persistent Auto Increment
Native InnoDB Data Dictionary
Improved Information Schema
performance
New! SQL Grouping Function
New! Optimizer Trace detailed sort
statistics
New! Descending Indexes
New! Smaller Package Downloads
New! JSON Aggregate, Pretty print
functions
New! JSON performance
improvements
New! Expended Query Hints
New! Improved usability of cost
constant configuration
Group Replication
New! Transaction Save Point
support in Group Replication
New! Improved Replication Applier
Lag Statistics in Performance
Schema
New! Per Multi-source Channel
Replication Filters
New! Atomic DDL extended to the
Binary Log
New! Performance Improvements
on the Replication Applier
New! Parallel Replication Applier
Policy
New! Binary Log Management
Enhancements
New! Additional Metadata into the
Binary Log
All these features plus...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
48 / 217
49 / 217
Our vision in 4 steps
MySQL Document Store
Relational & Document Models
MySQL HA
Out-Of-Box HA
Read Scale-Out
Async Replication + Auto Failover
Write Scale-Out
Sharding
E1 E3
E2 E4
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
50 / 217
Step 2´s Architecture
Application
MySQL Connector
MySQL Router
MySQL Shell
InnoDB
cluster
Application
MySQL Connector
MySQL Router
Mp
M
M
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
51 / 217
Step 3´s Architecture
Application
MySQL Connector
MySQL Router
MySQL Shell
InnoDB
cluster
Application
MySQL Connector
MySQL Router
Mp
M
M
S1 S2 S3 S4 S...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
52 / 217
Step 4´s Architecture
Application
MySQL Connector
MySQL Router
MySQL Shell
Application
MySQL Connector
MySQL Router
InnoDB
cluster
Mp
M
M
S2 S3 S4 S...S1
InnoDB
cluster
Mp
M
M
S1 S2 S3 S4 S...
InnoDB
cluster
Mp
M
M
S1 S2 S3 S4 S...
Application
MySQL Connector
MySQL Router
Application
MySQL Connector
MySQL Router
Application
MySQL Connector
MySQL Router
replicaset1
replicaset2
replicaset3
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
53 / 217
Group Replication: heart of MySQL InnoDB
Cluster
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
54 / 217
Group Replication: heart of MySQL InnoDB
Cluster
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
55 / 217
But before going further...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
56 / 217
Database High Availability == data redundancy
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
57 / 217
Database High Availability == data redundancy
The best way to achieve data redundancy with MySQL is to use replication !
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
58 / 217
MySQL HA Architectures with asynchronous
replication
It exists a lot of possible architectures and as much tools to enforce them.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
59 / 217
MySQL HA Architectures with asynchronous
replication
It exists a lot of possible architectures and as much tools to enforce them.
They are all based on the same principle:
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
60 / 217
MySQL HA Architectures with asynchronous
replication
It exists a lot of possible architectures and as much tools to enforce them.
They are all based on the same principle:
1 master
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
61 / 217
MySQL HA Architectures with asynchronous
replication
It exists a lot of possible architectures and as much tools to enforce them.
They are all based on the same principle:
1 master
1 or many replicas (slaves)
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
62 / 217
MySQL HA Architectures with asynchronous
replication
It exists a lot of possible architectures and as much tools to enforce them.
They are all based on the same principle:
1 master
1 or many replicas (slaves)
If the master as an issue, the most accurate slave needs to takeover the role and be
promoted as master for all the remaining slaves still online.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
63 / 217
Automation
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
64 / 217
Automation
And this is the most complicated part...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
65 / 217
Automation
And this is the most complicated part...
It exists a large amount of external tools that can be used to achieve this task. Most of
them are only compatible with GNU/Linux.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
66 / 217
Automation
And this is the most complicated part...
It exists a large amount of external tools that can be used to achieve this task. Most of
them are only compatible with GNU/Linux.
Their problem is that they create complexity in the architecture's design. You need to be
DBA & sysadmin to manage those solutions:
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
67 / 217
Automation
And this is the most complicated part...
It exists a large amount of external tools that can be used to achieve this task. Most of
them are only compatible with GNU/Linux.
Their problem is that they create complexity in the architecture's design. You need to be
DBA & sysadmin to manage those solutions:
MySQL-Utilities (mysqlrplcheck, mysqlrpladmin)
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
68 / 217
Automation
And this is the most complicated part...
It exists a large amount of external tools that can be used to achieve this task. Most of
them are only compatible with GNU/Linux.
Their problem is that they create complexity in the architecture's design. You need to be
DBA & sysadmin to manage those solutions:
MySQL-Utilities (mysqlrplcheck, mysqlrpladmin)
Pacemaker with MySQL dedicated OCF
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
69 / 217
Automation
And this is the most complicated part...
It exists a large amount of external tools that can be used to achieve this task. Most of
them are only compatible with GNU/Linux.
Their problem is that they create complexity in the architecture's design. You need to be
DBA & sysadmin to manage those solutions:
MySQL-Utilities (mysqlrplcheck, mysqlrpladmin)
Pacemaker with MySQL dedicated OCF
custom solutions...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
70 / 217
MySQL Group Replication
but what is it ?!?
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
71 / 217
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
72 / 217
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
73 / 217
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
GR uses a Paxos based protocol
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
74 / 217
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
GR uses a Paxos based protocol
GR allows to write on all Group Members (cluster nodes) simultaneously while
retaining consistency
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
75 / 217
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
GR uses a Paxos based protocol
GR allows to write on all Group Members (cluster nodes) simultaneously while
retaining consistency
GR implements conflict detection and resolution
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
76 / 217
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
GR uses a Paxos based protocol
GR allows to write on all Group Members (cluster nodes) simultaneously while
retaining consistency
GR implements conflict detection and resolution
GR allows automatic distributed recovery
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
77 / 217
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
GR uses a Paxos based protocol
GR allows to write on all Group Members (cluster nodes) simultaneously while
retaining consistency
GR implements conflict detection and resolution
GR allows automatic distributed recovery
Supported on all MySQL platforms !!
Linux, Windows, Solaris, OSX, FreeBSD
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
78 / 217
And for users ?
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
79 / 217
And for users ?
no longer necessary to handle server fail-over manually or with a complicated script
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
80 / 217
And for users ?
no longer necessary to handle server fail-over manually or with a complicated script
GR provides fault tolerance
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
81 / 217
And for users ?
no longer necessary to handle server fail-over manually or with a complicated script
GR provides fault tolerance
GR enables update-everywhere setups
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
82 / 217
And for users ?
no longer necessary to handle server fail-over manually or with a complicated script
GR provides fault tolerance
GR enables update-everywhere setups
GR handles crashes, failures, re-connetcs automatically
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
83 / 217
And for users ?
no longer necessary to handle server fail-over manually or with a complicated script
GR provides fault tolerance
GR enables update-everywhere setups
GR handles crashes, failures, re-connetcs automatically
Allows an easy setup of a MySQL service high available !
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
84 / 217
OK, but how does it work ?
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
85 / 217
OK, but how does it work ?
it's just ...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
86 / 217
OK, but how does it work ?
it's just ...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
87 / 217
OK, but how does it work ?
it's just ...
... no, in fact the writesets replication is synchronous and then certification and apply of
the changes are local to each nodes and asynchronous.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
88 / 217
OK, but how does it work ?
it's just ...
... no, in fact the writesets replication is synchronous and then certification and apply of
the changes are local to each nodes and asynchronous.
not that easy to understand... right ? As a picture is worth a 1000 words, let's illustrate
this...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
89 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
90 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
91 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
92 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
93 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
94 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
95 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
96 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
97 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
98 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
99 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
100 / 217
MySQL Group Replication
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
101 / 217
Certification
Certification is the process that only needs to answer the following unique question:
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
102 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
103 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
based on unapplied earlier transactions
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
104 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
based on unapplied earlier transactions
such conflicts must come for other members/nodes
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
105 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
based on unapplied earlier transactions
such conflicts must come for other members/nodes
happens on every member/node
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
106 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
based on unapplied earlier transactions
such conflicts must come for other members/nodes
happens on every member/node
should be deterministic on every node
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
107 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
based on unapplied earlier transactions
such conflicts must come for other members/nodes
happens on every member/node
should be deterministic on every node
results are not reported to the group
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
108 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
based on unapplied earlier transactions
such conflicts must come for other members/nodes
happens on every member/node
should be deterministic on every node
results are not reported to the group
pass: enter in the apply queue
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
109 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
based on unapplied earlier transactions
such conflicts must come for other members/nodes
happens on every member/node
should be deterministic on every node
results are not reported to the group
pass: enter in the apply queue
fail: drop the transaction
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
110 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
based on unapplied earlier transactions
such conflicts must come for other members/nodes
happens on every member/node
should be deterministic on every node
results are not reported to the group
pass: enter in the apply queue
fail: drop the transaction
serialized by the total order in GCS/XCOM + GTID
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
111 / 217
Certification
Certification is the process that only needs to answer the following unique question:
can the write (transaction) be applied ?
based on unapplied earlier transactions
such conflicts must come for other members/nodes
happens on every member/node
should be deterministic on every node
results are not reported to the group
pass: enter in the apply queue
fail: drop the transaction
serialized by the total order in GCS/XCOM + GTID
cost is based on trx size (# rows & # keys)
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
112 / 217
GTID
GTIDs are the same as those used by asynchronous replication.
mysql> SELECT * FROM performance_schema.replication_connection_statusG
************************** 1. row ***************************
CHANNEL_NAME: group_replication_applier
GROUP_NAME: afb80f36-2bff-11e6-84e0-0800277dd3bf
SOURCE_UUID: afb80f36-2bff-11e6-84e0-0800277dd3bf
THREAD_ID: NULL
SERVICE_STATE: ON
COUNT_RECEIVED_HEARTBEATS: 0
LAST_HEARTBEAT_TIMESTAMP: 0000-00-00 00:00:00
RECEIVED_TRANSACTION_SET: afb80f36-2bff-11e6-84e0-0800277dd3bf:1-57,
f037578b-46b1-11e6-8005-08002774c31b:1-48937
LAST_ERROR_NUMBER: 0
LAST_ERROR_MESSAGE:
LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
113 / 217
but transactions use the Group´s GTID
mysql> show master statusG
************************** 1. row ***************************
File: mysql4-bin.000001
Position: 1501
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set: afb80f36-2bff-11e6-84e0-0800277dd3bf:1-57,
f037578b-46b1-11e6-8005-08002774c31b:1-48937
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
114 / 217
Requirements
exclusively works with InnoDB tables only
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
115 / 217
Requirements
exclusively works with InnoDB tables only
every tables must have a PK defined
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
116 / 217
Requirements
exclusively works with InnoDB tables only
every tables must have a PK defined
only IPV4 is supported
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
117 / 217
Requirements
exclusively works with InnoDB tables only
every tables must have a PK defined
only IPV4 is supported
a good network with low latency is important
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
118 / 217
Requirements
exclusively works with InnoDB tables only
every tables must have a PK defined
only IPV4 is supported
a good network with low latency is important
maximum of 9 members per group
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
119 / 217
Requirements
exclusively works with InnoDB tables only
every tables must have a PK defined
only IPV4 is supported
a good network with low latency is important
maximum of 9 members per group
log-bin must be enabled and only ROW format is supported
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
120 / 217
Requirements (2)
enable GTIDs
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
121 / 217
Requirements (2)
enable GTIDs
replication meta-data must be stored in system tables
--master-info-repository=TABLE
--relay-log-info-repository=TABLE
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
122 / 217
Requirements (2)
enable GTIDs
replication meta-data must be stored in system tables
--master-info-repository=TABLE
--relay-log-info-repository=TABLE
writesets extraction must be enabled
--transaction-write-set-extraction=XXHASH64
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
123 / 217
Requirements (2)
enable GTIDs
replication meta-data must be stored in system tables
--master-info-repository=TABLE
--relay-log-info-repository=TABLE
writesets extraction must be enabled
--transaction-write-set-extraction=XXHASH64
log-slave-updates must also be enabled
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
124 / 217
Limitations
binlog checksum is not supported (but we have checksum in the replication channel)
--binlog-checksum=NONE
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
125 / 217
Limitations
binlog checksum is not supported (but we have checksum in the replication channel)
--binlog-checksum=NONE
savepoints were not supported before 5.7.19 & 8.0.1
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
126 / 217
Limitations
binlog checksum is not supported (but we have checksum in the replication channel)
--binlog-checksum=NONE
savepoints were not supported before 5.7.19 & 8.0.1
SERIALIZABLE is not supported as transaction isolation level
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
127 / 217
Limitations
binlog checksum is not supported (but we have checksum in the replication channel)
--binlog-checksum=NONE
savepoints were not supported before 5.7.19 & 8.0.1
SERIALIZABLE is not supported as transaction isolation level
http://lefred.be/content/mysql-group-replication-limitations-savepoints/
http://lefred.be/content/mysql-group-replication-and-table-design/
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
128 / 217
Default = Single Primary Mode
By default, MySQL InnoDB Cluster runs in Single Primary Mode.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
129 / 217
Default = Single Primary Mode
By default, MySQL InnoDB Cluster runs in Single Primary Mode.
mysql> show global variables like 'group_replication_single_primary_mode';
+---------------------------------------+-------+
| Variable_name | Value |
+---------------------------------------+-------+
| group_replication_single_primary_mode | ON |
+---------------------------------------+-------+
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
130 / 217
Default = Single Primary Mode
By default, MySQL InnoDB Cluster runs in Single Primary Mode.
mysql> show global variables like 'group_replication_single_primary_mode';
+---------------------------------------+-------+
| Variable_name | Value |
+---------------------------------------+-------+
| group_replication_single_primary_mode | ON |
+---------------------------------------+-------+
In Single Primary Mode, a single member acts as the writable master (PRIMARY) and
the rest of the members act as hot-standbys (SECONDARY).
The group itself coordinates and configures itself automatically to determine which
member will act as the PRIMARY, through a leader election mechanism.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
131 / 217
Single Primary Mode - new in 8.0.2
group_replication_member_weight: influence the primary member election in Single-
Primary mode (from 0 to 100).
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
132 / 217
Single Primary Mode - new in 8.0.2
group_replication_member_weight: influence the primary member election in Single-
Primary mode (from 0 to 100).
more visibility
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
133 / 217
Single Primary Mode - new in 8.0.2
group_replication_member_weight: influence the primary member election in Single-
Primary mode (from 0 to 100).
more visibility
mysql-sql> select * from performance_schema.replication_group_members;
+--------------+--------------+--------+------+---------+-------------+-------+
| CHANNEL_NAME | MEMBER_ID | M_HOST | PORT | M_STATE | MEMBER_ROLE | M_VER |
+--------------+--------------+--------+------+---------+-------------+-------+
| gr_applier | ...-8d90-... | mysql1 | 3306 | ONLINE | SECONDARY | 8.0.2 |
| gr_applier | ...-be23-... | mysql2 | 3306 | ONLINE | SECONDARY | 8.0.2 |
| gr_applier | ...-a747-... | mysql3 | 3306 | ONLINE | PRIMARY | 8.0.2 |
+--------------+--------------+--------+------+---------+-------------+-------+
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
134 / 217
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
135 / 217
MySQL Router (GA!)
MySQL Router is lightweight middleware that provides transparent routing between your
application and backend MySQL Servers. It can be used for a wide variety of use cases,
such as providing high availability and scalability by effectively routing database traffic
to appropriate backend MySQL Servers.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
136 / 217
MySQL Router (GA!)
MySQL Router is lightweight middleware that provides transparent routing between your
application and backend MySQL Servers. It can be used for a wide variety of use cases,
such as providing high availability and scalability by effectively routing database traffic
to appropriate backend MySQL Servers.
MySQL Router doesn´t require any specific configuration. It configures itself
automatically (bootstrap) using MySQL InnoDB Cluster´s metadata.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
137 / 217
MySQL Router (GA!)
MySQL Router is lightweight middleware that provides transparent routing between your
application and backend MySQL Servers. It can be used for a wide variety of use cases,
such as providing high availability and scalability by effectively routing database traffic
to appropriate backend MySQL Servers.
MySQL Router doesn´t require any specific configuration. It configures itself
automatically (bootstrap) using MySQL InnoDB Cluster´s metadata.
The MySQL Router development will be focusing on sharding.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
138 / 217
ProxySQL has native support for Group
Replication which makes it a good choice
for advanced users.
ProxySQL
If you need some specific features that are not yet available in MySQL Router, like
transparent R/W splitting, then you can use your software of choice.
We are also collaborating with ProxySQL.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
139 / 217
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
140 / 217
MySQL Shell (GA!)
The MySQL Shell is an interactive Javascript, Python, or SQL interface supporting
development and administration for the MySQL Server and is a component of the MySQL
Server. You can use the MySQL Shell to perform data queries and updates as well as
various administration operations.
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
141 / 217
MySQL Shell (2)
The MySQL Shell provides:
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
142 / 217
MySQL Shell (2)
The MySQL Shell provides:
Both Interactive and Batch operations
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
143 / 217
MySQL Shell (2)
The MySQL Shell provides:
Both Interactive and Batch operations
Document and Relational Models
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
144 / 217
MySQL Shell (2)
The MySQL Shell provides:
Both Interactive and Batch operations
Document and Relational Models
CRUD Document and Relational APIs via scripting
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
145 / 217
MySQL Shell (2)
The MySQL Shell provides:
Both Interactive and Batch operations
Document and Relational Models
CRUD Document and Relational APIs via scripting
Traditional Table, JSON, Tab Separated output results formats
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
146 / 217
MySQL Shell (2)
The MySQL Shell provides:
Both Interactive and Batch operations
Document and Relational Models
CRUD Document and Relational APIs via scripting
Traditional Table, JSON, Tab Separated output results formats
MySQL Standard and X Protocols
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
147 / 217
MySQL Shell (2)
The MySQL Shell provides:
Both Interactive and Batch operations
Document and Relational Models
CRUD Document and Relational APIs via scripting
Traditional Table, JSON, Tab Separated output results formats
MySQL Standard and X Protocols
and more...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
148 / 217
MySQL Shell (3)
PREVIEW: the new Shell´s prompt is nice and clear !
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
149 / 217
don´t forget, this is a HA solution !
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
150 / 217
Deploying a MySQL InnoDB Cluster using MySQL
Shell´s adminAPI:
mysql-js> var i1 = 'root@instance01:3306';
mysql-js> var i2 = 'root@instance02:3306';
mysql-js> var i3 = 'root@instance03:3306';
mysql-js> dba.checkInstanceCon guration(i1);
mysql-js> dba.checkInstanceCon guration(i2);
mysql-js> dba.checkInstanceCon guration(i3);
mysql-js> shell.connect(i1);
mysql-js> var cluster = dba.createCluster('ChinaCluster');
mysql-js> cluster.checkInstanceState(i2);
mysql-js> cluster.addInstance(i2);
mysql-js> cluster.checkInstanceState(i3);
mysql-js> cluster.addInstance(i3);
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
151 / 217
DEMO !
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
152 / 217
153 / 217
RDBMS & MySQL
Relational Databases
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
154 / 217
Relational Databases
Data Integrity
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
155 / 217
Relational Databases
Data Integrity
normalization
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
156 / 217
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
157 / 217
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
158 / 217
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
ACID compliant
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
159 / 217
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
ACID compliant
transactions
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
160 / 217
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
ACID compliant
transactions
SQL
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
161 / 217
Relational Databases
Data Integrity
normalization
constraints (foreign keys, ...)
Atomicity, Consistency, Isolation, Durability
ACID compliant
transactions
SQL
powerfull query language
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
162 / 217
NoSQL & MySQL
NoSQL Databases
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
163 / 217
NoSQL or Document Store
Schemaless
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
164 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
165 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
166 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
167 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
168 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be optimally modeled into a relational
model
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
169 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be optimally modeled into a relational
model
objects persistence without the use of any ORM - mapping object-oriented
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
170 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be optimally modeled into a relational
model
objects persistence without the use of any ORM - mapping object-oriented
JSON
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
171 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be optimally modeled into a relational
model
objects persistence without the use of any ORM - mapping object-oriented
JSON
close to frontend
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
172 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be optimally modeled into a relational
model
objects persistence without the use of any ORM - mapping object-oriented
JSON
close to frontend
native in JS
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
173 / 217
NoSQL or Document Store
Schemaless
no schema design, no normalization, no foreign keys, no data types, ...
very quick initial development
Flexible data structure
embedded arrays or objects
valid solution when natural data can´t be optimally modeled into a relational
model
objects persistence without the use of any ORM - mapping object-oriented
JSON
close to frontend
native in JS
easy to learn
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
174 / 217
How DBAs see data How Developers see
data
{
"GNP" : 249704,
"Name" : "Belgium",
"government" : {
"GovernmentForm" :
"Constitutional Monarchy, Fede
"HeadOfState" : "Philippe I"
},
"_id" : "BEL",
"IndepYear" : 1830,
"demographics" : {
"Population" : 10239000,
"LifeExpectancy" : 77.80000305175
},
"geography" : {
"Region" : "Western Europe",
"SurfaceArea" : 30518,
"Continent" : "Europe"
}
}
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
175 / 217
DMBS or NoSQL ?
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
176 / 217
DMBS or NoSQL ?
Why not both ?
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
177 / 217
MySQL as Document Store
Requirements
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
178 / 217
MySQL as Document Store: requirements
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
179 / 217
MySQL as Document Store: requirements
1. support of JSON datatype
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
180 / 217
MySQL as Document Store: requirements
1. support of JSON datatype
2. CRUD Operations
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
181 / 217
MySQL as Document Store: requirements
1. support of JSON datatype
2. CRUD Operations
3. X-Plugin
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
182 / 217
MySQL as Document Store: requirements
1. support of JSON datatype
2. CRUD Operations
3. X-Plugin
4. X-Protocol
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
183 / 217
MySQL as Document Store: requirements
1. support of JSON datatype
2. CRUD Operations
3. X-Plugin
4. X-Protocol
extends and replaces the traditional MySQL protocol
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
184 / 217
MySQL as Document Store: requirements
1. support of JSON datatype
2. CRUD Operations
3. X-Plugin
4. X-Protocol
extends and replaces the traditional MySQL protocol
supports asynchronous communication to the server
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
185 / 217
MySQL as Document Store: requirements
1. support of JSON datatype
2. CRUD Operations
3. X-Plugin
4. X-Protocol
extends and replaces the traditional MySQL protocol
supports asynchronous communication to the server
supports multiple API calls like Javascript, Python, SQL...
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
186 / 217
MySQL as Document Store: requirements
1. support of JSON datatype
2. CRUD Operations
3. X-Plugin
4. X-Protocol
extends and replaces the traditional MySQL protocol
supports asynchronous communication to the server
supports multiple API calls like Javascript, Python, SQL...
5. MySQL Shell
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
187 / 217
Starting using MySQL DS in few minutes
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
188 / 217
Starting using MySQL DS in few minutes
This is the new MySQL shell as it will be in 8 ;-)
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
189 / 217
Migration from MongoDB to MySQL DS
For this example, I will use the well known restaurants collection:
We have two options:
1. We need to dump the data to a file and we will use MySQL Shell with the Python
interpreter to load the data.
1. We retrieve the data from MongoDB and load it to MySQL via the Shell in javascript
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
190 / 217
Dump and load using MySQL Shell & Python
this example is the courtesy of @datacharmer:
https://www.slideshare.net/datacharmer/mysql-documentstore
$ mongo --quiet --eval 'DBQuery.shellBatchSize=300;
var all=db.restaurants. nd() ; all' | perl -pe 
's/(?:ObjectId|ISODate)(("[^"]+"))/ $1/g' > all_recs.json
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
191 / 217
Dump and load using bash and MySQL Shell
 
$ mongo --quiet --eval 'DBQuery.shellBatchSize=30000;
var all=db.restaurants. nd() ; all' 
| perl -pe 's/(?:ObjectId|ISODate)(("[^"]+"))/ $1/g'
| head -n -1 | while read line
do
mysqlsh root@127.0.0.1 --password='' -e "rec=$line;
session.getSchema('docstore').getCollection('restaurants').add(rec).execute()"
done
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
192 / 217
Let´s query
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
193 / 217
Let´s query
That´s too much records to show it here... let´s limit it
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
194 / 217
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
195 / 217
Some more examples
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
196 / 217
Some more examples
Let´s add a selection criteria:
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
197 / 217
Syntax slightly different than MongoDB
> db.restaurants. nd({"cuisine": "French",
"borough": { $not: /^Manhattan/} },
{"_id":0, "name": 1,"cuisine": 1, "borough": 1}).limit(2)
{ "borough" : "Queens", "cuisine" : "French",
"name" : "La Baraka Restaurant" }
{ "borough" : "Queens", "cuisine" : "French",
"name" : "Air France Lounge" }
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
198 / 217
CRUD operations
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
199 / 217
what about my old SQL ?
The hidden part of the iceberg
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
200 / 217
JSON datatype is behind the scene
native datatype (since 5.7.8)
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
201 / 217
JSON datatype is behind the scene
native datatype (since 5.7.8)
JSON values are stored in MySQL tables using UTF8MB4
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
202 / 217
JSON datatype is behind the scene
native datatype (since 5.7.8)
JSON values are stored in MySQL tables using UTF8MB4
Conversion from "native" SQL types to JSON values
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
203 / 217
JSON datatype is behind the scene
native datatype (since 5.7.8)
JSON values are stored in MySQL tables using UTF8MB4
Conversion from "native" SQL types to JSON values
JSON manipulation functions (JSON_EXTRACT, JSON_KEYS,
JSON_SEARCH,...)
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
204 / 217
JSON datatype is behind the scene
native datatype (since 5.7.8)
JSON values are stored in MySQL tables using UTF8MB4
Conversion from "native" SQL types to JSON values
JSON manipulation functions (JSON_EXTRACT, JSON_KEYS,
JSON_SEARCH,...)
Generated/virtual columns
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
205 / 217
JSON datatype is behind the scene
native datatype (since 5.7.8)
JSON values are stored in MySQL tables using UTF8MB4
Conversion from "native" SQL types to JSON values
JSON manipulation functions (JSON_EXTRACT, JSON_KEYS,
JSON_SEARCH,...)
Generated/virtual columns
Indexing JSON data
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
206 / 217
JSON datatype is behind the scene
native datatype (since 5.7.8)
JSON values are stored in MySQL tables using UTF8MB4
Conversion from "native" SQL types to JSON values
JSON manipulation functions (JSON_EXTRACT, JSON_KEYS,
JSON_SEARCH,...)
Generated/virtual columns
Indexing JSON data
Foreign Keys to JSON data
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
207 / 217
JSON datatype is behind the scene
native datatype (since 5.7.8)
JSON values are stored in MySQL tables using UTF8MB4
Conversion from "native" SQL types to JSON values
JSON manipulation functions (JSON_EXTRACT, JSON_KEYS,
JSON_SEARCH,...)
Generated/virtual columns
Indexing JSON data
Foreign Keys to JSON data
SQL Views to JSON data
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
208 / 217
Example
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
209 / 217
Example
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
210 / 217
Example (2)
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
211 / 217
Example (2)
 
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
212 / 217
Example (3): explain
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
213 / 217
Example (4): add index
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
214 / 217
what do I gain ?
Conclusion
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
215 / 217
schemaless
flexible data structure
easy to start (CRUD)
Conclusion
This is the best of the two worlds in one product !
Data integrity
ACID Compliant
SQL
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
216 / 217
Thank you - 谢谢 !
Any Questions ?
Copyright @ 2017 Oracle and/or its affiliates. All rights reserved.
217 / 217

MySQL Community Meetup in China : Innovation driven by the Community

  • 1.
  • 2.
  • 3.
  • 4.
    August 2017 MySQL Innovation Evolutionis inevitable & why the MySQL Users Base´s feedback is important from 5.7 to 8.0, InnoDB Cluster, Document Store     Frédéric Descamps - MySQL Evangeslist - Oracle 4 / 217
  • 5.
      Safe Harbor Statement Thefollowing 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 and timing of any features or functionality described for Oracle´s product remains at the sole discretion of Oracle. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 5 / 217
  • 6.
    about.me/lefred Who am I? Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 6 / 217
  • 7.
    Frédéric Descamps - 弗雷德 @lefred MySQLEvangelist Hacking MySQL since 3.23 devops believer part of MySQL Team since May 2016 living in Belgium 🇧🇪 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 7 / 217
  • 8.
    MySQL 5.7 ->8.0 Innovation Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 8 / 217
  • 9.
          MySQL 5.7 (GA) 3xBetter Performance Replication Enhancements Optimizer Cost Model JSON Support Improved Security SYS & Performance Schema GIS     MySQL InnoDB Cluster (GA) MySQL Group Replication MySQL Router MySQL Shell MySQL 8.0 (DMR) Data Dictionary Roles Unicode CTEs Window Functions Security Replication SysSchema GIS MySQL Innovation: 5.7 -> 8.0 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 9 / 217
  • 10.
    100%   virtually all organizationsrequire their most critical systems to be highly available ! Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 10 / 217
  • 11.
    100%   virtually all organizationsrequire their most critical systems to be highly available ! Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 11 / 217
  • 12.
        "High Availabilitybecomes a core first class feature of MySQL!" MySQL InnoDB Cluster   Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 12 / 217
  • 13.
    MySQL InnoDB Cluster:vision   "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 @ 2017 Oracle and/or its affiliates. All rights reserved. 13 / 217
  • 14.
    MySQL InnoDB Cluster:vision   "A single product - MySQL - with high availability and scaling features baked in; providing an integrated end-to-end solution that is easy to use." InnoDB cluster Ease-of-Use Extreme Scale-Out Out-of-Box Solution Built-in HA High Performance Everything Integrated Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 14 / 217
  • 15.
    One Product: MySQL Allcomponents created together Tested together Packaged together Easy to Use One client: MySQL Shell Easy packaging Integrated orchestration Homogenous servers Flexible and Modern SQL and NoSQL together Protocol Buffers Asynchronous API Developer friendly Support Read/Write Scale Out Shared clusters Federated system of N replica sets supporting cross shard operations Each replica set manages a shard MySQL InnoDB Cluster: goals Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 15 / 217
  • 16.
    MySQL InnoDB Cluster:Users Base Feedback Examples of improvements suggested by our users: Disallow changes to members that have left the group (8.0.2) - BUG#84728, BUG#84795, BUG#84733 Influence primary election by assigning promotion weights (8.0.2). More information on Performance Schema tables (8.0.2). Fine tuning options for the flow control mechanism (8.0.2). Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 16 / 217
  • 17.
    MySQL powers theWeb ! Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 17 / 217
  • 18.
    MySQL powers theWeb ! and many more... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 18 / 217
  • 19.
    Web applications evolution Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 19 / 217
  • 20.
    Web applications evolution Everythingis already Mobile first or moving to mobile very soon Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 20 / 217
  • 21.
    Web applications evolution Everythingis already Mobile first or moving to mobile very soon     ...and it impacts our roadmap and new features priority Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 21 / 217
  • 22.
    Evolution Driving Roadmap:1995 vs 2017   There was no local. Now everything is contextual to me as a user. The Internet was global, but full of silos. Now we are more connected than ever. In the past APIs were cumbersome, powered by SOAP and XML-RPC. There is now an increased focus on privacy and protecting information. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 22 / 217
  • 23.
    Evolution Driving Roadmap:1995 vs 2017   There was no local. Now everything is contextual to me as a user. The Internet was global, but full of silos. Now we are more connected than ever. In the past APIs were cumbersome, powered by SOAP and XML-RPC. There is now an increased focus on privacy and protecting information. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 23 / 217
  • 24.
    Evolution Driving Roadmap:MySQL 5.7 recap Switched to Boost.Geometry library R+Tree indexes for InnoDB Spatial Typed for InnoDB Optimized InnoDB Temporary Tables Optimized Packed Sort Buffer Switched InnoDB to DYNAMIC row format by default Native JSON Data Type 20+ JSON Functions Generated Columns for Functional Index JSON Comparator Short-hand JSON operators Secure by Default Password Expiration Password Policy Remove old password hash Encrypted Tablespaces, TDE (Enterprise) Firewall (Enterprise) Audit (Enterprise) Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 24 / 217
  • 25.
    Evolution Driving Roadmap:MySQL 8.0 Geography support Spatial Reference System (SRS) Support SQL/MM Information Schema views Standard compliant axis ordering in import/export functions Utf8mb4 as default Up to 16x Faster Performance Based on Unicode 9.0 New collations with Accents/Case sensitivity Japanese Collation Aggregate, Table and Pretty Print Functions Sort Performance Improvements Optimizer support for in-place update JSON Shell Roles Encrypted REDO Log and UNDO Space Finer grained system privileges Atomicity in Privilege statements Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 25 / 217
  • 26.
    Overview of improvements& new features What's new in MySQL 8.0 ? Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 26 / 217
  • 27.
    Fully Function, ProperlyArchitected Roles Create and Drop Roles, Grant to Roles Grant Roles to Roles. Grant Roles to Users Limit Hosts that can use roles, Define Default Roles And even visualize Roles with SQL function ROLES_GRAHPHML() MySQL 8.0: Security Roles Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 27 / 217
  • 28.
    MySQL 8.0 vsMySQL 5.7 utf8mb4 UTF8MB4 is now the default charset set ! Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 28 / 217
  • 29.
    MySQL 8.0 vsMySQL 5.7 utf8mb3 No need to use the short-cut as in 5.7 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 29 / 217
  • 30.
    MySQL 8.0: BoostsDeveloper Productivity   Improve support for the SQL standard Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 30 / 217
  • 31.
    MySQL 8.0: BoostsDeveloper Productivity New! CTEs and Recursive CTEs New! Window Functions New! SKIP LOCKED and NOWAIT UUIDs and Bitwise Functions Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 31 / 217
  • 32.
    WITH RECURSIVE qnAS ( SELECT 1 AS a UNION ALL SELECT 1+a FROM qn WHERE a<10 ) SELECT * FROM qn; MySQL 8.0: recursive CTE (example)   Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 32 / 217
  • 33.
    WITH RECURSIVE qnAS ( SELECT 1 AS a UNION ALL SELECT 1+a FROM qn WHERE a<10 ) SELECT * FROM qn; +------+ | a | +------+ | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | +------+ 10 rows in set (0.01 sec) MySQL 8.0: recursive CTE (example)   Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 33 / 217
  • 34.
    SELECT row_number() over() as `row_num`, `name`, `country` FROM friends ORDER BY country; MySQL 8.0: Window Functions (example)   Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 34 / 217
  • 35.
    SELECT row_number() over() as `row_num`, `name`, `country` FROM friends ORDER BY country; +---------+--------+----------+ | row_num | name | country | +---------+--------+----------+ | 1 | dim0 | Belgium | | 2 | Kenny | Belgium | | 3 | Luis | Portugal | | 4 | Emily | USA | | 5 | Stoker | USA | +---------+--------+----------+ 5 rows in set (0.00 sec) MySQL 8.0: Window Functions (example)   Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 35 / 217
  • 36.
    SELECT seat_no FROM seats JOINseat_rows USING (row_no) WHERE seat_no IN (3,4) AND seat_rows.row_no IN (12) AND booked = 'NO' FOR UPDATE OF seats SKIP LOCKED FOR SHARE OF seats_rows NOWAIT; MySQL 8.0: better handing of hot rows   Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 36 / 217
  • 37.
    SELECT seat_no FROM seats JOINseat_rows USING (row_no) WHERE seat_no IN (3,4) AND seat_rows.row_no IN (12) AND booked = 'NO' FOR UPDATE OF seats SKIP LOCKED FOR SHARE OF seats_rows NOWAIT; SKIP LOCKED = non deterministically skip over locked rows NOWAIT = error immediately if a row is already locked MySQL 8.0: better handing of hot rows   Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 37 / 217
  • 38.
    Do more witha fewer number of servers Take more advantages of new hardware: SSD multi-core processors Greater density per server Operator Friendliness Increase Reliability Improved Replication Throughput Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 38 / 217
  • 39.
    MySQL 8.0: MakesScale Easier Better Observability: improving PFS (more instruments, better performance) New operations Higher Reliability: system tables are now in InnoDB and is used for Data Dictionary Parallel Replication Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 39 / 217
  • 40.
    MySQL 8.0: PerformanceSchema SQL error instrumentation Indexes Configuration Variables New! Data Locks New! Histograms Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 40 / 217
  • 41.
    PFS : PerformanceComparison Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 41 / 217
  • 42.
    PFS : PerformanceComparison Over 30x faster! Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 42 / 217
  • 43.
    MySQL 8.0: InvisibleIndexes Indexes are "hidden" to the MySQL Optimizer not the same as "disabled indexes" contents are fully up to date and maintained by DML Two use cases: Soft Delete (Recycle Bin) Staged Rollout Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 43 / 217
  • 44.
    MySQL 8.0: PersistConfiguration Persist GLOBAL Server Variables SET PERSIST max_connections = 500; Examples Include: Of ine_mode Read_Only Requires no filesystem access New! Captures timestamp and change user Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 44 / 217
  • 45.
    MySQL 8.0: ParallelReplication MySQL 5.7 added support for logical clock parallel replication in early version (<5.7.3), the logical clock is group commit based in next versions, the logical clock is interval based MySQL 8.0 adds support for Write Set parallelism identification Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 45 / 217
  • 46.
    MySQL 8.0: ReplicationImprovements Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 46 / 217
  • 47.
    MySQL 8.0: ReplicationImprovements Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 47 / 217
  • 48.
    Source code nowdocumented with Doxygen Plugin Infrastructure! Expanded Query Hints Support Improved Scan Query Performance Improved BLOB Storage Improved Memcached Interface Cost Model Improvements Scalabibilty Improvements Atomicity in Privileges Parser Refactoring Improvements to Temporary Tables C++11 and Toolchain Improvements GTID_PURGED always settable Persistent Auto Increment Native InnoDB Data Dictionary Improved Information Schema performance New! SQL Grouping Function New! Optimizer Trace detailed sort statistics New! Descending Indexes New! Smaller Package Downloads New! JSON Aggregate, Pretty print functions New! JSON performance improvements New! Expended Query Hints New! Improved usability of cost constant configuration Group Replication New! Transaction Save Point support in Group Replication New! Improved Replication Applier Lag Statistics in Performance Schema New! Per Multi-source Channel Replication Filters New! Atomic DDL extended to the Binary Log New! Performance Improvements on the Replication Applier New! Parallel Replication Applier Policy New! Binary Log Management Enhancements New! Additional Metadata into the Binary Log All these features plus... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 48 / 217
  • 49.
  • 50.
    Our vision in4 steps MySQL Document Store Relational & Document Models MySQL HA Out-Of-Box HA Read Scale-Out Async Replication + Auto Failover Write Scale-Out Sharding E1 E3 E2 E4 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 50 / 217
  • 51.
    Step 2´s Architecture Application MySQLConnector MySQL Router MySQL Shell InnoDB cluster Application MySQL Connector MySQL Router Mp M M Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 51 / 217
  • 52.
    Step 3´s Architecture Application MySQLConnector MySQL Router MySQL Shell InnoDB cluster Application MySQL Connector MySQL Router Mp M M S1 S2 S3 S4 S... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 52 / 217
  • 53.
    Step 4´s Architecture Application MySQLConnector MySQL Router MySQL Shell Application MySQL Connector MySQL Router InnoDB cluster Mp M M S2 S3 S4 S...S1 InnoDB cluster Mp M M S1 S2 S3 S4 S... InnoDB cluster Mp M M S1 S2 S3 S4 S... Application MySQL Connector MySQL Router Application MySQL Connector MySQL Router Application MySQL Connector MySQL Router replicaset1 replicaset2 replicaset3 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 53 / 217
  • 54.
    Group Replication: heartof MySQL InnoDB Cluster Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 54 / 217
  • 55.
    Group Replication: heartof MySQL InnoDB Cluster Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 55 / 217
  • 56.
    But before goingfurther... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 56 / 217
  • 57.
    Database High Availability== data redundancy Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 57 / 217
  • 58.
    Database High Availability== data redundancy The best way to achieve data redundancy with MySQL is to use replication ! Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 58 / 217
  • 59.
    MySQL HA Architectureswith asynchronous replication It exists a lot of possible architectures and as much tools to enforce them. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 59 / 217
  • 60.
    MySQL HA Architectureswith asynchronous replication It exists a lot of possible architectures and as much tools to enforce them. They are all based on the same principle: Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 60 / 217
  • 61.
    MySQL HA Architectureswith asynchronous replication It exists a lot of possible architectures and as much tools to enforce them. They are all based on the same principle: 1 master Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 61 / 217
  • 62.
    MySQL HA Architectureswith asynchronous replication It exists a lot of possible architectures and as much tools to enforce them. They are all based on the same principle: 1 master 1 or many replicas (slaves) Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 62 / 217
  • 63.
    MySQL HA Architectureswith asynchronous replication It exists a lot of possible architectures and as much tools to enforce them. They are all based on the same principle: 1 master 1 or many replicas (slaves) If the master as an issue, the most accurate slave needs to takeover the role and be promoted as master for all the remaining slaves still online. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 63 / 217
  • 64.
    Automation Copyright @ 2017Oracle and/or its affiliates. All rights reserved. 64 / 217
  • 65.
    Automation And this isthe most complicated part... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 65 / 217
  • 66.
    Automation And this isthe most complicated part... It exists a large amount of external tools that can be used to achieve this task. Most of them are only compatible with GNU/Linux. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 66 / 217
  • 67.
    Automation And this isthe most complicated part... It exists a large amount of external tools that can be used to achieve this task. Most of them are only compatible with GNU/Linux. Their problem is that they create complexity in the architecture's design. You need to be DBA & sysadmin to manage those solutions: Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 67 / 217
  • 68.
    Automation And this isthe most complicated part... It exists a large amount of external tools that can be used to achieve this task. Most of them are only compatible with GNU/Linux. Their problem is that they create complexity in the architecture's design. You need to be DBA & sysadmin to manage those solutions: MySQL-Utilities (mysqlrplcheck, mysqlrpladmin) Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 68 / 217
  • 69.
    Automation And this isthe most complicated part... It exists a large amount of external tools that can be used to achieve this task. Most of them are only compatible with GNU/Linux. Their problem is that they create complexity in the architecture's design. You need to be DBA & sysadmin to manage those solutions: MySQL-Utilities (mysqlrplcheck, mysqlrpladmin) Pacemaker with MySQL dedicated OCF Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 69 / 217
  • 70.
    Automation And this isthe most complicated part... It exists a large amount of external tools that can be used to achieve this task. Most of them are only compatible with GNU/Linux. Their problem is that they create complexity in the architecture's design. You need to be DBA & sysadmin to manage those solutions: MySQL-Utilities (mysqlrplcheck, mysqlrpladmin) Pacemaker with MySQL dedicated OCF custom solutions... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 70 / 217
  • 71.
    MySQL Group Replication butwhat is it ?!? Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 71 / 217
  • 72.
    MySQL Group Replication butwhat is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 72 / 217
  • 73.
    MySQL Group Replication butwhat is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 73 / 217
  • 74.
    MySQL Group Replication butwhat is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory GR uses a Paxos based protocol Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 74 / 217
  • 75.
    MySQL Group Replication butwhat is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory GR uses a Paxos based protocol GR allows to write on all Group Members (cluster nodes) simultaneously while retaining consistency Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 75 / 217
  • 76.
    MySQL Group Replication butwhat is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory GR uses a Paxos based protocol GR allows to write on all Group Members (cluster nodes) simultaneously while retaining consistency GR implements conflict detection and resolution Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 76 / 217
  • 77.
    MySQL Group Replication butwhat is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory GR uses a Paxos based protocol GR allows to write on all Group Members (cluster nodes) simultaneously while retaining consistency GR implements conflict detection and resolution GR allows automatic distributed recovery Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 77 / 217
  • 78.
    MySQL Group Replication butwhat is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory GR uses a Paxos based protocol GR allows to write on all Group Members (cluster nodes) simultaneously while retaining consistency GR implements conflict detection and resolution GR allows automatic distributed recovery Supported on all MySQL platforms !! Linux, Windows, Solaris, OSX, FreeBSD Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 78 / 217
  • 79.
    And for users? Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 79 / 217
  • 80.
    And for users? no longer necessary to handle server fail-over manually or with a complicated script Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 80 / 217
  • 81.
    And for users? no longer necessary to handle server fail-over manually or with a complicated script GR provides fault tolerance Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 81 / 217
  • 82.
    And for users? no longer necessary to handle server fail-over manually or with a complicated script GR provides fault tolerance GR enables update-everywhere setups Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 82 / 217
  • 83.
    And for users? no longer necessary to handle server fail-over manually or with a complicated script GR provides fault tolerance GR enables update-everywhere setups GR handles crashes, failures, re-connetcs automatically Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 83 / 217
  • 84.
    And for users? no longer necessary to handle server fail-over manually or with a complicated script GR provides fault tolerance GR enables update-everywhere setups GR handles crashes, failures, re-connetcs automatically Allows an easy setup of a MySQL service high available ! Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 84 / 217
  • 85.
    OK, but howdoes it work ? Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 85 / 217
  • 86.
    OK, but howdoes it work ? it's just ... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 86 / 217
  • 87.
    OK, but howdoes it work ? it's just ... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 87 / 217
  • 88.
    OK, but howdoes it work ? it's just ... ... no, in fact the writesets replication is synchronous and then certification and apply of the changes are local to each nodes and asynchronous. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 88 / 217
  • 89.
    OK, but howdoes it work ? it's just ... ... no, in fact the writesets replication is synchronous and then certification and apply of the changes are local to each nodes and asynchronous. not that easy to understand... right ? As a picture is worth a 1000 words, let's illustrate this... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 89 / 217
  • 90.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 90 / 217
  • 91.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 91 / 217
  • 92.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 92 / 217
  • 93.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 93 / 217
  • 94.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 94 / 217
  • 95.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 95 / 217
  • 96.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 96 / 217
  • 97.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 97 / 217
  • 98.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 98 / 217
  • 99.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 99 / 217
  • 100.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 100 / 217
  • 101.
    MySQL Group Replication Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 101 / 217
  • 102.
    Certification Certification is theprocess that only needs to answer the following unique question: Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 102 / 217
  • 103.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 103 / 217
  • 104.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? based on unapplied earlier transactions Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 104 / 217
  • 105.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? based on unapplied earlier transactions such conflicts must come for other members/nodes Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 105 / 217
  • 106.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? based on unapplied earlier transactions such conflicts must come for other members/nodes happens on every member/node Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 106 / 217
  • 107.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? based on unapplied earlier transactions such conflicts must come for other members/nodes happens on every member/node should be deterministic on every node Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 107 / 217
  • 108.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? based on unapplied earlier transactions such conflicts must come for other members/nodes happens on every member/node should be deterministic on every node results are not reported to the group Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 108 / 217
  • 109.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? based on unapplied earlier transactions such conflicts must come for other members/nodes happens on every member/node should be deterministic on every node results are not reported to the group pass: enter in the apply queue Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 109 / 217
  • 110.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? based on unapplied earlier transactions such conflicts must come for other members/nodes happens on every member/node should be deterministic on every node results are not reported to the group pass: enter in the apply queue fail: drop the transaction Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 110 / 217
  • 111.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? based on unapplied earlier transactions such conflicts must come for other members/nodes happens on every member/node should be deterministic on every node results are not reported to the group pass: enter in the apply queue fail: drop the transaction serialized by the total order in GCS/XCOM + GTID Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 111 / 217
  • 112.
    Certification Certification is theprocess that only needs to answer the following unique question: can the write (transaction) be applied ? based on unapplied earlier transactions such conflicts must come for other members/nodes happens on every member/node should be deterministic on every node results are not reported to the group pass: enter in the apply queue fail: drop the transaction serialized by the total order in GCS/XCOM + GTID cost is based on trx size (# rows & # keys) Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 112 / 217
  • 113.
    GTID GTIDs are thesame as those used by asynchronous replication. mysql> SELECT * FROM performance_schema.replication_connection_statusG ************************** 1. row *************************** CHANNEL_NAME: group_replication_applier GROUP_NAME: afb80f36-2bff-11e6-84e0-0800277dd3bf SOURCE_UUID: afb80f36-2bff-11e6-84e0-0800277dd3bf THREAD_ID: NULL SERVICE_STATE: ON COUNT_RECEIVED_HEARTBEATS: 0 LAST_HEARTBEAT_TIMESTAMP: 0000-00-00 00:00:00 RECEIVED_TRANSACTION_SET: afb80f36-2bff-11e6-84e0-0800277dd3bf:1-57, f037578b-46b1-11e6-8005-08002774c31b:1-48937 LAST_ERROR_NUMBER: 0 LAST_ERROR_MESSAGE: LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 113 / 217
  • 114.
    but transactions usethe Group´s GTID mysql> show master statusG ************************** 1. row *************************** File: mysql4-bin.000001 Position: 1501 Binlog_Do_DB: Binlog_Ignore_DB: Executed_Gtid_Set: afb80f36-2bff-11e6-84e0-0800277dd3bf:1-57, f037578b-46b1-11e6-8005-08002774c31b:1-48937 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 114 / 217
  • 115.
    Requirements exclusively works withInnoDB tables only Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 115 / 217
  • 116.
    Requirements exclusively works withInnoDB tables only every tables must have a PK defined Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 116 / 217
  • 117.
    Requirements exclusively works withInnoDB tables only every tables must have a PK defined only IPV4 is supported Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 117 / 217
  • 118.
    Requirements exclusively works withInnoDB tables only every tables must have a PK defined only IPV4 is supported a good network with low latency is important Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 118 / 217
  • 119.
    Requirements exclusively works withInnoDB tables only every tables must have a PK defined only IPV4 is supported a good network with low latency is important maximum of 9 members per group Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 119 / 217
  • 120.
    Requirements exclusively works withInnoDB tables only every tables must have a PK defined only IPV4 is supported a good network with low latency is important maximum of 9 members per group log-bin must be enabled and only ROW format is supported Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 120 / 217
  • 121.
    Requirements (2) enable GTIDs Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 121 / 217
  • 122.
    Requirements (2) enable GTIDs replicationmeta-data must be stored in system tables --master-info-repository=TABLE --relay-log-info-repository=TABLE Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 122 / 217
  • 123.
    Requirements (2) enable GTIDs replicationmeta-data must be stored in system tables --master-info-repository=TABLE --relay-log-info-repository=TABLE writesets extraction must be enabled --transaction-write-set-extraction=XXHASH64 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 123 / 217
  • 124.
    Requirements (2) enable GTIDs replicationmeta-data must be stored in system tables --master-info-repository=TABLE --relay-log-info-repository=TABLE writesets extraction must be enabled --transaction-write-set-extraction=XXHASH64 log-slave-updates must also be enabled Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 124 / 217
  • 125.
    Limitations binlog checksum isnot supported (but we have checksum in the replication channel) --binlog-checksum=NONE Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 125 / 217
  • 126.
    Limitations binlog checksum isnot supported (but we have checksum in the replication channel) --binlog-checksum=NONE savepoints were not supported before 5.7.19 & 8.0.1 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 126 / 217
  • 127.
    Limitations binlog checksum isnot supported (but we have checksum in the replication channel) --binlog-checksum=NONE savepoints were not supported before 5.7.19 & 8.0.1 SERIALIZABLE is not supported as transaction isolation level Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 127 / 217
  • 128.
    Limitations binlog checksum isnot supported (but we have checksum in the replication channel) --binlog-checksum=NONE savepoints were not supported before 5.7.19 & 8.0.1 SERIALIZABLE is not supported as transaction isolation level http://lefred.be/content/mysql-group-replication-limitations-savepoints/ http://lefred.be/content/mysql-group-replication-and-table-design/ Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 128 / 217
  • 129.
    Default = SinglePrimary Mode By default, MySQL InnoDB Cluster runs in Single Primary Mode. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 129 / 217
  • 130.
    Default = SinglePrimary Mode By default, MySQL InnoDB Cluster runs in Single Primary Mode. mysql> show global variables like 'group_replication_single_primary_mode'; +---------------------------------------+-------+ | Variable_name | Value | +---------------------------------------+-------+ | group_replication_single_primary_mode | ON | +---------------------------------------+-------+ Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 130 / 217
  • 131.
    Default = SinglePrimary Mode By default, MySQL InnoDB Cluster runs in Single Primary Mode. mysql> show global variables like 'group_replication_single_primary_mode'; +---------------------------------------+-------+ | Variable_name | Value | +---------------------------------------+-------+ | group_replication_single_primary_mode | ON | +---------------------------------------+-------+ In Single Primary Mode, a single member acts as the writable master (PRIMARY) and the rest of the members act as hot-standbys (SECONDARY). The group itself coordinates and configures itself automatically to determine which member will act as the PRIMARY, through a leader election mechanism. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 131 / 217
  • 132.
    Single Primary Mode- new in 8.0.2 group_replication_member_weight: influence the primary member election in Single- Primary mode (from 0 to 100). Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 132 / 217
  • 133.
    Single Primary Mode- new in 8.0.2 group_replication_member_weight: influence the primary member election in Single- Primary mode (from 0 to 100). more visibility Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 133 / 217
  • 134.
    Single Primary Mode- new in 8.0.2 group_replication_member_weight: influence the primary member election in Single- Primary mode (from 0 to 100). more visibility mysql-sql> select * from performance_schema.replication_group_members; +--------------+--------------+--------+------+---------+-------------+-------+ | CHANNEL_NAME | MEMBER_ID | M_HOST | PORT | M_STATE | MEMBER_ROLE | M_VER | +--------------+--------------+--------+------+---------+-------------+-------+ | gr_applier | ...-8d90-... | mysql1 | 3306 | ONLINE | SECONDARY | 8.0.2 | | gr_applier | ...-be23-... | mysql2 | 3306 | ONLINE | SECONDARY | 8.0.2 | | gr_applier | ...-a747-... | mysql3 | 3306 | ONLINE | PRIMARY | 8.0.2 | +--------------+--------------+--------+------+---------+-------------+-------+ Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 134 / 217
  • 135.
    Copyright @ 2017Oracle and/or its affiliates. All rights reserved. 135 / 217
  • 136.
    MySQL Router (GA!) MySQLRouter is lightweight middleware that provides transparent routing between your application and backend MySQL Servers. It can be used for a wide variety of use cases, such as providing high availability and scalability by effectively routing database traffic to appropriate backend MySQL Servers. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 136 / 217
  • 137.
    MySQL Router (GA!) MySQLRouter is lightweight middleware that provides transparent routing between your application and backend MySQL Servers. It can be used for a wide variety of use cases, such as providing high availability and scalability by effectively routing database traffic to appropriate backend MySQL Servers. MySQL Router doesn´t require any specific configuration. It configures itself automatically (bootstrap) using MySQL InnoDB Cluster´s metadata. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 137 / 217
  • 138.
    MySQL Router (GA!) MySQLRouter is lightweight middleware that provides transparent routing between your application and backend MySQL Servers. It can be used for a wide variety of use cases, such as providing high availability and scalability by effectively routing database traffic to appropriate backend MySQL Servers. MySQL Router doesn´t require any specific configuration. It configures itself automatically (bootstrap) using MySQL InnoDB Cluster´s metadata. The MySQL Router development will be focusing on sharding. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 138 / 217
  • 139.
    ProxySQL has nativesupport for Group Replication which makes it a good choice for advanced users. ProxySQL If you need some specific features that are not yet available in MySQL Router, like transparent R/W splitting, then you can use your software of choice. We are also collaborating with ProxySQL. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 139 / 217
  • 140.
    Copyright @ 2017Oracle and/or its affiliates. All rights reserved. 140 / 217
  • 141.
    MySQL Shell (GA!) TheMySQL Shell is an interactive Javascript, Python, or SQL interface supporting development and administration for the MySQL Server and is a component of the MySQL Server. You can use the MySQL Shell to perform data queries and updates as well as various administration operations. Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 141 / 217
  • 142.
    MySQL Shell (2) TheMySQL Shell provides: Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 142 / 217
  • 143.
    MySQL Shell (2) TheMySQL Shell provides: Both Interactive and Batch operations Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 143 / 217
  • 144.
    MySQL Shell (2) TheMySQL Shell provides: Both Interactive and Batch operations Document and Relational Models Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 144 / 217
  • 145.
    MySQL Shell (2) TheMySQL Shell provides: Both Interactive and Batch operations Document and Relational Models CRUD Document and Relational APIs via scripting Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 145 / 217
  • 146.
    MySQL Shell (2) TheMySQL Shell provides: Both Interactive and Batch operations Document and Relational Models CRUD Document and Relational APIs via scripting Traditional Table, JSON, Tab Separated output results formats Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 146 / 217
  • 147.
    MySQL Shell (2) TheMySQL Shell provides: Both Interactive and Batch operations Document and Relational Models CRUD Document and Relational APIs via scripting Traditional Table, JSON, Tab Separated output results formats MySQL Standard and X Protocols Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 147 / 217
  • 148.
    MySQL Shell (2) TheMySQL Shell provides: Both Interactive and Batch operations Document and Relational Models CRUD Document and Relational APIs via scripting Traditional Table, JSON, Tab Separated output results formats MySQL Standard and X Protocols and more... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 148 / 217
  • 149.
    MySQL Shell (3) PREVIEW:the new Shell´s prompt is nice and clear ! Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 149 / 217
  • 150.
    don´t forget, thisis a HA solution ! Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 150 / 217
  • 151.
    Deploying a MySQLInnoDB Cluster using MySQL Shell´s adminAPI: mysql-js> var i1 = 'root@instance01:3306'; mysql-js> var i2 = 'root@instance02:3306'; mysql-js> var i3 = 'root@instance03:3306'; mysql-js> dba.checkInstanceCon guration(i1); mysql-js> dba.checkInstanceCon guration(i2); mysql-js> dba.checkInstanceCon guration(i3); mysql-js> shell.connect(i1); mysql-js> var cluster = dba.createCluster('ChinaCluster'); mysql-js> cluster.checkInstanceState(i2); mysql-js> cluster.addInstance(i2); mysql-js> cluster.checkInstanceState(i3); mysql-js> cluster.addInstance(i3); Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 151 / 217
  • 152.
    DEMO ! Copyright @2017 Oracle and/or its affiliates. All rights reserved. 152 / 217
  • 153.
  • 154.
    RDBMS & MySQL RelationalDatabases Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 154 / 217
  • 155.
    Relational Databases Data Integrity Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 155 / 217
  • 156.
    Relational Databases Data Integrity normalization Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 156 / 217
  • 157.
    Relational Databases Data Integrity normalization constraints(foreign keys, ...) Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 157 / 217
  • 158.
    Relational Databases Data Integrity normalization constraints(foreign keys, ...) Atomicity, Consistency, Isolation, Durability Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 158 / 217
  • 159.
    Relational Databases Data Integrity normalization constraints(foreign keys, ...) Atomicity, Consistency, Isolation, Durability ACID compliant Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 159 / 217
  • 160.
    Relational Databases Data Integrity normalization constraints(foreign keys, ...) Atomicity, Consistency, Isolation, Durability ACID compliant transactions Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 160 / 217
  • 161.
    Relational Databases Data Integrity normalization constraints(foreign keys, ...) Atomicity, Consistency, Isolation, Durability ACID compliant transactions SQL Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 161 / 217
  • 162.
    Relational Databases Data Integrity normalization constraints(foreign keys, ...) Atomicity, Consistency, Isolation, Durability ACID compliant transactions SQL powerfull query language Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 162 / 217
  • 163.
    NoSQL & MySQL NoSQLDatabases Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 163 / 217
  • 164.
    NoSQL or DocumentStore Schemaless Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 164 / 217
  • 165.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 165 / 217
  • 166.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 166 / 217
  • 167.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 167 / 217
  • 168.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 168 / 217
  • 169.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can´t be optimally modeled into a relational model Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 169 / 217
  • 170.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can´t be optimally modeled into a relational model objects persistence without the use of any ORM - mapping object-oriented Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 170 / 217
  • 171.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can´t be optimally modeled into a relational model objects persistence without the use of any ORM - mapping object-oriented JSON Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 171 / 217
  • 172.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can´t be optimally modeled into a relational model objects persistence without the use of any ORM - mapping object-oriented JSON close to frontend Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 172 / 217
  • 173.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can´t be optimally modeled into a relational model objects persistence without the use of any ORM - mapping object-oriented JSON close to frontend native in JS Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 173 / 217
  • 174.
    NoSQL or DocumentStore Schemaless no schema design, no normalization, no foreign keys, no data types, ... very quick initial development Flexible data structure embedded arrays or objects valid solution when natural data can´t be optimally modeled into a relational model objects persistence without the use of any ORM - mapping object-oriented JSON close to frontend native in JS easy to learn Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 174 / 217
  • 175.
    How DBAs seedata How Developers see data { "GNP" : 249704, "Name" : "Belgium", "government" : { "GovernmentForm" : "Constitutional Monarchy, Fede "HeadOfState" : "Philippe I" }, "_id" : "BEL", "IndepYear" : 1830, "demographics" : { "Population" : 10239000, "LifeExpectancy" : 77.80000305175 }, "geography" : { "Region" : "Western Europe", "SurfaceArea" : 30518, "Continent" : "Europe" } } Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 175 / 217
  • 176.
    DMBS or NoSQL? Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 176 / 217
  • 177.
    DMBS or NoSQL? Why not both ? Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 177 / 217
  • 178.
    MySQL as DocumentStore Requirements Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 178 / 217
  • 179.
    MySQL as DocumentStore: requirements Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 179 / 217
  • 180.
    MySQL as DocumentStore: requirements 1. support of JSON datatype Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 180 / 217
  • 181.
    MySQL as DocumentStore: requirements 1. support of JSON datatype 2. CRUD Operations Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 181 / 217
  • 182.
    MySQL as DocumentStore: requirements 1. support of JSON datatype 2. CRUD Operations 3. X-Plugin Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 182 / 217
  • 183.
    MySQL as DocumentStore: requirements 1. support of JSON datatype 2. CRUD Operations 3. X-Plugin 4. X-Protocol Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 183 / 217
  • 184.
    MySQL as DocumentStore: requirements 1. support of JSON datatype 2. CRUD Operations 3. X-Plugin 4. X-Protocol extends and replaces the traditional MySQL protocol Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 184 / 217
  • 185.
    MySQL as DocumentStore: requirements 1. support of JSON datatype 2. CRUD Operations 3. X-Plugin 4. X-Protocol extends and replaces the traditional MySQL protocol supports asynchronous communication to the server Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 185 / 217
  • 186.
    MySQL as DocumentStore: requirements 1. support of JSON datatype 2. CRUD Operations 3. X-Plugin 4. X-Protocol extends and replaces the traditional MySQL protocol supports asynchronous communication to the server supports multiple API calls like Javascript, Python, SQL... Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 186 / 217
  • 187.
    MySQL as DocumentStore: requirements 1. support of JSON datatype 2. CRUD Operations 3. X-Plugin 4. X-Protocol extends and replaces the traditional MySQL protocol supports asynchronous communication to the server supports multiple API calls like Javascript, Python, SQL... 5. MySQL Shell Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 187 / 217
  • 188.
    Starting using MySQLDS in few minutes Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 188 / 217
  • 189.
    Starting using MySQLDS in few minutes This is the new MySQL shell as it will be in 8 ;-) Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 189 / 217
  • 190.
    Migration from MongoDBto MySQL DS For this example, I will use the well known restaurants collection: We have two options: 1. We need to dump the data to a file and we will use MySQL Shell with the Python interpreter to load the data. 1. We retrieve the data from MongoDB and load it to MySQL via the Shell in javascript Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 190 / 217
  • 191.
    Dump and loadusing MySQL Shell & Python this example is the courtesy of @datacharmer: https://www.slideshare.net/datacharmer/mysql-documentstore $ mongo --quiet --eval 'DBQuery.shellBatchSize=300; var all=db.restaurants. nd() ; all' | perl -pe 's/(?:ObjectId|ISODate)(("[^"]+"))/ $1/g' > all_recs.json Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 191 / 217
  • 192.
    Dump and loadusing bash and MySQL Shell   $ mongo --quiet --eval 'DBQuery.shellBatchSize=30000; var all=db.restaurants. nd() ; all' | perl -pe 's/(?:ObjectId|ISODate)(("[^"]+"))/ $1/g' | head -n -1 | while read line do mysqlsh root@127.0.0.1 --password='' -e "rec=$line; session.getSchema('docstore').getCollection('restaurants').add(rec).execute()" done Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 192 / 217
  • 193.
    Let´s query Copyright @2017 Oracle and/or its affiliates. All rights reserved. 193 / 217
  • 194.
    Let´s query That´s toomuch records to show it here... let´s limit it Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 194 / 217
  • 195.
    Copyright @ 2017Oracle and/or its affiliates. All rights reserved. 195 / 217
  • 196.
    Some more examples Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 196 / 217
  • 197.
    Some more examples Let´sadd a selection criteria: Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 197 / 217
  • 198.
    Syntax slightly differentthan MongoDB > db.restaurants. nd({"cuisine": "French", "borough": { $not: /^Manhattan/} }, {"_id":0, "name": 1,"cuisine": 1, "borough": 1}).limit(2) { "borough" : "Queens", "cuisine" : "French", "name" : "La Baraka Restaurant" } { "borough" : "Queens", "cuisine" : "French", "name" : "Air France Lounge" } Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 198 / 217
  • 199.
    CRUD operations Copyright @2017 Oracle and/or its affiliates. All rights reserved. 199 / 217
  • 200.
    what about myold SQL ? The hidden part of the iceberg Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 200 / 217
  • 201.
    JSON datatype isbehind the scene native datatype (since 5.7.8) Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 201 / 217
  • 202.
    JSON datatype isbehind the scene native datatype (since 5.7.8) JSON values are stored in MySQL tables using UTF8MB4 Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 202 / 217
  • 203.
    JSON datatype isbehind the scene native datatype (since 5.7.8) JSON values are stored in MySQL tables using UTF8MB4 Conversion from "native" SQL types to JSON values Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 203 / 217
  • 204.
    JSON datatype isbehind the scene native datatype (since 5.7.8) JSON values are stored in MySQL tables using UTF8MB4 Conversion from "native" SQL types to JSON values JSON manipulation functions (JSON_EXTRACT, JSON_KEYS, JSON_SEARCH,...) Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 204 / 217
  • 205.
    JSON datatype isbehind the scene native datatype (since 5.7.8) JSON values are stored in MySQL tables using UTF8MB4 Conversion from "native" SQL types to JSON values JSON manipulation functions (JSON_EXTRACT, JSON_KEYS, JSON_SEARCH,...) Generated/virtual columns Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 205 / 217
  • 206.
    JSON datatype isbehind the scene native datatype (since 5.7.8) JSON values are stored in MySQL tables using UTF8MB4 Conversion from "native" SQL types to JSON values JSON manipulation functions (JSON_EXTRACT, JSON_KEYS, JSON_SEARCH,...) Generated/virtual columns Indexing JSON data Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 206 / 217
  • 207.
    JSON datatype isbehind the scene native datatype (since 5.7.8) JSON values are stored in MySQL tables using UTF8MB4 Conversion from "native" SQL types to JSON values JSON manipulation functions (JSON_EXTRACT, JSON_KEYS, JSON_SEARCH,...) Generated/virtual columns Indexing JSON data Foreign Keys to JSON data Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 207 / 217
  • 208.
    JSON datatype isbehind the scene native datatype (since 5.7.8) JSON values are stored in MySQL tables using UTF8MB4 Conversion from "native" SQL types to JSON values JSON manipulation functions (JSON_EXTRACT, JSON_KEYS, JSON_SEARCH,...) Generated/virtual columns Indexing JSON data Foreign Keys to JSON data SQL Views to JSON data Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 208 / 217
  • 209.
    Example Copyright @ 2017Oracle and/or its affiliates. All rights reserved. 209 / 217
  • 210.
    Example Copyright @ 2017Oracle and/or its affiliates. All rights reserved. 210 / 217
  • 211.
    Example (2) Copyright @2017 Oracle and/or its affiliates. All rights reserved. 211 / 217
  • 212.
    Example (2)   Copyright @2017 Oracle and/or its affiliates. All rights reserved. 212 / 217
  • 213.
    Example (3): explain Copyright@ 2017 Oracle and/or its affiliates. All rights reserved. 213 / 217
  • 214.
    Example (4): addindex Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 214 / 217
  • 215.
    what do Igain ? Conclusion Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 215 / 217
  • 216.
    schemaless flexible data structure easyto start (CRUD) Conclusion This is the best of the two worlds in one product ! Data integrity ACID Compliant SQL Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 216 / 217
  • 217.
    Thank you -谢谢 ! Any Questions ? Copyright @ 2017 Oracle and/or its affiliates. All rights reserved. 217 / 217