SlideShare a Scribd company logo
1 of 191
Download to read offline
1 / 191
MySQL Group Replication in a nutshell
MySQL InnoDB Cluster: hands-on tutorial
 
Percona Live Amsterdam - October 2016
 
Frédéric Descamps - MySQL Community Manager - Oracle
Kenny Gryp - MySQL Practice Manager - Percona
2 / 191
 
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 @ 2016 Oracle and/or its affiliates. All rights reserved.
3 / 191
about.me/lefred
Who are we ?
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
4 / 191
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
5 / 191
Frédéric Descamps
@lefred
MySQL Evangelist
Managing MySQL since 3.23
devops believer
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
6 / 191
Kenny Gryp
@gryp
MySQL Practice Manager
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
7 / 191
get more at the conference
MySQL Group Replication
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
8 / 191
Other session
MySQL Replication: Latest Developments
Luìs Soares
Tuesday 4 October 2016
3:10pm to 4:00pm - Zürich 1
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
9 / 191
Agenda
Prepare your workstation
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
10 / 191
Agenda
Prepare your workstation
Group Replication concepts
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
11 / 191
Agenda
Prepare your workstation
Group Replication concepts
Migration from Master-Slave to GR
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
12 / 191
Agenda
Prepare your workstation
Group Replication concepts
Migration from Master-Slave to GR
How to monitor ?
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
13 / 191
Agenda
Prepare your workstation
Group Replication concepts
Migration from Master-Slave to GR
How to monitor ?
Application interaction
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
14 / 191
VirtualBox
Setup your workstation
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
15 / 191
Setup your workstation
Install VirtualBox 5
On the USB key, there is a file called PLAM16_GR.ova, please copy it on your
laptop and doubleclick on it
Start all virtual machines (mysql1, mysql2, mysql3& mysql4)
Install putty if you are using Windows
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
16 / 191
Setup your workstation
Install VirtualBox 5
On the USB key, there is a file called PLAM16_GR.ova, please copy it on your
laptop and doubleclick on it
Start all virtual machines (mysql1, mysql2, mysql3& mysql4)
Install putty if you are using Windows
Try to connect to all VM's from your terminal or putty (root password is X) :
ssh-p8821root@127.0.0.1to mysql1
ssh-p8822root@127.0.0.1to mysql2
ssh-p8823root@127.0.0.1to mysql3
ssh-p8824root@127.0.0.1to mysql4
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
17 / 191
LAB1: Current situation
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
18 / 191
launch
run_app.sh
on mysql1into
a screen
session
verify that
mysql2is a
running slave
LAB1: Current situation
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
19 / 191
Summary
 
+--------+----------+--------------+-----------------+
| | ROLE | SSHPORT | INTERNALIP |
+--------+----------+--------------+-----------------+
| | | | |
|mysql1|master |8821 | 192.168.56.11 |
| | | | |
|mysql2|slave |8822 | 192.168.56.12 |
| | | | |
|mysql3|n/a |8823 | 192.168.56.13 |
| | | | |
|mysql4|n/a |8824 | 192.168.56.14 |
| | | | |
+--------+----------+--------------+-----------------+
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
20 / 191
the magic explained
Group Replication Concept
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
21 / 191
Group Replication : what is it ?
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
22 / 191
Group Replication : what is it ?
MySQL Group Replication is one of the major components of MySQL InnoDB Cluster
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
23 / 191
Group Replication : what is it ?
MySQL Group Replication is one of the major components of MySQL InnoDB Cluster  
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
24 / 191
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
25 / 191
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
26 / 191
Group replication is a plugin !
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
27 / 191
Group replication is a plugin !
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
28 / 191
Group replication is a plugin !
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
MySQL Group Communication System (GCS) is based on Paxos Mencius
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
29 / 191
Group replication is a plugin !
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
MySQL Group Communication System (GCS) is based on Paxos Mencius
Provides virtually synchronous replication for MySQL 5.7+
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
30 / 191
Group replication is a plugin !
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
MySQL Group Communication System (GCS) is based on Paxos Mencius
Provides virtually synchronous replication for MySQL 5.7+
Supported on all MySQL platforms !!
Linux, Windows, Solaris, OSX, FreeBSD
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
31 / 191
“Multi-master update anywhere replication plugin for MySQL with built-in conflict
detection and resolution, automatic distributed recovery, and group membership.”
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
32 / 191
Group Replication : how does it work ?
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
33 / 191
Group Replication : how does it work ?
A node (member of the group) sends the changes (binlog events) made by a
transaction to the group through the GCS.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
34 / 191
Group Replication : how does it work ?
A node (member of the group) sends the changes (binlog events) made by a
transaction to the group through the GCS.
All members consume the writeset and certify it, no need to wait for all members,
ack by the majority is enough.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
35 / 191
Group Replication : how does it work ?
A node (member of the group) sends the changes (binlog events) made by a
transaction to the group through the GCS.
All members consume the writeset and certify it, no need to wait for all members,
ack by the majority is enough.
If passed it is applied, if failed, transaction is rolled back on originating server and
discarded at other servers.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
36 / 191
OK... but how does it work ?!
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
37 / 191
OK... but how does it work ?!
It's just magic !
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
38 / 191
OK... but how does it work ?!
It's just magic !
... no, the writeset replication is synchronous and then certification and applying of the
changes happen locally on each node and is asynchronous.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
39 / 191
OK... but how does it work ?!
It's just magic !
... no, the writeset replication is synchronous and then certification and applying of the
changes happen locally on each node and is asynchronous.
not that easy to understand... right ? Let's illustrate this...
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
40 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
41 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
42 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
43 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
44 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
45 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
46 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
47 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
48 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
49 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
50 / 191
MySQL Group Replication (autocommit)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
51 / 191
MySQL Group Replication (full transaction)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
52 / 191
MySQL Group Replication (full transaction)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
53 / 191
MySQL Group Replication (full transaction)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
54 / 191
MySQL Group Replication (full transaction)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
55 / 191
MySQL Group Replication (full transaction)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
56 / 191
MySQL Group Replication (full transaction)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
57 / 191
MySQL Group Replication (full transaction)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
58 / 191
MySQL Group Replication (full transaction)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
59 / 191
MySQL Group Replication (full transaction)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
60 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
61 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
62 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
63 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
64 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
65 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
66 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
67 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
68 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
69 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
70 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
71 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
72 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
73 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
74 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
75 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
76 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
77 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
78 / 191
Group Replication : Total Order Delivery - GTID
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
79 / 191
Group Replication : Optimistic Locking
Group Replication uses optimistic locking
during a transaction, local (InnoDB) locking happens
optimistically assumes there will be no conflicts across nodes
(no communication between nodes necessary)
cluster-wide conflict resolution happens only at COMMIT, during certification
Let's first have a look at the traditional locking to compare.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
80 / 191
Traditional locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
81 / 191
Traditional locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
82 / 191
Traditional locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
83 / 191
Traditional locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
84 / 191
Traditional locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
85 / 191
Traditional locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
86 / 191
Optimistic Locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
87 / 191
Optimistic Locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
88 / 191
Optimistic Locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
89 / 191
Optimistic Locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
90 / 191
Optimistic Locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
91 / 191
Optimistic Locking
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
92 / 191
Optimistic Locking
The system returns error 149 as certification failed:
ERROR1180(HY000):Goterror149duringCOMMIT
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
93 / 191
Group Replication : requirements
exclusively works with InnoDB tables only
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
94 / 191
Group Replication : requirements
exclusively works with InnoDB tables only
every tables must have a PK defined
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
95 / 191
Group Replication : requirements
exclusively works with InnoDB tables only
every tables must have a PK defined
only IPV4 is supported
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
96 / 191
Group Replication : 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 @ 2016 Oracle and/or its affiliates. All rights reserved.
97 / 191
Group Replication : 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 @ 2016 Oracle and/or its affiliates. All rights reserved.
98 / 191
Group Replication : 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-binmust be enabled and only ROW format is supported
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
99 / 191
Group Replication : requirements (2)
enable GTIDs
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
100 / 191
Group Replication : requirements (2)
enable GTIDs
replication meta-data must be stored on system tables
--master-info-repository=TABLE
--relay-log-info-repository=TABLE
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
101 / 191
Group Replication : requirements (2)
enable GTIDs
replication meta-data must be stored on system tables
--master-info-repository=TABLE
--relay-log-info-repository=TABLE
writesets extraction must be enabled
--transaction-write-set-extraction=XXHASH64
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
102 / 191
Group Replication : requirements (2)
enable GTIDs
replication meta-data must be stored on system tables
--master-info-repository=TABLE
--relay-log-info-repository=TABLE
writesets extraction must be enabled
--transaction-write-set-extraction=XXHASH64
log-slave-updatesmust be enabled
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
103 / 191
Group Replication : limitations
There are also some technical limitations:
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
104 / 191
Group Replication : limitations
There are also some technical limitations:
binlog checksum is not supported
--binlog-checksum=NONE
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
105 / 191
Group Replication : limitations
There are also some technical limitations:
binlog checksum is not supported
--binlog-checksum=NONE
Savepoints are not supported
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
106 / 191
Group Replication : limitations
There are also some technical limitations:
binlog checksum is not supported
--binlog-checksum=NONE
Savepoints are not supported
SERIALIZABLE is not supported as transaction isolation level
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
107 / 191
Group Replication : limitations
There are also some technical limitations:
binlog checksum is not supported
--binlog-checksum=NONE
Savepoints are not supported
SERIALIZABLE is not supported as transaction isolation level
an object cannot be changed concurrently at different servers by two operations,
where one of them is a DDL and the other is either a DML or DDL.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
108 / 191
Is my workload ready for Group Replication ?
As the writesets (transactions) are replicated to all available nodes on commit, and as
they are certified on every node, a very large writeset could increase the amount of
certification errors.
Additionally, changing the same record on all the nodes (hotspot) concurrently will also
cause problems.
And finally, the certification uses the primary key of the tables, a table without PK is also
a problem.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
109 / 191
Is my workload ready for Group Replication ?
Therefore, when using Group Replication, we should pay attention to these points:
PK is mandatory (and a good one is better)
avoid large transactions
avoid hotspot
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
110 / 191
ready ?
Migration from Master-Slave to GR
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
111 / 191
The plan
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
112 / 191
1) We install and
setup MySQL InnoDB
Cluster on one of the
new servers
The plan
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
113 / 191
2) We restore a
backup
3) setup
asynchronous
replication on the new
server.
The plan
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
114 / 191
4) We add a new
instance to our group
The plan
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
115 / 191
5) We point the
application to one of
our new nodes.
6) We wait and check
that asynchronous
replication is caught
up
7) we stop those
asynchronous slaves
The plan
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
116 / 191
8) We attach the
mysql2 slave to the
group
The plan
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
117 / 191
9) Use MySQL Router
for directing traffic
The plan
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
118 / 191
MySQL InnoDB Cluster from Labs is already
installed on mysql3.
Let's take a backup on mysql1:
[mysql1~]#xtrabackup--backup
--target-dir=/tmp/backup
--user=root
--password=X--host=127.0.0.1
[mysql1~]#xtrabackup--prepare
--target-dir=/tmp/backup
LAB2: Prepare mysql3
Asynchronous slave
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
119 / 191
LAB2: Prepare mysql3 (2)
Asynchronous slave
Copy the backup from mysql1to mysql3:
[mysql1~]#scp-r/tmp/backupmysql3:/tmp
And restore it:
[mysql3~]#xtrabackup--copy-back--target-dir=/tmp/backup
[mysql3~]#chown-Rmysql./var/lib/mysql
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
120 / 191
LAB3: mysql3 as asynchronous slave (2)
Asynchronous slave
Configure /etc/my.cnf:
[mysqld]
...
server_id=3
enforce_gtid_consistency=on
gtid_mode =on
log_bin
log_slave_updates
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
121 / 191
LAB2: Prepare mysql3 (3)
Asynchronous slave
Let's start MySQL on mysql3:
[mysql3~]#systemctlstartmysqld
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
122 / 191
find the GTIDs purged
change MASTER
set the purged GTIDs
start replication
LAB3: mysql3 as asynchronous slave (1)
 
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
123 / 191
LAB3: mysql3 as asynchronous slave (2)
Find the latest purged GTIDs:
[mysql3~]#cat/tmp/backup/xtrabackup_binlog_info
mysql-bin.000002 167646328 b346474c-8601-11e6-9b39-08002718d305:1-771
Connect to mysql3and setup replication:
mysql>CHANGEMASTERTOMASTER_HOST="mysql1",
MASTER_USER="repl_async",MASTER_PASSWORD='Xslave',
MASTER_AUTO_POSITION=1;
mysql>RESETMASTER;
mysql>SETglobalgtid_purged="VALUEFOUNDPREVIOUSLY";
mysql>STARTSLAVE;
Check that you receive the application's traffic
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
124 / 191
LAB4: MySQL InnoDB Cluster
Create a single instance cluster
Time to use the new MySQL Shell !
[mysql3~]#mysqlsh
Let's verify if our server is ready to become a member of a new cluster:
mysql-js>dba.validateInstance('root@mysql3:3306')
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
125 / 191
LAB4: configuration settings (2)
mysql3's my.cnf
Configure /etc/my.cnf:
[mysqld]
...
server_id=3
enforce_gtid_consistency=on
gtid_mode =on
log_bin
log_slave_updates
binlog_checksum=none
master_info_repository=TABLE
relay_log_info_repository=TABLE
transaction_write_set_extraction=XXHASH64
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
126 / 191
LAB4: configuration settings (2)
mysql3's my.cnf
Configure /etc/my.cnf:
[mysqld]
...
server_id=3
enforce_gtid_consistency=on
gtid_mode =on
log_bin
log_slave_updates
binlog_checksum=none
master_info_repository=TABLE
relay_log_info_repository=TABLE
transaction_write_set_extraction=XXHASH64
[mysql3~]#systemctlrestartmysqld
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
127 / 191
LAB4: MySQL InnoDB Cluster (3)
Create a single instance cluster
[mysql3~]#mysqlsh
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
128 / 191
LAB4: MySQL InnoDB Cluster (3)
Create a single instance cluster
[mysql3~]#mysqlsh
mysql-js>dba.validateInstance('root@mysql3:3306')
mysql-js>croot@mysql3:3306
mysql-js>cluster=dba.createCluster('plam')
The KEY is the only credential we need to remember to manage our cluster.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
129 / 191
LAB4: MySQL InnoDB Cluster (3)
Create a single instance cluster
[mysql3~]#mysqlsh
mysql-js>dba.validateInstance('root@mysql3:3306')
mysql-js>croot@mysql3:3306
mysql-js>cluster=dba.createCluster('plam')
The KEY is the only credential we need to remember to manage our cluster.
mysql-js>cluster.status()
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
130 / 191
Cluster Status
mysql-js>cluster.status()
{
"clusterName":"plam",
"defaultReplicaSet":{
"status":"ClusterisNOTtoleranttoanyfailures.",
"topology":{
"mysql3:3306":{
"address":"mysql3:3306",
"status":"ONLINE",
"role":"HA",
"mode":"R/W",
"leaves":{}
}
}
}
}
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
131 / 191
Add mysql4to the Group:
restore the backup
set the purged GTIDs
use MySQL shell
LAB5: add mysql4 to the cluster (1)
 
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
132 / 191
LAB5: add mysql4 to the cluster (2)
Copy the backup from mysql1to mysql4:
[mysql1~]#scp-r/tmp/backupmysql4:/tmp
And restore it:
[mysql4~]#xtrabackup--copy-back--target-dir=/tmp/backup
[mysql4~]#chown-Rmysql./var/lib/mysql
Start MySQL on mysql4:
[mysql4~]#systemctlstartmysqld
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
133 / 191
LAB5: MySQL shell to add an instance (3)
[mysql4~]#mysqlsh
Let's verify the config:
mysql-js>dba.validateInstance('root@mysql4:3306')
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
134 / 191
LAB5: MySQL shell to add an instance (4)
Configure /etc/my.cnf:
[mysqld]
...
server_id=4
enforce_gtid_consistency=on
gtid_mode =on
log_bin
log_slave_updates
binlog_checksum=none
master_info_repository=TABLE
relay_log_info_repository=TABLE
transaction_write_set_extraction=XXHASH64
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
135 / 191
LAB5: MySQL shell to add an instance (4)
Configure /etc/my.cnf:
[mysqld]
...
server_id=4
enforce_gtid_consistency=on
gtid_mode =on
log_bin
log_slave_updates
binlog_checksum=none
master_info_repository=TABLE
relay_log_info_repository=TABLE
transaction_write_set_extraction=XXHASH64
[mysql4~]#systemctlrestartmysqld
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
136 / 191
LAB5: MySQL InnoDB Cluster (4)
Group of 2 instances
Find the latest purged GTIDs:
[mysql4~]#cat/tmp/backup/xtrabackup_binlog_info
mysql-bin.000002 167646328 b346474c-8601-11e6-9b39-08002718d305:1-77177
Connect to mysql4and set GTID_PURGED
[mysql4~]#mysqlsh
mysql-js>croot@mysql4:3306
mysql-js>sql
mysql-sql>RESETMASTER;
mysql-sql>SETglobalgtid_purged="VALUEFOUNDPREVIOUSLY";
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
137 / 191
LAB5: MySQL InnoDB Cluster (5)
mysql-sql>js
mysql-js>dba.validateInstance('root@mysql4:3306')
mysql-js>croot@mysql3:3306
mysql-js>cluster=dba.getCluster('plam')
mysql-js>cluster.addInstance("root@mysql4:3306")
mysql-js>cluster.status()
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
138 / 191
Cluster Status
mysql-js>cluster.status()
{
"clusterName":"plam",
"defaultReplicaSet":{
"status":"ClusterisNOTtoleranttoanyfailures.",
"topology":{
"mysql3:3306":{
"address":"mysql3:3306",
"status":"ONLINE",
"role":"HA",
"mode":"R/W",
"leaves":{
"mysql4:3306":{
"address":"mysql4:3306",
"status":"RECOVERING",
"role":"HA",
"mode":"R/O",
"leaves":{}
}
}
}
}
}
}
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
139 / 191
Recovering progress
On standard MySQL, monitor the group_replication_recoverychannel to see
the progress:
mysql>showslavestatusforchannel'group_replication_recovery'G
***************************1.row***************************
Slave_IO_State:Waitingformastertosendevent
Master_Host:mysql3
Master_User:mysql_innodb_cluster_rpl_user
...
Slave_IO_Running:Yes
Slave_SQL_Running:Yes
...
Retrieved_Gtid_Set:6e7d7848-860f-11e6-92e4-08002718d305:1-6,
7c1f0c2d-860d-11e6-9df7-08002718d305:1-15,
b346474c-8601-11e6-9b39-08002718d305:1964-77177,
e8c524df-860d-11e6-9df7-08002718d305:1-2
Executed_Gtid_Set:7c1f0c2d-860d-11e6-9df7-08002718d305:1-7,
b346474c-8601-11e6-9b39-08002718d305:1-45408,
e8c524df-860d-11e6-9df7-08002718d305:1-2
...
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
140 / 191
point the application
to the cluster
Migrate the application
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
141 / 191
LAB6: Migrate the application
Now we need to point the application to mysql3, this is the only downtime !
...
[ 21257s]threads:4,tps:12.00,reads:167.94,writes:47.98,responsetime:18
[ 21258s]threads:4,tps:6.00, reads:83.96,writes: 23.99,responsetime:14
[ 21259s]threads:4,tps:7.00, reads:98.05,writes: 28.01,responsetime:16
[ 31250s]threads:4,tps:8.00, reads:111.95,writes:31.99,responsetime:30
[ 31251s]threads:4,tps:11.00,reads:154.01,writes:44.00,responsetime:13
[ 31252s]threads:4,tps:11.00,reads:153.94,writes:43.98,responsetime:12
[ 31253s]threads:4,tps:10.01,reads:140.07,writes:40.02,responsetime:17
^C
[mysql1~]#run_app.shmysql3
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
142 / 191
LAB6: Migrate the application
Make sure replication is running properly on mysql2and mysql3.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
143 / 191
LAB6: Migrate the application
Make sure replication is running properly on mysql2and mysql3.
**************************1.row***************************
...
Master_Host:mysql1
Slave_IO_Running:Yes
Slave_SQL_Running:No
...
Last_SQL_Errno:3100
Last_SQL_Error:ErrorinXid_log_event:Commitcouldnotbecompleted,
'Erroronobserverwhilerunningreplicationhook'before_commit'.'
Replicate_Ignore_Server_Ids:
Master_Server_Id:1
Master_UUID:8fbcd944-8760-11e6-9b4e-08002718d305
...
Last_SQL_Error_Timestamp:16093023:04:07
Retrieved_Gtid_Set:8fbcd944-8760-11e6-9b4e-08002718d305:360-3704
Executed_Gtid_Set:0b31b4f3-8762-11e6-bb35-08002718d305:1-7,
30212757-8762-11e6-ad73-08002718d305:1-2,
8fbcd944-8760-11e6-9b4e-08002718d305:1-2652
Auto_Position:1
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
144 / 191
LAB6: Migrate the application
Fix replication if necessary:
mysql3>startslave;
mysql3>showslavestatus;
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
145 / 191
LAB6: Migrate the application
Fix replication if necessary:
mysql3>startslave;
mysql3>showslavestatus;
Stop asynchronous replication on mysql2and mysql3:
mysql2>stopslave;
mysql3>stopslave;
Make sure gtid_executedrange on mysql2is lower or equal than on mysql3
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
146 / 191
LAB6: Migrate the application
Fix replication if necessary:
mysql3>startslave;
mysql3>showslavestatus;
Stop asynchronous replication on mysql2and mysql3:
mysql2>stopslave;
mysql3>stopslave;
Make sure gtid_executedrange on mysql2is lower or equal than on mysql3
mysql2>setglobalsuper_read_only=off;#http://bugs.mysql.com/bug.php?id=83234
mysql2>resetslaveall;
mysql3>resetslaveall;
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
147 / 191
previous slave
(mysql2) can now
be part of the cluster
Add a third instance
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
148 / 191
LAB7: Add mysql2 to the group
We first validate the instance using MySQL shell and we modify the configuration.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
149 / 191
LAB7: Add mysql2 to the group
We first validate the instance using MySQL shell and we modify the configuration.
[mysqld]
...
super_read_only=0
server_id=2
binlog_checksum=none
enforce_gtid_consistency=on
gtid_mode =on
log_bin
log_slave_updates
master_info_repository=TABLE
relay_log_info_repository=TABLE
transaction_write_set_extraction=XXHASH64
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
150 / 191
LAB7: Add mysql2 to the group
We first validate the instance using MySQL shell and we modify the configuration.
[mysqld]
...
super_read_only=0
server_id=2
binlog_checksum=none
enforce_gtid_consistency=on
gtid_mode =on
log_bin
log_slave_updates
master_info_repository=TABLE
relay_log_info_repository=TABLE
transaction_write_set_extraction=XXHASH64
[mysql2~]#systemctlrestartmysqld
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
151 / 191
LAB7: Add mysql2 to the group (2)
Back in MySQL shell we add the new instance:
[mysql2~]#mysqlsh
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
152 / 191
LAB7: Add mysql2 to the group (2)
Back in MySQL shell we add the new instance:
[mysql2~]#mysqlsh
mysql-js>dba.validateInstance('root@mysql2:3306')
mysql-js>croot@mysql3:3306
mysql-js>cluster=dba.getCluster('plam')
mysql-js>cluster.addInstance("root@mysql2:3306")
mysql-js>cluster.status()
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
153 / 191
LAB7: Add mysql2 to the group (3)
{
"clusterName":"plam",
"defaultReplicaSet":{
"status":"ClustertoleranttouptoONEfailure.",
"topology":{
"mysql3:3306":{
"address":"mysql3:3306",
"status":"ONLINE",
"role":"HA",
"mode":"R/W",
"leaves":{
"mysql4:3306":{
"address":"mysql4:3306",
"status":"ONLINE",
"role":"HA",
"mode":"R/O",
"leaves":{}
},
"mysql2:3306":{
"address":"mysql2:3306",
"status":"ONLINE",
"role":"HA",
"mode":"R/O",
"leaves":{}
}
} Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
154 / 191
WOOHOOOOW
IT WORKS!
155 / 191
writing to a single server
Single Primary Mode
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
156 / 191
Default = Single Primary Mode
By default, MySQL InnoDB Cluster enables SinglePrimaryMode.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
157 / 191
Default = Single Primary Mode
By default, MySQL InnoDB Cluster enables SinglePrimaryMode.
mysql>showglobalvariableslike'group_replication_single_primary_mode';
+---------------------------------------+-------+
|Variable_name |Value|
+---------------------------------------+-------+
|group_replication_single_primary_mode|ON |
+---------------------------------------+-------+
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
158 / 191
Default = Single Primary Mode
By default, MySQL InnoDB Cluster enables SinglePrimaryMode.
mysql>showglobalvariableslike'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 @ 2016 Oracle and/or its affiliates. All rights reserved.
159 / 191
Who's the Primary Master ?
As the Primary Master is elected, all nodes part of the group knows which one was
elected. This value is exposed in status variables:
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
160 / 191
Who's the Primary Master ?
As the Primary Master is elected, all nodes part of the group knows which one was
elected. This value is exposed in status variables:
mysql>showstatuslike'group_replication_primary_member';
+----------------------------------+--------------------------------------+
|Variable_name |Value |
+----------------------------------+--------------------------------------+
|group_replication_primary_member|28a4e51f-860e-11e6-bdc4-08002718d305|
+----------------------------------+--------------------------------------+
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
161 / 191
Who's the Primary Master ?
As the Primary Master is elected, all nodes part of the group knows which one was
elected. This value is exposed in status variables:
mysql>showstatuslike'group_replication_primary_member';
+----------------------------------+--------------------------------------+
|Variable_name |Value |
+----------------------------------+--------------------------------------+
|group_replication_primary_member|28a4e51f-860e-11e6-bdc4-08002718d305|
+----------------------------------+--------------------------------------+
mysql>selectmember_hostas"primarymaster"
fromperformance_schema.global_status
join performance_schema.replication_group_members
wherevariable_name='group_replication_primary_member'
andmember_id=variable_value;
+---------------+
|primarymaster|
+---------------+
|mysql3 |
+---------------+
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
162 / 191
get more info
Monitoring
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
163 / 191
Performance Schema
Group Replication uses Performance_Schemato expose status
mysql3>SELECT*FROMperformance_schema.replication_group_membersG
***************************1.row***************************
CHANNEL_NAME:group_replication_applier
MEMBER_ID:00db47c7-3e23-11e6-afd4-08002774c31b
MEMBER_HOST:mysql3.localdomain
MEMBER_PORT:3306
MEMBER_STATE:ONLINE
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
164 / 191
Performance Schema
Group Replication uses Performance_Schemato expose status
mysql3>SELECT*FROMperformance_schema.replication_group_membersG
***************************1.row***************************
CHANNEL_NAME:group_replication_applier
MEMBER_ID:00db47c7-3e23-11e6-afd4-08002774c31b
MEMBER_HOST:mysql3.localdomain
MEMBER_PORT:3306
MEMBER_STATE:ONLINE
mysql3>SELECT*FROMperformance_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-0000:00:00
RECEIVED_TRANSACTION_SET:afb80f36-2bff-11e6-84e0-0800277dd3bf:1-2
LAST_ERROR_NUMBER:0
LAST_ERROR_MESSAGE:
LAST_ERROR_TIMESTAMP:0000-00-0000:00:00Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
165 / 191
Member State
These are the different possible state for a node member:
ONLINE
OFFLINE
RECOVERING
ERROR: when a node is leaving but the plugin was not instructed to stop
UNREACHABLE
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
166 / 191
Status information & metrics
Members
mysql> SELECT*FROMperformance_schema.replication_group_membersG
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
167 / 191
Status information & metrics
Members
mysql> SELECT*FROMperformance_schema.replication_group_membersG
***************************1.row***************************
CHANNEL_NAME:group_replication_applier
MEMBER_ID:00db47c7-3e23-11e6-afd4-08002774c31b
MEMBER_HOST:mysql3.localdomain
MEMBER_PORT:3306
MEMBER_STATE:ONLINE
***************************2.row***************************
CHANNEL_NAME:group_replication_applier
MEMBER_ID:e1544c9d-4451-11e6-9f5a-08002774c31b
MEMBER_HOST:mysql4.localdomain.localdomain
MEMBER_PORT:3306
MEMBER_STATE:ONLINE
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
168 / 191
Status information & metrics
Connections
mysql>SELECT*FROMperformance_schema.replication_connection_statusG
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
169 / 191
Status information & metrics
Connections
mysql>SELECT*FROMperformance_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-0000:00:00
RECEIVED_TRANSACTION_SET:5de4400b-3dd7-11e6-8a71-08002774c31b:1-814089,
afb80f36-2bff-11e6-84e0-0800277dd3bf:1-2834
LAST_ERROR_NUMBER:0
LAST_ERROR_MESSAGE:
LAST_ERROR_TIMESTAMP:0000-00-0000:00:00
***************************2.row***************************
CHANNEL_NAME:group_replication_recovery
GROUP_NAME:
SOURCE_UUID:
THREAD_ID:NULL
SERVICE_STATE:OFF
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
170 / 191
Status information & metrics
Local node status
mysql>select*fromperformance_schema.replication_group_member_statsG
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
171 / 191
Status information & metrics
Local node status
mysql>select*fromperformance_schema.replication_group_member_statsG
***************************1.row***************************
CHANNEL_NAME:group_replication_applier
VIEW_ID:14679667214442885:4
MEMBER_ID:e1544c9d-4451-11e6-9f5a-08002774c31b
COUNT_TRANSACTIONS_IN_QUEUE:0
COUNT_TRANSACTIONS_CHECKED:5961
COUNT_CONFLICTS_DETECTED:0
COUNT_TRANSACTIONS_ROWS_VALIDATING:0
TRANSACTIONS_COMMITTED_ALL_MEMBERS:5de4400b-3dd7-11e6-8a71-08002774c31b:1-814089,
afb80f36-2bff-11e6-84e0-0800277dd3bf:1-5718
LAST_CONFLICT_FREE_TRANSACTION:afb80f36-2bff-11e6-84e0-0800277dd3bf:5718
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
172 / 191
Performance_Schema
You can find GR information in the following Performance_Schema tables:
replication_applier_con guration
replication_applier_status
replication_applier_status_by_worker
replication_connection_con guration
replication_connection_status
replication_group_member_stats
replication_group_members
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
173 / 191
Status during recovery
mysql>SHOWSLAVESTATUSFORCHANNEL'group_replication_recovery'G
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
174 / 191
Status during recovery
mysql>SHOWSLAVESTATUSFORCHANNEL'group_replication_recovery'G
***************************1.row***************************
Slave_IO_State:
Master_Host:<NULL>
Master_User:gr_repl
Master_Port:0
...
Relay_Log_File:mysql4-relay-bin-group_replication_recovery.000001
...
Slave_IO_Running:No
Slave_SQL_Running:No
...
Executed_Gtid_Set:5de4400b-3dd7-11e6-8a71-08002774c31b:1-814089,
afb80f36-2bff-11e6-84e0-0800277dd3bf:1-5718
...
Channel_Name:group_replication_recovery
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
175 / 191
Sys Schema
The easiest way to detect if a node is a member of the primary component (when there
are partitioning of your nodes due to network issues for example) and therefore a valid
candidate for routing queries to it, is to use the sys table.
Additional information for syscan be downloaded at
https://github.com/lefred/mysql_gr_routing_check/blob/master/addition_to_sys.sql
On the primary node:
[mysql3~]#mysql</tmp/gr_addition_to_sys.sql
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
176 / 191
Sys Schema
Is this node part of PRIMARY Partition:
mysql3>SELECTsys.gr_member_in_primary_partition();
+------------------------------------+
|sys.gr_node_in_primary_partition()|
+------------------------------------+
|YES |
+------------------------------------+
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
177 / 191
Sys Schema
Is this node part of PRIMARY Partition:
mysql3>SELECTsys.gr_member_in_primary_partition();
+------------------------------------+
|sys.gr_node_in_primary_partition()|
+------------------------------------+
|YES |
+------------------------------------+
To use as healthcheck:
mysql3>SELECT*FROMsys.gr_member_routing_candidate_status;
+------------------+-----------+---------------------+----------------------+
|viable_candidate|read_only|transactions_behind|transactions_to_cert|
+------------------+-----------+---------------------+----------------------+
|YES |YES |0 |0 |
+------------------+-----------+---------------------+----------------------+
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
178 / 191
Sys Schema - Heath Check
On one of the non Primary nodes, run the following command:
mysql-sql> ushtableswithreadlock;
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
179 / 191
Sys Schema - Heath Check
On one of the non Primary nodes, run the following command:
mysql-sql> ushtableswithreadlock;
Now you can verify what the healthcheck exposes to you:
mysql-sql>SELECT*FROMsys.gr_member_routing_candidate_status;
+------------------+-----------+---------------------+----------------------+
|viable_candidate|read_only|transactions_behind|transactions_to_cert|
+------------------+-----------+---------------------+----------------------+
|YES |YES | 950| 0|
+------------------+-----------+---------------------+----------------------+
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
180 / 191
Sys Schema - Heath Check
On one of the non Primary nodes, run the following command:
mysql-sql> ushtableswithreadlock;
Now you can verify what the healthcheck exposes to you:
mysql-sql>SELECT*FROMsys.gr_member_routing_candidate_status;
+------------------+-----------+---------------------+----------------------+
|viable_candidate|read_only|transactions_behind|transactions_to_cert|
+------------------+-----------+---------------------+----------------------+
|YES |YES | 950| 0|
+------------------+-----------+---------------------+----------------------+
mysql-sql>UNLOCKtables;
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
181 / 191
application interaction
MySQL Router
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
182 / 191
MySQL Router
We will now use mysqlrouterbetween our application and the cluster.
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
183 / 191
MySQL Router (2)
Configure MySQL Router (bootstrap it using an instance):
[mysql2~]# mysqlrouter--bootstrapmysql2:3306
PleaseentertheadministrativeMASTERkeyfortheMySQLInnoDBcluster:
MySQLRouterhasnowbeencon guredfortheInnoDBcluster'plam'.
Thefollowingconnectioninformationcanbeusedtoconnecttothecluster.
ClassicMySQLprotocolconnectionstocluster'plam':
-Read/WriteConnections:localhost:6446
-Read/OnlyConnections:localhost:6447
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
184 / 191
MySQL Router (3)
Now let's copy the configuration to mysql1(our app server) and modify it to listen to
port 3306:
[mysql2~]#scp/etc/mysqlrouter/mysqlrouter.confmysql1:/etc/mysqlrouter/
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
185 / 191
MySQL Router (3)
Now let's copy the configuration to mysql1(our app server) and modify it to listen to
port 3306:
[mysql2~]#scp/etc/mysqlrouter/mysqlrouter.confmysql1:/etc/mysqlrouter/
[routing:default_rw]
-bind_port=6446
+bind_port=3306
+bind_address=mysql1
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
186 / 191
MySQL Router (3)
Now let's copy the configuration to mysql1(our app server) and modify it to listen to
port 3306:
[mysql2~]#scp/etc/mysqlrouter/mysqlrouter.confmysql1:/etc/mysqlrouter/
[routing:default_rw]
-bind_port=6446
+bind_port=3306
+bind_address=mysql1
We can stop mysqldon mysql1and start mysqlrouterinto a screen session:
[mysql1~]#systemctlstopmysqld
[mysql1~]#mysqlrouter
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
187 / 191
MySQL Router (4)
Now we can point the application to the router:
[mysql1~]#run_app.shmysql1
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
188 / 191
MySQL Router (4)
Now we can point the application to the router:
[mysql1~]#run_app.shmysql1
Check app and kill mysqldon mysql3 (the Primary Master R/W node) !
[mysql3~]#kill-9$(pidofmysqld)
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
189 / 191
MySQL Router (4)
Now we can point the application to the router:
[mysql1~]#run_app.shmysql1
Check app and kill mysqldon mysql3 (the Primary Master R/W node) !
[mysql3~]#kill-9$(pidofmysqld)
mysql>selectmember_hostas"primary"fromperformance_schema.global_status
join performance_schema.replication_group_members
wherevariable_name='group_replication_primary_member'
andmember_id=variable_value;
+---------+
|primary|
+---------+
|mysql4 |
+---------+
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
190 / 191
Thank you !
Questions ?
Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.
191 / 191

More Related Content

What's hot

Oracle Exadata Cloud Services guide from practical experience - OOW19
Oracle Exadata Cloud Services guide from practical experience - OOW19Oracle Exadata Cloud Services guide from practical experience - OOW19
Oracle Exadata Cloud Services guide from practical experience - OOW19Nelson Calero
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationFrancisco Gonçalves
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바NeoClova
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScaleMariaDB plc
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바NeoClova
 
MySQL InnoDB Cluster and Group Replication in a Nutshell
MySQL InnoDB Cluster and Group Replication in a NutshellMySQL InnoDB Cluster and Group Replication in a Nutshell
MySQL InnoDB Cluster and Group Replication in a NutshellFrederic Descamps
 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfSrirakshaSrinivasan2
 
MariaDB 10: The Complete Tutorial
MariaDB 10: The Complete TutorialMariaDB 10: The Complete Tutorial
MariaDB 10: The Complete TutorialColin Charles
 
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법Ji-Woong Choi
 
MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)Kenny Gryp
 
Top 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous DatabaseTop 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous DatabaseSandesh Rao
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)Jean-François Gagné
 
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the CloudOracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the CloudMarkus Michalewicz
 
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and OrchestratorAlmost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and OrchestratorJean-François Gagné
 
[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기NHN FORWARD
 
MySQL Performance Schema in MySQL 8.0
MySQL Performance Schema in MySQL 8.0MySQL Performance Schema in MySQL 8.0
MySQL Performance Schema in MySQL 8.0Mayank Prasad
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxNeoClova
 
MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용I Goo Lee
 
MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!Vitor Oliveira
 

What's hot (20)

Oracle Exadata Cloud Services guide from practical experience - OOW19
Oracle Exadata Cloud Services guide from practical experience - OOW19Oracle Exadata Cloud Services guide from practical experience - OOW19
Oracle Exadata Cloud Services guide from practical experience - OOW19
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentation
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScale
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바
 
MySQL InnoDB Cluster and Group Replication in a Nutshell
MySQL InnoDB Cluster and Group Replication in a NutshellMySQL InnoDB Cluster and Group Replication in a Nutshell
MySQL InnoDB Cluster and Group Replication in a Nutshell
 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
 
MariaDB 10: The Complete Tutorial
MariaDB 10: The Complete TutorialMariaDB 10: The Complete Tutorial
MariaDB 10: The Complete Tutorial
 
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
 
MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)MySQL Group Replication - Ready For Production? (2018-04)
MySQL Group Replication - Ready For Production? (2018-04)
 
Top 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous DatabaseTop 20 FAQs on the Autonomous Database
Top 20 FAQs on the Autonomous Database
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
 
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the CloudOracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
Oracle RAC Virtualized - In VMs, in Containers, On-premises, and in the Cloud
 
PostgreSQL and RAM usage
PostgreSQL and RAM usagePostgreSQL and RAM usage
PostgreSQL and RAM usage
 
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and OrchestratorAlmost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
 
[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기[2018] MySQL 이중화 진화기
[2018] MySQL 이중화 진화기
 
MySQL Performance Schema in MySQL 8.0
MySQL Performance Schema in MySQL 8.0MySQL Performance Schema in MySQL 8.0
MySQL Performance Schema in MySQL 8.0
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptx
 
MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용
 
MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!MySQL Replication Performance Tuning for Fun and Profit!
MySQL Replication Performance Tuning for Fun and Profit!
 

Viewers also liked

Multi Source Replication With MySQL 5.7 @ Verisure
Multi Source Replication With MySQL 5.7 @ VerisureMulti Source Replication With MySQL 5.7 @ Verisure
Multi Source Replication With MySQL 5.7 @ VerisureKenny Gryp
 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsRonald Bradford
 
Why MySQL High Availability Matters
Why MySQL High Availability MattersWhy MySQL High Availability Matters
Why MySQL High Availability MattersMatt Lord
 
MySQL 5.7: Focus on InnoDB
MySQL 5.7: Focus on InnoDBMySQL 5.7: Focus on InnoDB
MySQL 5.7: Focus on InnoDBMario Beck
 
Lessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationLessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationSveta Smirnova
 
MySQL High-Availability and Scale-Out architectures
MySQL High-Availability and Scale-Out architecturesMySQL High-Availability and Scale-Out architectures
MySQL High-Availability and Scale-Out architecturesFromDual GmbH
 
Advanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteAdvanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteKenny Gryp
 
MySQL Storage Engines - which do you use? TokuDB? MyRocks? InnoDB?
MySQL Storage Engines - which do you use? TokuDB? MyRocks? InnoDB?MySQL Storage Engines - which do you use? TokuDB? MyRocks? InnoDB?
MySQL Storage Engines - which do you use? TokuDB? MyRocks? InnoDB?Sveta Smirnova
 
A New Architecture for Group Replication in Data Grid
A New Architecture for Group Replication in Data GridA New Architecture for Group Replication in Data Grid
A New Architecture for Group Replication in Data GridEditor IJCATR
 
淘宝数据库架构演进历程
淘宝数据库架构演进历程淘宝数据库架构演进历程
淘宝数据库架构演进历程zhaolinjnu
 
2010丹臣的思考
2010丹臣的思考2010丹臣的思考
2010丹臣的思考zhaolinjnu
 
Мониторинг и отладка MySQL: максимум информации при минимальных потерях
Мониторинг и отладка MySQL: максимум информации при минимальных потеряхМониторинг и отладка MySQL: максимум информации при минимальных потерях
Мониторинг и отладка MySQL: максимум информации при минимальных потеряхSveta Smirnova
 
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group ReplicationPercona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group ReplicationKenny Gryp
 
High Availability Using MySQL Group Replication
High Availability Using MySQL Group ReplicationHigh Availability Using MySQL Group Replication
High Availability Using MySQL Group ReplicationOSSCube
 
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017Ivan Ma
 
Online MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackupOnline MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackupKenny Gryp
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server DefaultsMorgan Tocker
 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group ReplicationKenny Gryp
 

Viewers also liked (20)

Multi Source Replication With MySQL 5.7 @ Verisure
Multi Source Replication With MySQL 5.7 @ VerisureMulti Source Replication With MySQL 5.7 @ Verisure
Multi Source Replication With MySQL 5.7 @ Verisure
 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery Essentials
 
Explain
ExplainExplain
Explain
 
Why MySQL High Availability Matters
Why MySQL High Availability MattersWhy MySQL High Availability Matters
Why MySQL High Availability Matters
 
MySQL 5.7: Focus on InnoDB
MySQL 5.7: Focus on InnoDBMySQL 5.7: Focus on InnoDB
MySQL 5.7: Focus on InnoDB
 
Lessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting ReplicationLessons Learned: Troubleshooting Replication
Lessons Learned: Troubleshooting Replication
 
MySQL High-Availability and Scale-Out architectures
MySQL High-Availability and Scale-Out architecturesMySQL High-Availability and Scale-Out architectures
MySQL High-Availability and Scale-Out architectures
 
Advanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteAdvanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suite
 
MySQL Storage Engines - which do you use? TokuDB? MyRocks? InnoDB?
MySQL Storage Engines - which do you use? TokuDB? MyRocks? InnoDB?MySQL Storage Engines - which do you use? TokuDB? MyRocks? InnoDB?
MySQL Storage Engines - which do you use? TokuDB? MyRocks? InnoDB?
 
A New Architecture for Group Replication in Data Grid
A New Architecture for Group Replication in Data GridA New Architecture for Group Replication in Data Grid
A New Architecture for Group Replication in Data Grid
 
淘宝数据库架构演进历程
淘宝数据库架构演进历程淘宝数据库架构演进历程
淘宝数据库架构演进历程
 
2010丹臣的思考
2010丹臣的思考2010丹臣的思考
2010丹臣的思考
 
Мониторинг и отладка MySQL: максимум информации при минимальных потерях
Мониторинг и отладка MySQL: максимум информации при минимальных потеряхМониторинг и отладка MySQL: максимум информации при минимальных потерях
Мониторинг и отладка MySQL: максимум информации при минимальных потерях
 
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group ReplicationPercona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
 
High Availability Using MySQL Group Replication
High Availability Using MySQL Group ReplicationHigh Availability Using MySQL Group Replication
High Availability Using MySQL Group Replication
 
Load Data Fast!
Load Data Fast!Load Data Fast!
Load Data Fast!
 
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
 
Online MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackupOnline MySQL Backups with Percona XtraBackup
Online MySQL Backups with Percona XtraBackup
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server Defaults
 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group Replication
 

Similar to MySQL Group Replication - HandsOn Tutorial

MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
MySQL Group Replicatio  in a nutshell - MySQL InnoDB ClusterMySQL Group Replicatio  in a nutshell - MySQL InnoDB Cluster
MySQL Group Replicatio in a nutshell - MySQL InnoDB ClusterFrederic Descamps
 
MySQL InnoDB Cluster and Group Replication in a nutshell hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a nutshell  hands-on tutorialMySQL InnoDB Cluster and Group Replication in a nutshell  hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a nutshell hands-on tutorialFrederic Descamps
 
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...
DataOpsbarcelona 2019:  Deep dive into MySQL Group Replication... the magic e...DataOpsbarcelona 2019:  Deep dive into MySQL Group Replication... the magic e...
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...Frederic Descamps
 
MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...
MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...
MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...Frederic Descamps
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsFrederic Descamps
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationFrederic Descamps
 
Boston meetup : MySQL Innodb Cluster - May 1st 2017
Boston meetup : MySQL Innodb Cluster - May 1st  2017Boston meetup : MySQL Innodb Cluster - May 1st  2017
Boston meetup : MySQL Innodb Cluster - May 1st 2017Frederic Descamps
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterFrederic Descamps
 
DataOps Barcelona - MySQL HA so easy... that's insane !
DataOps Barcelona - MySQL HA so easy... that's insane !DataOps Barcelona - MySQL HA so easy... that's insane !
DataOps Barcelona - MySQL HA so easy... that's insane !Frederic Descamps
 
Swedish MySQL User Group - MySQL InnoDB Cluster
Swedish MySQL User Group - MySQL InnoDB ClusterSwedish MySQL User Group - MySQL InnoDB Cluster
Swedish MySQL User Group - MySQL InnoDB ClusterFrederic Descamps
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterFrederic Descamps
 
MySQL High Availability with Group Replication
MySQL High Availability with Group ReplicationMySQL High Availability with Group Replication
MySQL High Availability with Group ReplicationNuno Carvalho
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterFrederic Descamps
 
MySQL InnoDB Cluster in a Nutshell - Hands-on Lab
MySQL InnoDB Cluster in a Nutshell - Hands-on LabMySQL InnoDB Cluster in a Nutshell - Hands-on Lab
MySQL InnoDB Cluster in a Nutshell - Hands-on LabFrederic Descamps
 
How to operate MySQL InnoDB Cluster with MySQL Shell
How to operate MySQL InnoDB Cluster with MySQL ShellHow to operate MySQL InnoDB Cluster with MySQL Shell
How to operate MySQL InnoDB Cluster with MySQL ShellFrederic Descamps
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterFrederic Descamps
 
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL ShellMySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL ShellMiguel Araújo
 
MySQL Innovation Day Chicago - MySQL HA So Easy : That's insane !!
MySQL Innovation Day Chicago  - MySQL HA So Easy : That's insane !!MySQL Innovation Day Chicago  - MySQL HA So Easy : That's insane !!
MySQL Innovation Day Chicago - MySQL HA So Easy : That's insane !!Frederic Descamps
 
MySQL 8.0 InnoDB Cluster - Easiest Tutorial
MySQL 8.0 InnoDB Cluster - Easiest TutorialMySQL 8.0 InnoDB Cluster - Easiest Tutorial
MySQL 8.0 InnoDB Cluster - Easiest TutorialFrederic Descamps
 
Oracle Open World 2018 / Code One : MySQL 8.0 High Availability with MySQL I...
Oracle Open World 2018 / Code One  : MySQL 8.0 High Availability with MySQL I...Oracle Open World 2018 / Code One  : MySQL 8.0 High Availability with MySQL I...
Oracle Open World 2018 / Code One : MySQL 8.0 High Availability with MySQL I...Frederic Descamps
 

Similar to MySQL Group Replication - HandsOn Tutorial (20)

MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
MySQL Group Replicatio  in a nutshell - MySQL InnoDB ClusterMySQL Group Replicatio  in a nutshell - MySQL InnoDB Cluster
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
 
MySQL InnoDB Cluster and Group Replication in a nutshell hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a nutshell  hands-on tutorialMySQL InnoDB Cluster and Group Replication in a nutshell  hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a nutshell hands-on tutorial
 
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...
DataOpsbarcelona 2019:  Deep dive into MySQL Group Replication... the magic e...DataOpsbarcelona 2019:  Deep dive into MySQL Group Replication... the magic e...
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...
 
MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...
MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...
MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & Operations
 
MySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group ReplicationMySQL InnoDB Cluster - Group Replication
MySQL InnoDB Cluster - Group Replication
 
Boston meetup : MySQL Innodb Cluster - May 1st 2017
Boston meetup : MySQL Innodb Cluster - May 1st  2017Boston meetup : MySQL Innodb Cluster - May 1st  2017
Boston meetup : MySQL Innodb Cluster - May 1st 2017
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
 
DataOps Barcelona - MySQL HA so easy... that's insane !
DataOps Barcelona - MySQL HA so easy... that's insane !DataOps Barcelona - MySQL HA so easy... that's insane !
DataOps Barcelona - MySQL HA so easy... that's insane !
 
Swedish MySQL User Group - MySQL InnoDB Cluster
Swedish MySQL User Group - MySQL InnoDB ClusterSwedish MySQL User Group - MySQL InnoDB Cluster
Swedish MySQL User Group - MySQL InnoDB Cluster
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
 
MySQL High Availability with Group Replication
MySQL High Availability with Group ReplicationMySQL High Availability with Group Replication
MySQL High Availability with Group Replication
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
 
MySQL InnoDB Cluster in a Nutshell - Hands-on Lab
MySQL InnoDB Cluster in a Nutshell - Hands-on LabMySQL InnoDB Cluster in a Nutshell - Hands-on Lab
MySQL InnoDB Cluster in a Nutshell - Hands-on Lab
 
How to operate MySQL InnoDB Cluster with MySQL Shell
How to operate MySQL InnoDB Cluster with MySQL ShellHow to operate MySQL InnoDB Cluster with MySQL Shell
How to operate MySQL InnoDB Cluster with MySQL Shell
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
 
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL ShellMySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
 
MySQL Innovation Day Chicago - MySQL HA So Easy : That's insane !!
MySQL Innovation Day Chicago  - MySQL HA So Easy : That's insane !!MySQL Innovation Day Chicago  - MySQL HA So Easy : That's insane !!
MySQL Innovation Day Chicago - MySQL HA So Easy : That's insane !!
 
MySQL 8.0 InnoDB Cluster - Easiest Tutorial
MySQL 8.0 InnoDB Cluster - Easiest TutorialMySQL 8.0 InnoDB Cluster - Easiest Tutorial
MySQL 8.0 InnoDB Cluster - Easiest Tutorial
 
Oracle Open World 2018 / Code One : MySQL 8.0 High Availability with MySQL I...
Oracle Open World 2018 / Code One  : MySQL 8.0 High Availability with MySQL I...Oracle Open World 2018 / Code One  : MySQL 8.0 High Availability with MySQL I...
Oracle Open World 2018 / Code One : MySQL 8.0 High Availability with MySQL I...
 

More from Kenny Gryp

MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08Kenny Gryp
 
MySQL Operator for Kubernetes
MySQL Operator for KubernetesMySQL Operator for Kubernetes
MySQL Operator for KubernetesKenny Gryp
 
MySQL Database Architectures - 2020-10
MySQL Database Architectures -  2020-10MySQL Database Architectures -  2020-10
MySQL Database Architectures - 2020-10Kenny Gryp
 
MySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - TutorialMySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - TutorialKenny Gryp
 
MySQL Connectors 8.0.19 & DNS SRV
MySQL Connectors 8.0.19 & DNS SRVMySQL Connectors 8.0.19 & DNS SRV
MySQL Connectors 8.0.19 & DNS SRVKenny Gryp
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterKenny Gryp
 
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesKenny Gryp
 
Reducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQLReducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQLKenny Gryp
 
Java MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & OptimizationJava MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & OptimizationKenny Gryp
 
Percona XtraDB Cluster
Percona XtraDB ClusterPercona XtraDB Cluster
Percona XtraDB ClusterKenny Gryp
 

More from Kenny Gryp (10)

MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08
 
MySQL Operator for Kubernetes
MySQL Operator for KubernetesMySQL Operator for Kubernetes
MySQL Operator for Kubernetes
 
MySQL Database Architectures - 2020-10
MySQL Database Architectures -  2020-10MySQL Database Architectures -  2020-10
MySQL Database Architectures - 2020-10
 
MySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - TutorialMySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - Tutorial
 
MySQL Connectors 8.0.19 & DNS SRV
MySQL Connectors 8.0.19 & DNS SRVMySQL Connectors 8.0.19 & DNS SRV
MySQL Connectors 8.0.19 & DNS SRV
 
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & ClusterMySQL Database Architectures - InnoDB ReplicaSet & Cluster
MySQL Database Architectures - InnoDB ReplicaSet & Cluster
 
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
 
Reducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQLReducing Risk When Upgrading MySQL
Reducing Risk When Upgrading MySQL
 
Java MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & OptimizationJava MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & Optimization
 
Percona XtraDB Cluster
Percona XtraDB ClusterPercona XtraDB Cluster
Percona XtraDB Cluster
 

Recently uploaded

DATA ANALYSIS using various data sets like shoping data set etc
DATA ANALYSIS using various data sets like shoping data set etcDATA ANALYSIS using various data sets like shoping data set etc
DATA ANALYSIS using various data sets like shoping data set etclalithasri22
 
Predictive Analysis - Using Insight-informed Data to Plan Inventory in Next 6...
Predictive Analysis - Using Insight-informed Data to Plan Inventory in Next 6...Predictive Analysis - Using Insight-informed Data to Plan Inventory in Next 6...
Predictive Analysis - Using Insight-informed Data to Plan Inventory in Next 6...ThinkInnovation
 
Role of Consumer Insights in business transformation
Role of Consumer Insights in business transformationRole of Consumer Insights in business transformation
Role of Consumer Insights in business transformationAnnie Melnic
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Boston Institute of Analytics
 
Presentation of project of business person who are success
Presentation of project of business person who are successPresentation of project of business person who are success
Presentation of project of business person who are successPratikSingh115843
 
IBEF report on the Insurance market in India
IBEF report on the Insurance market in IndiaIBEF report on the Insurance market in India
IBEF report on the Insurance market in IndiaManalVerma4
 
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis modelDecoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis modelBoston Institute of Analytics
 
Statistics For Management by Richard I. Levin 8ed.pdf
Statistics For Management by Richard I. Levin 8ed.pdfStatistics For Management by Richard I. Levin 8ed.pdf
Statistics For Management by Richard I. Levin 8ed.pdfnikeshsingh56
 
Bank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis ProjectBank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis ProjectBoston Institute of Analytics
 
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...Jack Cole
 
Digital Indonesia Report 2024 by We Are Social .pdf
Digital Indonesia Report 2024 by We Are Social .pdfDigital Indonesia Report 2024 by We Are Social .pdf
Digital Indonesia Report 2024 by We Are Social .pdfNicoChristianSunaryo
 
Decision Making Under Uncertainty - Is It Better Off Joining a Partnership or...
Decision Making Under Uncertainty - Is It Better Off Joining a Partnership or...Decision Making Under Uncertainty - Is It Better Off Joining a Partnership or...
Decision Making Under Uncertainty - Is It Better Off Joining a Partnership or...ThinkInnovation
 
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...Dr Arash Najmaei ( Phd., MBA, BSc)
 

Recently uploaded (16)

Data Analysis Project: Stroke Prediction
Data Analysis Project: Stroke PredictionData Analysis Project: Stroke Prediction
Data Analysis Project: Stroke Prediction
 
DATA ANALYSIS using various data sets like shoping data set etc
DATA ANALYSIS using various data sets like shoping data set etcDATA ANALYSIS using various data sets like shoping data set etc
DATA ANALYSIS using various data sets like shoping data set etc
 
Predictive Analysis - Using Insight-informed Data to Plan Inventory in Next 6...
Predictive Analysis - Using Insight-informed Data to Plan Inventory in Next 6...Predictive Analysis - Using Insight-informed Data to Plan Inventory in Next 6...
Predictive Analysis - Using Insight-informed Data to Plan Inventory in Next 6...
 
2023 Survey Shows Dip in High School E-Cigarette Use
2023 Survey Shows Dip in High School E-Cigarette Use2023 Survey Shows Dip in High School E-Cigarette Use
2023 Survey Shows Dip in High School E-Cigarette Use
 
Role of Consumer Insights in business transformation
Role of Consumer Insights in business transformationRole of Consumer Insights in business transformation
Role of Consumer Insights in business transformation
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
 
Presentation of project of business person who are success
Presentation of project of business person who are successPresentation of project of business person who are success
Presentation of project of business person who are success
 
IBEF report on the Insurance market in India
IBEF report on the Insurance market in IndiaIBEF report on the Insurance market in India
IBEF report on the Insurance market in India
 
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis modelDecoding Movie Sentiments: Analyzing Reviews with Data Analysis model
Decoding Movie Sentiments: Analyzing Reviews with Data Analysis model
 
Insurance Churn Prediction Data Analysis Project
Insurance Churn Prediction Data Analysis ProjectInsurance Churn Prediction Data Analysis Project
Insurance Churn Prediction Data Analysis Project
 
Statistics For Management by Richard I. Levin 8ed.pdf
Statistics For Management by Richard I. Levin 8ed.pdfStatistics For Management by Richard I. Levin 8ed.pdf
Statistics For Management by Richard I. Levin 8ed.pdf
 
Bank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis ProjectBank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis Project
 
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
why-transparency-and-traceability-are-essential-for-sustainable-supply-chains...
 
Digital Indonesia Report 2024 by We Are Social .pdf
Digital Indonesia Report 2024 by We Are Social .pdfDigital Indonesia Report 2024 by We Are Social .pdf
Digital Indonesia Report 2024 by We Are Social .pdf
 
Decision Making Under Uncertainty - Is It Better Off Joining a Partnership or...
Decision Making Under Uncertainty - Is It Better Off Joining a Partnership or...Decision Making Under Uncertainty - Is It Better Off Joining a Partnership or...
Decision Making Under Uncertainty - Is It Better Off Joining a Partnership or...
 
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
 

MySQL Group Replication - HandsOn Tutorial

  • 2. MySQL Group Replication in a nutshell MySQL InnoDB Cluster: hands-on tutorial   Percona Live Amsterdam - October 2016   Frédéric Descamps - MySQL Community Manager - Oracle Kenny Gryp - MySQL Practice Manager - Percona 2 / 191
  • 3.   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 @ 2016 Oracle and/or its affiliates. All rights reserved. 3 / 191
  • 4. about.me/lefred Who are we ? Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 4 / 191
  • 5. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 5 / 191
  • 6. Frédéric Descamps @lefred MySQL Evangelist Managing MySQL since 3.23 devops believer Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 6 / 191
  • 7. Kenny Gryp @gryp MySQL Practice Manager Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 7 / 191
  • 8. get more at the conference MySQL Group Replication Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 8 / 191
  • 9. Other session MySQL Replication: Latest Developments Luìs Soares Tuesday 4 October 2016 3:10pm to 4:00pm - Zürich 1 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 9 / 191
  • 10. Agenda Prepare your workstation Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 10 / 191
  • 11. Agenda Prepare your workstation Group Replication concepts Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 11 / 191
  • 12. Agenda Prepare your workstation Group Replication concepts Migration from Master-Slave to GR Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 12 / 191
  • 13. Agenda Prepare your workstation Group Replication concepts Migration from Master-Slave to GR How to monitor ? Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 13 / 191
  • 14. Agenda Prepare your workstation Group Replication concepts Migration from Master-Slave to GR How to monitor ? Application interaction Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 14 / 191
  • 15. VirtualBox Setup your workstation Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 15 / 191
  • 16. Setup your workstation Install VirtualBox 5 On the USB key, there is a file called PLAM16_GR.ova, please copy it on your laptop and doubleclick on it Start all virtual machines (mysql1, mysql2, mysql3& mysql4) Install putty if you are using Windows Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 16 / 191
  • 17. Setup your workstation Install VirtualBox 5 On the USB key, there is a file called PLAM16_GR.ova, please copy it on your laptop and doubleclick on it Start all virtual machines (mysql1, mysql2, mysql3& mysql4) Install putty if you are using Windows Try to connect to all VM's from your terminal or putty (root password is X) : ssh-p8821root@127.0.0.1to mysql1 ssh-p8822root@127.0.0.1to mysql2 ssh-p8823root@127.0.0.1to mysql3 ssh-p8824root@127.0.0.1to mysql4 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 17 / 191
  • 18. LAB1: Current situation Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 18 / 191
  • 19. launch run_app.sh on mysql1into a screen session verify that mysql2is a running slave LAB1: Current situation Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 19 / 191
  • 20. Summary   +--------+----------+--------------+-----------------+ | | ROLE | SSHPORT | INTERNALIP | +--------+----------+--------------+-----------------+ | | | | | |mysql1|master |8821 | 192.168.56.11 | | | | | | |mysql2|slave |8822 | 192.168.56.12 | | | | | | |mysql3|n/a |8823 | 192.168.56.13 | | | | | | |mysql4|n/a |8824 | 192.168.56.14 | | | | | | +--------+----------+--------------+-----------------+ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 20 / 191
  • 21. the magic explained Group Replication Concept Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 21 / 191
  • 22. Group Replication : what is it ? Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 22 / 191
  • 23. Group Replication : what is it ? MySQL Group Replication is one of the major components of MySQL InnoDB Cluster Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 23 / 191
  • 24. Group Replication : what is it ? MySQL Group Replication is one of the major components of MySQL InnoDB Cluster   Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 24 / 191
  • 25. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 25 / 191
  • 26. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 26 / 191
  • 27. Group replication is a plugin ! Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 27 / 191
  • 28. Group replication is a plugin ! GR is a plugin for MySQL, made by MySQL and packaged with MySQL Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 28 / 191
  • 29. Group replication is a plugin ! GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory MySQL Group Communication System (GCS) is based on Paxos Mencius Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 29 / 191
  • 30. Group replication is a plugin ! GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory MySQL Group Communication System (GCS) is based on Paxos Mencius Provides virtually synchronous replication for MySQL 5.7+ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 30 / 191
  • 31. Group replication is a plugin ! GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory MySQL Group Communication System (GCS) is based on Paxos Mencius Provides virtually synchronous replication for MySQL 5.7+ Supported on all MySQL platforms !! Linux, Windows, Solaris, OSX, FreeBSD Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 31 / 191
  • 32. “Multi-master update anywhere replication plugin for MySQL with built-in conflict detection and resolution, automatic distributed recovery, and group membership.” Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 32 / 191
  • 33. Group Replication : how does it work ? Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 33 / 191
  • 34. Group Replication : how does it work ? A node (member of the group) sends the changes (binlog events) made by a transaction to the group through the GCS. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 34 / 191
  • 35. Group Replication : how does it work ? A node (member of the group) sends the changes (binlog events) made by a transaction to the group through the GCS. All members consume the writeset and certify it, no need to wait for all members, ack by the majority is enough. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 35 / 191
  • 36. Group Replication : how does it work ? A node (member of the group) sends the changes (binlog events) made by a transaction to the group through the GCS. All members consume the writeset and certify it, no need to wait for all members, ack by the majority is enough. If passed it is applied, if failed, transaction is rolled back on originating server and discarded at other servers. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 36 / 191
  • 37. OK... but how does it work ?! Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 37 / 191
  • 38. OK... but how does it work ?! It's just magic ! Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 38 / 191
  • 39. OK... but how does it work ?! It's just magic ! ... no, the writeset replication is synchronous and then certification and applying of the changes happen locally on each node and is asynchronous. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 39 / 191
  • 40. OK... but how does it work ?! It's just magic ! ... no, the writeset replication is synchronous and then certification and applying of the changes happen locally on each node and is asynchronous. not that easy to understand... right ? Let's illustrate this... Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 40 / 191
  • 41. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 41 / 191
  • 42. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 42 / 191
  • 43. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 43 / 191
  • 44. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 44 / 191
  • 45. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 45 / 191
  • 46. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 46 / 191
  • 47. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 47 / 191
  • 48. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 48 / 191
  • 49. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 49 / 191
  • 50. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 50 / 191
  • 51. MySQL Group Replication (autocommit) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 51 / 191
  • 52. MySQL Group Replication (full transaction) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 52 / 191
  • 53. MySQL Group Replication (full transaction) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 53 / 191
  • 54. MySQL Group Replication (full transaction) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 54 / 191
  • 55. MySQL Group Replication (full transaction) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 55 / 191
  • 56. MySQL Group Replication (full transaction) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 56 / 191
  • 57. MySQL Group Replication (full transaction) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 57 / 191
  • 58. MySQL Group Replication (full transaction) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 58 / 191
  • 59. MySQL Group Replication (full transaction) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 59 / 191
  • 60. MySQL Group Replication (full transaction) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 60 / 191
  • 61. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 61 / 191
  • 62. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 62 / 191
  • 63. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 63 / 191
  • 64. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 64 / 191
  • 65. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 65 / 191
  • 66. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 66 / 191
  • 67. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 67 / 191
  • 68. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 68 / 191
  • 69. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 69 / 191
  • 70. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 70 / 191
  • 71. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 71 / 191
  • 72. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 72 / 191
  • 73. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 73 / 191
  • 74. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 74 / 191
  • 75. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 75 / 191
  • 76. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 76 / 191
  • 77. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 77 / 191
  • 78. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 78 / 191
  • 79. Group Replication : Total Order Delivery - GTID Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 79 / 191
  • 80. Group Replication : Optimistic Locking Group Replication uses optimistic locking during a transaction, local (InnoDB) locking happens optimistically assumes there will be no conflicts across nodes (no communication between nodes necessary) cluster-wide conflict resolution happens only at COMMIT, during certification Let's first have a look at the traditional locking to compare. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 80 / 191
  • 81. Traditional locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 81 / 191
  • 82. Traditional locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 82 / 191
  • 83. Traditional locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 83 / 191
  • 84. Traditional locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 84 / 191
  • 85. Traditional locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 85 / 191
  • 86. Traditional locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 86 / 191
  • 87. Optimistic Locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 87 / 191
  • 88. Optimistic Locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 88 / 191
  • 89. Optimistic Locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 89 / 191
  • 90. Optimistic Locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 90 / 191
  • 91. Optimistic Locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 91 / 191
  • 92. Optimistic Locking Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 92 / 191
  • 93. Optimistic Locking The system returns error 149 as certification failed: ERROR1180(HY000):Goterror149duringCOMMIT Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 93 / 191
  • 94. Group Replication : requirements exclusively works with InnoDB tables only Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 94 / 191
  • 95. Group Replication : requirements exclusively works with InnoDB tables only every tables must have a PK defined Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 95 / 191
  • 96. Group Replication : requirements exclusively works with InnoDB tables only every tables must have a PK defined only IPV4 is supported Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 96 / 191
  • 97. Group Replication : 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 @ 2016 Oracle and/or its affiliates. All rights reserved. 97 / 191
  • 98. Group Replication : 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 @ 2016 Oracle and/or its affiliates. All rights reserved. 98 / 191
  • 99. Group Replication : 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-binmust be enabled and only ROW format is supported Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 99 / 191
  • 100. Group Replication : requirements (2) enable GTIDs Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 100 / 191
  • 101. Group Replication : requirements (2) enable GTIDs replication meta-data must be stored on system tables --master-info-repository=TABLE --relay-log-info-repository=TABLE Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 101 / 191
  • 102. Group Replication : requirements (2) enable GTIDs replication meta-data must be stored on system tables --master-info-repository=TABLE --relay-log-info-repository=TABLE writesets extraction must be enabled --transaction-write-set-extraction=XXHASH64 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 102 / 191
  • 103. Group Replication : requirements (2) enable GTIDs replication meta-data must be stored on system tables --master-info-repository=TABLE --relay-log-info-repository=TABLE writesets extraction must be enabled --transaction-write-set-extraction=XXHASH64 log-slave-updatesmust be enabled Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 103 / 191
  • 104. Group Replication : limitations There are also some technical limitations: Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 104 / 191
  • 105. Group Replication : limitations There are also some technical limitations: binlog checksum is not supported --binlog-checksum=NONE Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 105 / 191
  • 106. Group Replication : limitations There are also some technical limitations: binlog checksum is not supported --binlog-checksum=NONE Savepoints are not supported Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 106 / 191
  • 107. Group Replication : limitations There are also some technical limitations: binlog checksum is not supported --binlog-checksum=NONE Savepoints are not supported SERIALIZABLE is not supported as transaction isolation level Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 107 / 191
  • 108. Group Replication : limitations There are also some technical limitations: binlog checksum is not supported --binlog-checksum=NONE Savepoints are not supported SERIALIZABLE is not supported as transaction isolation level an object cannot be changed concurrently at different servers by two operations, where one of them is a DDL and the other is either a DML or DDL. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 108 / 191
  • 109. Is my workload ready for Group Replication ? As the writesets (transactions) are replicated to all available nodes on commit, and as they are certified on every node, a very large writeset could increase the amount of certification errors. Additionally, changing the same record on all the nodes (hotspot) concurrently will also cause problems. And finally, the certification uses the primary key of the tables, a table without PK is also a problem. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 109 / 191
  • 110. Is my workload ready for Group Replication ? Therefore, when using Group Replication, we should pay attention to these points: PK is mandatory (and a good one is better) avoid large transactions avoid hotspot Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 110 / 191
  • 111. ready ? Migration from Master-Slave to GR Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 111 / 191
  • 112. The plan Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 112 / 191
  • 113. 1) We install and setup MySQL InnoDB Cluster on one of the new servers The plan Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 113 / 191
  • 114. 2) We restore a backup 3) setup asynchronous replication on the new server. The plan Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 114 / 191
  • 115. 4) We add a new instance to our group The plan Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 115 / 191
  • 116. 5) We point the application to one of our new nodes. 6) We wait and check that asynchronous replication is caught up 7) we stop those asynchronous slaves The plan Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 116 / 191
  • 117. 8) We attach the mysql2 slave to the group The plan Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 117 / 191
  • 118. 9) Use MySQL Router for directing traffic The plan Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 118 / 191
  • 119. MySQL InnoDB Cluster from Labs is already installed on mysql3. Let's take a backup on mysql1: [mysql1~]#xtrabackup--backup --target-dir=/tmp/backup --user=root --password=X--host=127.0.0.1 [mysql1~]#xtrabackup--prepare --target-dir=/tmp/backup LAB2: Prepare mysql3 Asynchronous slave Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 119 / 191
  • 120. LAB2: Prepare mysql3 (2) Asynchronous slave Copy the backup from mysql1to mysql3: [mysql1~]#scp-r/tmp/backupmysql3:/tmp And restore it: [mysql3~]#xtrabackup--copy-back--target-dir=/tmp/backup [mysql3~]#chown-Rmysql./var/lib/mysql Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 120 / 191
  • 121. LAB3: mysql3 as asynchronous slave (2) Asynchronous slave Configure /etc/my.cnf: [mysqld] ... server_id=3 enforce_gtid_consistency=on gtid_mode =on log_bin log_slave_updates Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 121 / 191
  • 122. LAB2: Prepare mysql3 (3) Asynchronous slave Let's start MySQL on mysql3: [mysql3~]#systemctlstartmysqld Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 122 / 191
  • 123. find the GTIDs purged change MASTER set the purged GTIDs start replication LAB3: mysql3 as asynchronous slave (1)   Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 123 / 191
  • 124. LAB3: mysql3 as asynchronous slave (2) Find the latest purged GTIDs: [mysql3~]#cat/tmp/backup/xtrabackup_binlog_info mysql-bin.000002 167646328 b346474c-8601-11e6-9b39-08002718d305:1-771 Connect to mysql3and setup replication: mysql>CHANGEMASTERTOMASTER_HOST="mysql1", MASTER_USER="repl_async",MASTER_PASSWORD='Xslave', MASTER_AUTO_POSITION=1; mysql>RESETMASTER; mysql>SETglobalgtid_purged="VALUEFOUNDPREVIOUSLY"; mysql>STARTSLAVE; Check that you receive the application's traffic Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 124 / 191
  • 125. LAB4: MySQL InnoDB Cluster Create a single instance cluster Time to use the new MySQL Shell ! [mysql3~]#mysqlsh Let's verify if our server is ready to become a member of a new cluster: mysql-js>dba.validateInstance('root@mysql3:3306') Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 125 / 191
  • 126. LAB4: configuration settings (2) mysql3's my.cnf Configure /etc/my.cnf: [mysqld] ... server_id=3 enforce_gtid_consistency=on gtid_mode =on log_bin log_slave_updates binlog_checksum=none master_info_repository=TABLE relay_log_info_repository=TABLE transaction_write_set_extraction=XXHASH64 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 126 / 191
  • 127. LAB4: configuration settings (2) mysql3's my.cnf Configure /etc/my.cnf: [mysqld] ... server_id=3 enforce_gtid_consistency=on gtid_mode =on log_bin log_slave_updates binlog_checksum=none master_info_repository=TABLE relay_log_info_repository=TABLE transaction_write_set_extraction=XXHASH64 [mysql3~]#systemctlrestartmysqld Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 127 / 191
  • 128. LAB4: MySQL InnoDB Cluster (3) Create a single instance cluster [mysql3~]#mysqlsh Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 128 / 191
  • 129. LAB4: MySQL InnoDB Cluster (3) Create a single instance cluster [mysql3~]#mysqlsh mysql-js>dba.validateInstance('root@mysql3:3306') mysql-js>croot@mysql3:3306 mysql-js>cluster=dba.createCluster('plam') The KEY is the only credential we need to remember to manage our cluster. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 129 / 191
  • 130. LAB4: MySQL InnoDB Cluster (3) Create a single instance cluster [mysql3~]#mysqlsh mysql-js>dba.validateInstance('root@mysql3:3306') mysql-js>croot@mysql3:3306 mysql-js>cluster=dba.createCluster('plam') The KEY is the only credential we need to remember to manage our cluster. mysql-js>cluster.status() Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 130 / 191
  • 132. Add mysql4to the Group: restore the backup set the purged GTIDs use MySQL shell LAB5: add mysql4 to the cluster (1)   Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 132 / 191
  • 133. LAB5: add mysql4 to the cluster (2) Copy the backup from mysql1to mysql4: [mysql1~]#scp-r/tmp/backupmysql4:/tmp And restore it: [mysql4~]#xtrabackup--copy-back--target-dir=/tmp/backup [mysql4~]#chown-Rmysql./var/lib/mysql Start MySQL on mysql4: [mysql4~]#systemctlstartmysqld Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 133 / 191
  • 134. LAB5: MySQL shell to add an instance (3) [mysql4~]#mysqlsh Let's verify the config: mysql-js>dba.validateInstance('root@mysql4:3306') Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 134 / 191
  • 135. LAB5: MySQL shell to add an instance (4) Configure /etc/my.cnf: [mysqld] ... server_id=4 enforce_gtid_consistency=on gtid_mode =on log_bin log_slave_updates binlog_checksum=none master_info_repository=TABLE relay_log_info_repository=TABLE transaction_write_set_extraction=XXHASH64 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 135 / 191
  • 136. LAB5: MySQL shell to add an instance (4) Configure /etc/my.cnf: [mysqld] ... server_id=4 enforce_gtid_consistency=on gtid_mode =on log_bin log_slave_updates binlog_checksum=none master_info_repository=TABLE relay_log_info_repository=TABLE transaction_write_set_extraction=XXHASH64 [mysql4~]#systemctlrestartmysqld Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 136 / 191
  • 137. LAB5: MySQL InnoDB Cluster (4) Group of 2 instances Find the latest purged GTIDs: [mysql4~]#cat/tmp/backup/xtrabackup_binlog_info mysql-bin.000002 167646328 b346474c-8601-11e6-9b39-08002718d305:1-77177 Connect to mysql4and set GTID_PURGED [mysql4~]#mysqlsh mysql-js>croot@mysql4:3306 mysql-js>sql mysql-sql>RESETMASTER; mysql-sql>SETglobalgtid_purged="VALUEFOUNDPREVIOUSLY"; Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 137 / 191
  • 138. LAB5: MySQL InnoDB Cluster (5) mysql-sql>js mysql-js>dba.validateInstance('root@mysql4:3306') mysql-js>croot@mysql3:3306 mysql-js>cluster=dba.getCluster('plam') mysql-js>cluster.addInstance("root@mysql4:3306") mysql-js>cluster.status() Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 138 / 191
  • 140. Recovering progress On standard MySQL, monitor the group_replication_recoverychannel to see the progress: mysql>showslavestatusforchannel'group_replication_recovery'G ***************************1.row*************************** Slave_IO_State:Waitingformastertosendevent Master_Host:mysql3 Master_User:mysql_innodb_cluster_rpl_user ... Slave_IO_Running:Yes Slave_SQL_Running:Yes ... Retrieved_Gtid_Set:6e7d7848-860f-11e6-92e4-08002718d305:1-6, 7c1f0c2d-860d-11e6-9df7-08002718d305:1-15, b346474c-8601-11e6-9b39-08002718d305:1964-77177, e8c524df-860d-11e6-9df7-08002718d305:1-2 Executed_Gtid_Set:7c1f0c2d-860d-11e6-9df7-08002718d305:1-7, b346474c-8601-11e6-9b39-08002718d305:1-45408, e8c524df-860d-11e6-9df7-08002718d305:1-2 ... Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 140 / 191
  • 141. point the application to the cluster Migrate the application Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 141 / 191
  • 142. LAB6: Migrate the application Now we need to point the application to mysql3, this is the only downtime ! ... [ 21257s]threads:4,tps:12.00,reads:167.94,writes:47.98,responsetime:18 [ 21258s]threads:4,tps:6.00, reads:83.96,writes: 23.99,responsetime:14 [ 21259s]threads:4,tps:7.00, reads:98.05,writes: 28.01,responsetime:16 [ 31250s]threads:4,tps:8.00, reads:111.95,writes:31.99,responsetime:30 [ 31251s]threads:4,tps:11.00,reads:154.01,writes:44.00,responsetime:13 [ 31252s]threads:4,tps:11.00,reads:153.94,writes:43.98,responsetime:12 [ 31253s]threads:4,tps:10.01,reads:140.07,writes:40.02,responsetime:17 ^C [mysql1~]#run_app.shmysql3 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 142 / 191
  • 143. LAB6: Migrate the application Make sure replication is running properly on mysql2and mysql3. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 143 / 191
  • 144. LAB6: Migrate the application Make sure replication is running properly on mysql2and mysql3. **************************1.row*************************** ... Master_Host:mysql1 Slave_IO_Running:Yes Slave_SQL_Running:No ... Last_SQL_Errno:3100 Last_SQL_Error:ErrorinXid_log_event:Commitcouldnotbecompleted, 'Erroronobserverwhilerunningreplicationhook'before_commit'.' Replicate_Ignore_Server_Ids: Master_Server_Id:1 Master_UUID:8fbcd944-8760-11e6-9b4e-08002718d305 ... Last_SQL_Error_Timestamp:16093023:04:07 Retrieved_Gtid_Set:8fbcd944-8760-11e6-9b4e-08002718d305:360-3704 Executed_Gtid_Set:0b31b4f3-8762-11e6-bb35-08002718d305:1-7, 30212757-8762-11e6-ad73-08002718d305:1-2, 8fbcd944-8760-11e6-9b4e-08002718d305:1-2652 Auto_Position:1 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 144 / 191
  • 145. LAB6: Migrate the application Fix replication if necessary: mysql3>startslave; mysql3>showslavestatus; Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 145 / 191
  • 146. LAB6: Migrate the application Fix replication if necessary: mysql3>startslave; mysql3>showslavestatus; Stop asynchronous replication on mysql2and mysql3: mysql2>stopslave; mysql3>stopslave; Make sure gtid_executedrange on mysql2is lower or equal than on mysql3 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 146 / 191
  • 147. LAB6: Migrate the application Fix replication if necessary: mysql3>startslave; mysql3>showslavestatus; Stop asynchronous replication on mysql2and mysql3: mysql2>stopslave; mysql3>stopslave; Make sure gtid_executedrange on mysql2is lower or equal than on mysql3 mysql2>setglobalsuper_read_only=off;#http://bugs.mysql.com/bug.php?id=83234 mysql2>resetslaveall; mysql3>resetslaveall; Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 147 / 191
  • 148. previous slave (mysql2) can now be part of the cluster Add a third instance Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 148 / 191
  • 149. LAB7: Add mysql2 to the group We first validate the instance using MySQL shell and we modify the configuration. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 149 / 191
  • 150. LAB7: Add mysql2 to the group We first validate the instance using MySQL shell and we modify the configuration. [mysqld] ... super_read_only=0 server_id=2 binlog_checksum=none enforce_gtid_consistency=on gtid_mode =on log_bin log_slave_updates master_info_repository=TABLE relay_log_info_repository=TABLE transaction_write_set_extraction=XXHASH64 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 150 / 191
  • 151. LAB7: Add mysql2 to the group We first validate the instance using MySQL shell and we modify the configuration. [mysqld] ... super_read_only=0 server_id=2 binlog_checksum=none enforce_gtid_consistency=on gtid_mode =on log_bin log_slave_updates master_info_repository=TABLE relay_log_info_repository=TABLE transaction_write_set_extraction=XXHASH64 [mysql2~]#systemctlrestartmysqld Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 151 / 191
  • 152. LAB7: Add mysql2 to the group (2) Back in MySQL shell we add the new instance: [mysql2~]#mysqlsh Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 152 / 191
  • 153. LAB7: Add mysql2 to the group (2) Back in MySQL shell we add the new instance: [mysql2~]#mysqlsh mysql-js>dba.validateInstance('root@mysql2:3306') mysql-js>croot@mysql3:3306 mysql-js>cluster=dba.getCluster('plam') mysql-js>cluster.addInstance("root@mysql2:3306") mysql-js>cluster.status() Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 153 / 191
  • 154. LAB7: Add mysql2 to the group (3) { "clusterName":"plam", "defaultReplicaSet":{ "status":"ClustertoleranttouptoONEfailure.", "topology":{ "mysql3:3306":{ "address":"mysql3:3306", "status":"ONLINE", "role":"HA", "mode":"R/W", "leaves":{ "mysql4:3306":{ "address":"mysql4:3306", "status":"ONLINE", "role":"HA", "mode":"R/O", "leaves":{} }, "mysql2:3306":{ "address":"mysql2:3306", "status":"ONLINE", "role":"HA", "mode":"R/O", "leaves":{} } } Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 154 / 191
  • 156. writing to a single server Single Primary Mode Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 156 / 191
  • 157. Default = Single Primary Mode By default, MySQL InnoDB Cluster enables SinglePrimaryMode. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 157 / 191
  • 158. Default = Single Primary Mode By default, MySQL InnoDB Cluster enables SinglePrimaryMode. mysql>showglobalvariableslike'group_replication_single_primary_mode'; +---------------------------------------+-------+ |Variable_name |Value| +---------------------------------------+-------+ |group_replication_single_primary_mode|ON | +---------------------------------------+-------+ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 158 / 191
  • 159. Default = Single Primary Mode By default, MySQL InnoDB Cluster enables SinglePrimaryMode. mysql>showglobalvariableslike'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 @ 2016 Oracle and/or its affiliates. All rights reserved. 159 / 191
  • 160. Who's the Primary Master ? As the Primary Master is elected, all nodes part of the group knows which one was elected. This value is exposed in status variables: Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 160 / 191
  • 161. Who's the Primary Master ? As the Primary Master is elected, all nodes part of the group knows which one was elected. This value is exposed in status variables: mysql>showstatuslike'group_replication_primary_member'; +----------------------------------+--------------------------------------+ |Variable_name |Value | +----------------------------------+--------------------------------------+ |group_replication_primary_member|28a4e51f-860e-11e6-bdc4-08002718d305| +----------------------------------+--------------------------------------+ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 161 / 191
  • 162. Who's the Primary Master ? As the Primary Master is elected, all nodes part of the group knows which one was elected. This value is exposed in status variables: mysql>showstatuslike'group_replication_primary_member'; +----------------------------------+--------------------------------------+ |Variable_name |Value | +----------------------------------+--------------------------------------+ |group_replication_primary_member|28a4e51f-860e-11e6-bdc4-08002718d305| +----------------------------------+--------------------------------------+ mysql>selectmember_hostas"primarymaster" fromperformance_schema.global_status join performance_schema.replication_group_members wherevariable_name='group_replication_primary_member' andmember_id=variable_value; +---------------+ |primarymaster| +---------------+ |mysql3 | +---------------+ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 162 / 191
  • 163. get more info Monitoring Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 163 / 191
  • 164. Performance Schema Group Replication uses Performance_Schemato expose status mysql3>SELECT*FROMperformance_schema.replication_group_membersG ***************************1.row*************************** CHANNEL_NAME:group_replication_applier MEMBER_ID:00db47c7-3e23-11e6-afd4-08002774c31b MEMBER_HOST:mysql3.localdomain MEMBER_PORT:3306 MEMBER_STATE:ONLINE Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 164 / 191
  • 165. Performance Schema Group Replication uses Performance_Schemato expose status mysql3>SELECT*FROMperformance_schema.replication_group_membersG ***************************1.row*************************** CHANNEL_NAME:group_replication_applier MEMBER_ID:00db47c7-3e23-11e6-afd4-08002774c31b MEMBER_HOST:mysql3.localdomain MEMBER_PORT:3306 MEMBER_STATE:ONLINE mysql3>SELECT*FROMperformance_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-0000:00:00 RECEIVED_TRANSACTION_SET:afb80f36-2bff-11e6-84e0-0800277dd3bf:1-2 LAST_ERROR_NUMBER:0 LAST_ERROR_MESSAGE: LAST_ERROR_TIMESTAMP:0000-00-0000:00:00Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 165 / 191
  • 166. Member State These are the different possible state for a node member: ONLINE OFFLINE RECOVERING ERROR: when a node is leaving but the plugin was not instructed to stop UNREACHABLE Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 166 / 191
  • 167. Status information & metrics Members mysql> SELECT*FROMperformance_schema.replication_group_membersG Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 167 / 191
  • 168. Status information & metrics Members mysql> SELECT*FROMperformance_schema.replication_group_membersG ***************************1.row*************************** CHANNEL_NAME:group_replication_applier MEMBER_ID:00db47c7-3e23-11e6-afd4-08002774c31b MEMBER_HOST:mysql3.localdomain MEMBER_PORT:3306 MEMBER_STATE:ONLINE ***************************2.row*************************** CHANNEL_NAME:group_replication_applier MEMBER_ID:e1544c9d-4451-11e6-9f5a-08002774c31b MEMBER_HOST:mysql4.localdomain.localdomain MEMBER_PORT:3306 MEMBER_STATE:ONLINE Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 168 / 191
  • 169. Status information & metrics Connections mysql>SELECT*FROMperformance_schema.replication_connection_statusG Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 169 / 191
  • 170. Status information & metrics Connections mysql>SELECT*FROMperformance_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-0000:00:00 RECEIVED_TRANSACTION_SET:5de4400b-3dd7-11e6-8a71-08002774c31b:1-814089, afb80f36-2bff-11e6-84e0-0800277dd3bf:1-2834 LAST_ERROR_NUMBER:0 LAST_ERROR_MESSAGE: LAST_ERROR_TIMESTAMP:0000-00-0000:00:00 ***************************2.row*************************** CHANNEL_NAME:group_replication_recovery GROUP_NAME: SOURCE_UUID: THREAD_ID:NULL SERVICE_STATE:OFF Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 170 / 191
  • 171. Status information & metrics Local node status mysql>select*fromperformance_schema.replication_group_member_statsG Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 171 / 191
  • 172. Status information & metrics Local node status mysql>select*fromperformance_schema.replication_group_member_statsG ***************************1.row*************************** CHANNEL_NAME:group_replication_applier VIEW_ID:14679667214442885:4 MEMBER_ID:e1544c9d-4451-11e6-9f5a-08002774c31b COUNT_TRANSACTIONS_IN_QUEUE:0 COUNT_TRANSACTIONS_CHECKED:5961 COUNT_CONFLICTS_DETECTED:0 COUNT_TRANSACTIONS_ROWS_VALIDATING:0 TRANSACTIONS_COMMITTED_ALL_MEMBERS:5de4400b-3dd7-11e6-8a71-08002774c31b:1-814089, afb80f36-2bff-11e6-84e0-0800277dd3bf:1-5718 LAST_CONFLICT_FREE_TRANSACTION:afb80f36-2bff-11e6-84e0-0800277dd3bf:5718 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 172 / 191
  • 173. Performance_Schema You can find GR information in the following Performance_Schema tables: replication_applier_con guration replication_applier_status replication_applier_status_by_worker replication_connection_con guration replication_connection_status replication_group_member_stats replication_group_members Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 173 / 191
  • 174. Status during recovery mysql>SHOWSLAVESTATUSFORCHANNEL'group_replication_recovery'G Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 174 / 191
  • 176. Sys Schema The easiest way to detect if a node is a member of the primary component (when there are partitioning of your nodes due to network issues for example) and therefore a valid candidate for routing queries to it, is to use the sys table. Additional information for syscan be downloaded at https://github.com/lefred/mysql_gr_routing_check/blob/master/addition_to_sys.sql On the primary node: [mysql3~]#mysql</tmp/gr_addition_to_sys.sql Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 176 / 191
  • 177. Sys Schema Is this node part of PRIMARY Partition: mysql3>SELECTsys.gr_member_in_primary_partition(); +------------------------------------+ |sys.gr_node_in_primary_partition()| +------------------------------------+ |YES | +------------------------------------+ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 177 / 191
  • 178. Sys Schema Is this node part of PRIMARY Partition: mysql3>SELECTsys.gr_member_in_primary_partition(); +------------------------------------+ |sys.gr_node_in_primary_partition()| +------------------------------------+ |YES | +------------------------------------+ To use as healthcheck: mysql3>SELECT*FROMsys.gr_member_routing_candidate_status; +------------------+-----------+---------------------+----------------------+ |viable_candidate|read_only|transactions_behind|transactions_to_cert| +------------------+-----------+---------------------+----------------------+ |YES |YES |0 |0 | +------------------+-----------+---------------------+----------------------+ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 178 / 191
  • 179. Sys Schema - Heath Check On one of the non Primary nodes, run the following command: mysql-sql> ushtableswithreadlock; Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 179 / 191
  • 180. Sys Schema - Heath Check On one of the non Primary nodes, run the following command: mysql-sql> ushtableswithreadlock; Now you can verify what the healthcheck exposes to you: mysql-sql>SELECT*FROMsys.gr_member_routing_candidate_status; +------------------+-----------+---------------------+----------------------+ |viable_candidate|read_only|transactions_behind|transactions_to_cert| +------------------+-----------+---------------------+----------------------+ |YES |YES | 950| 0| +------------------+-----------+---------------------+----------------------+ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 180 / 191
  • 181. Sys Schema - Heath Check On one of the non Primary nodes, run the following command: mysql-sql> ushtableswithreadlock; Now you can verify what the healthcheck exposes to you: mysql-sql>SELECT*FROMsys.gr_member_routing_candidate_status; +------------------+-----------+---------------------+----------------------+ |viable_candidate|read_only|transactions_behind|transactions_to_cert| +------------------+-----------+---------------------+----------------------+ |YES |YES | 950| 0| +------------------+-----------+---------------------+----------------------+ mysql-sql>UNLOCKtables; Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 181 / 191
  • 182. application interaction MySQL Router Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 182 / 191
  • 183. MySQL Router We will now use mysqlrouterbetween our application and the cluster. Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 183 / 191
  • 184. MySQL Router (2) Configure MySQL Router (bootstrap it using an instance): [mysql2~]# mysqlrouter--bootstrapmysql2:3306 PleaseentertheadministrativeMASTERkeyfortheMySQLInnoDBcluster: MySQLRouterhasnowbeencon guredfortheInnoDBcluster'plam'. Thefollowingconnectioninformationcanbeusedtoconnecttothecluster. ClassicMySQLprotocolconnectionstocluster'plam': -Read/WriteConnections:localhost:6446 -Read/OnlyConnections:localhost:6447 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 184 / 191
  • 185. MySQL Router (3) Now let's copy the configuration to mysql1(our app server) and modify it to listen to port 3306: [mysql2~]#scp/etc/mysqlrouter/mysqlrouter.confmysql1:/etc/mysqlrouter/ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 185 / 191
  • 186. MySQL Router (3) Now let's copy the configuration to mysql1(our app server) and modify it to listen to port 3306: [mysql2~]#scp/etc/mysqlrouter/mysqlrouter.confmysql1:/etc/mysqlrouter/ [routing:default_rw] -bind_port=6446 +bind_port=3306 +bind_address=mysql1 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 186 / 191
  • 187. MySQL Router (3) Now let's copy the configuration to mysql1(our app server) and modify it to listen to port 3306: [mysql2~]#scp/etc/mysqlrouter/mysqlrouter.confmysql1:/etc/mysqlrouter/ [routing:default_rw] -bind_port=6446 +bind_port=3306 +bind_address=mysql1 We can stop mysqldon mysql1and start mysqlrouterinto a screen session: [mysql1~]#systemctlstopmysqld [mysql1~]#mysqlrouter Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 187 / 191
  • 188. MySQL Router (4) Now we can point the application to the router: [mysql1~]#run_app.shmysql1 Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 188 / 191
  • 189. MySQL Router (4) Now we can point the application to the router: [mysql1~]#run_app.shmysql1 Check app and kill mysqldon mysql3 (the Primary Master R/W node) ! [mysql3~]#kill-9$(pidofmysqld) Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 189 / 191
  • 190. MySQL Router (4) Now we can point the application to the router: [mysql1~]#run_app.shmysql1 Check app and kill mysqldon mysql3 (the Primary Master R/W node) ! [mysql3~]#kill-9$(pidofmysqld) mysql>selectmember_hostas"primary"fromperformance_schema.global_status join performance_schema.replication_group_members wherevariable_name='group_replication_primary_member' andmember_id=variable_value; +---------+ |primary| +---------+ |mysql4 | +---------+ Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 190 / 191
  • 191. Thank you ! Questions ? Copyright @ 2016 Oracle and/or its affiliates. All rights reserved. 191 / 191