SlideShare ist ein Scribd-Unternehmen logo
1 von 145
Downloaden Sie, um offline zu lesen
1 / 145
2 / 145
MySQL InnoDB Cluster in a Nutshell
Hands-On Tutorial
Percona Live Europe - Frankfurt 2018
Frédéric Descamps - MySQL Community Manager - Oracle
Kenny Gryp - ■■■■■ ■■■■■■■ ■■■■■■■ - ■■■■■■
3 / 145
 
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 @ 2018 Oracle and/or its affiliates. All rights reserved.
4 / 145
Who are we ?
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
5 / 145
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
6 / 145
Frédéric Descamps
@lefred
MySQL Evangelist
Managing MySQL since 3.23
devops believer
http://about.me/lefred
 
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
7 / 145
Kenny Gryp
@gryp
Houseman
Aspiring electrician
 
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
8 / 145
how will the session proceed?
Agenda
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
9 / 145
Agenda
Prepare your workstation
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
10 / 145
Agenda
Prepare your workstation
What are MySQL InnoDB Cluster & Group Replication ?
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
11 / 145
Agenda
Prepare your workstation
What are MySQL InnoDB Cluster & Group Replication ?
Migration from Master-Slave to GR
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
12 / 145
Agenda
Prepare your workstation
What are MySQL InnoDB Cluster & Group Replication ?
Migration from Master-Slave to GR
How to monitor ?
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
13 / 145
Agenda
Prepare your workstation
What are MySQL InnoDB Cluster & Group Replication ?
Migration from Master-Slave to GR
How to monitor ?
Application interaction
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
14 / 145
VirtualBox
Setup your workstation
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
15 / 145
Setup your workstation
Install VirtualBox 5.2
On the USB key, copy PLEU_18_GR.ova on your laptop and doubleclick on it
Ensure you have vboxnet0 network interface
Older VirtualBox: VirtualBox Pref. -> Network -> Host-Only Networks -> +
New VirtualBox: Global Tools -> Host Network Manager -> +
Start all virtual machines (mysql1, mysql2, mysql3 & mysql4)
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
16 / 145
Setup your workstation
Install VirtualBox 5.2
On the USB key, copy PLEU_18_GR.ova on your laptop and doubleclick on it
Ensure you have vboxnet0 network interface
Older VirtualBox: VirtualBox Pref. -> Network -> Host-Only Networks -> +
New VirtualBox: Global Tools -> Host Network Manager -> +
Start all virtual machines (mysql1, mysql2, mysql3 & mysql4)
Try to connect to all VM´s from your terminal or putty (root password is X) :
ssh -p 8821 root@127.0.0.1 mysql1
ssh -p 8822 root@127.0.0.1 mysql2
ssh -p 8823 root@127.0.0.1 mysql3
ssh -p 8824 root@127.0.0.1 mysql4
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
17 / 145
LAB1: Current situation
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
18 / 145
all running database
servers (mysql1 &
mysql2) are using
MySQL 5.7.24
LAB1: Current situation
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
19 / 145
launch
run_app.sh
on mysql1 into
a screen
session
verify that
mysql2 is a
running slave
LAB1: Current situation
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
20 / 145
Summary
 
+--------+----------+--------------+----------------+
| | ROLE | SSH PORT | INTERNAL IP |
+--------+----------+--------------+----------------+
| | | | |
| mysql1 | master | 8821 | 192.168.91.11 |
| | | | |
| mysql2 | slave | 8822 | 192.168.91.12 |
| | | | |
| mysql3 | n/a | 8823 | 192.168.91.13 |
| | | | |
| mysql4 | n/a | 8824 | 192.168.91.14 |
| | | | |
+--------+----------+--------------++---------------+
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
21 / 145
Summary
 
+--------+----------+--------------+----------------+
| | ROLE | SSH PORT | INTERNAL IP |
+--------+----------+--------------+----------------+
| | | | |
| mysql1 | master | 8821 | 192.168.91.11 |
| | | | |
| mysql2 | slave | 8822 | 192.168.91.12 |
| | | | |
| mysql3 | n/a | 8823 | 192.168.91.13 |
| | | | |
| mysql4 | n/a | 8824 | 192.168.91.14 |
| | | | |
+--------+----------+--------------++---------------+
write this down somewhere !
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
22 / 145
Easy High Availability
MySQL InnoDB Cluster
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
23 / 145
InnoDB
cluster
Ease-of-Use
Extreme Scale-Out
Out-of-Box Solution
Built-in HA
High Performance
Everything Integrated
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
24 / 145
InnoDB Cluster's Architecture
Application
MySQL Connector
MySQL Router
MySQL Shell
InnoDB
cluster
Application
MySQL Connector
MySQL Router
Mp
M
M
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
25 / 145
Group Replication: heart of MySQL InnoDB
Cluster
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
26 / 145
Group Replication: heart of MySQL InnoDB
Cluster
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
27 / 145
MySQL Group Replication
but what is it ?!?
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
28 / 145
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
29 / 145
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
30 / 145
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
Paxos based protocol
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
31 / 145
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
Paxos based protocol
GR allows to write on all Group Members (cluster nodes) simultaneously while
retaining consistency
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
32 / 145
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
Paxos based protocol
GR allows to write on all Group Members (cluster nodes) simultaneously while
retaining consistency
GR implements conflict detection and resolution
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
33 / 145
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
Paxos based protocol
GR allows to write on all Group Members (cluster nodes) simultaneously while
retaining consistency
GR implements conflict detection and resolution
GR allows automatic distributed recovery
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
34 / 145
MySQL Group Replication
but what is it ?!?
GR is a plugin for MySQL, made by MySQL and packaged with MySQL
GR is an implementation of Replicated Database State Machine theory
Paxos based protocol
GR allows to write on all Group Members (cluster nodes) simultaneously while
retaining consistency
GR implements conflict detection and resolution
GR allows automatic distributed recovery
Supported on all MySQL platforms !!
Linux, Windows, Solaris, OSX, FreeBSD
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
35 / 145
And for users ?
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
36 / 145
And for users ?
not longer necessary to handle server fail-over manually or with a complicated script
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
37 / 145
And for users ?
not longer necessary to handle server fail-over manually or with a complicated script
GR provides fault tolerance
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
38 / 145
And for users ?
not longer necessary to handle server fail-over manually or with a complicated script
GR provides fault tolerance
GR enables update-everywhere setups
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
39 / 145
And for users ?
not longer necessary to handle server fail-over manually or with a complicated script
GR provides fault tolerance
GR enables update-everywhere setups
GR handles crashes, failures, re-connects automatically
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
40 / 145
And for users ?
not longer necessary to handle server fail-over manually or with a complicated script
GR provides fault tolerance
GR enables update-everywhere setups
GR handles crashes, failures, re-connects automatically
Allows an easy setup of a highly available MySQL service!
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
41 / 145
ready ?
Migration from Master-Slave to GR
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
42 / 145
The plan
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
43 / 145
These are the 10
steps for the
migration:
1) We install and
setup MySQL InnoDB
Cluster on one of the
new servers
The plan
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
44 / 145
2) we restore a
backup
3) we update to
MySQL 8.0
4) setup
asynchronous
replication on the new
server.
The plan
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
45 / 145
5) we add a new
instance to our group
The plan
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
46 / 145
6) we point the
application to one of
our new nodes.
7) we wait and check
that asynchronous
replication is caught
up
8) we stop those
asynchronous slaves
The plan
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
47 / 145
9) we upgrade and
attach mysql2
(previous slave) to
the group
The plan
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
48 / 145
10) use MySQL Router
for directing traffic
The plan
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
49 / 145
LAB2: Verify if your environment can be
upgraded to MySQL 8.0
We will first create an admin account on mysql1 that we will use throughout the
tutorial:
mysql1> CREATE USER clusteradmin@'%' identi ed by 'mysql';
mysql1> GRANT ALL PRIVILEGES ON *.* TO clusteradmin@'%'
WITH GRANT OPTION;
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
50 / 145
LAB2: Verify if your environment can be
upgraded to MySQL 8.0
We will first create an admin account on mysql1 that we will use throughout the
tutorial:
mysql1> CREATE USER clusteradmin@'%' identi ed by 'mysql';
mysql1> GRANT ALL PRIVILEGES ON *.* TO clusteradmin@'%'
WITH GRANT OPTION;
Now, we use MySQL Shell to check if the settings on mysql1 can be upgraded to MySQL
8.0 without problem:
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
51 / 145
LAB2: Verify if your environment can be
upgraded to MySQL 8.0
We will first create an admin account on mysql1 that we will use throughout the
tutorial:
mysql1> CREATE USER clusteradmin@'%' identi ed by 'mysql';
mysql1> GRANT ALL PRIVILEGES ON *.* TO clusteradmin@'%'
WITH GRANT OPTION;
Now, we use MySQL Shell to check if the settings on mysql1 can be upgraded to MySQL
8.0 without problem:
# mysqlsh -- util check-for-server-upgrade clusteradmin@mysql1
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
52 / 145
LAB2: Beautiful MySQL Shell
You can setup a better shell environment :
# mysqlsh
mysql-js> shell.options['history.autoSave']=true
# cp /usr/share/mysqlsh/prompt/prompt_256pl+aw.json ~/.mysqlsh/prompt.json
# mysqlsh clusteradmin@mysql2
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
53 / 145
MySQL 8.0.13 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
54 / 145
LAB2: Prepare mysql3 (2)
Asynchronous slave
Copy the backup from mysql1 to mysql3:
[mysql1 ~]# scp -r /tmp/backup mysql3:/tmp
And restore it:
[mysql3 ~]# xtrabackup --copy-back --target-dir=/tmp/backup
[mysql3 ~]# chown -R mysql. /var/lib/mysql
55 / 145
LAB2: Prepare mysql3 (3)
Asynchronous slave
Let´s start MySQL on mysql3:
[mysql3 ~]# systemctl start mysqld
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
56 / 145
LAB2: Prepare mysql3 (3)
Asynchronous slave
Let´s start MySQL on mysql3:
[mysql3 ~]# systemctl start mysqld
[mysql3 ~]# mysql_upgrade
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
57 / 145
LAB2: Prepare mysql3 (3)
Asynchronous slave
Let´s start MySQL on mysql3:
[mysql3 ~]# systemctl start mysqld
[mysql3 ~]# mysql_upgrade
And restart mysqld as recommended after having run mysql_upgrade:
[mysql3 ~]# systemctl restart mysqld
or
# mysqlsh clusteradmin@mysql3 --sql -e "restart"
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
58 / 145
find the GTIDs purged
change MASTER
set the purged GTIDs
start replication
LAB3: mysql3 as asynchronous slave (1)
 
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
59 / 145
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 mysql3 and setup replication:
mysql> CHANGE MASTER TO MASTER_HOST="mysql1",
MASTER_USER="repl", MASTER_PASSWORD='X',
MASTER_AUTO_POSITION=1;
mysql> RESET MASTER;
mysql> SET global gtid_purged="VALUE FOUND PREVIOUSLY";
mysql> START SLAVE;
Check that you receive the application´s traffic
60 / 145
Administration made easy and more...
MySQL InnoDB Cluster
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
61 / 145
LAB4: MySQL InnoDB Cluster
Create a single instance cluster (mysql3)
# mysqlsh
Let´s verify if our server is ready to become a member of a new cluster:
mysql-js> dba.checkInstanceCon guration('clusteradmin@mysql3')
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
62 / 145
LAB4: MySQL InnoDB Cluster
Create a single instance cluster (mysql3)
# mysqlsh
Let´s verify if our server is ready to become a member of a new cluster:
mysql-js> dba.checkInstanceCon guration('clusteradmin@mysql3')
Change the configuration !
mysql-js> dba.con gureInstance('clusteradmin@mysql3')
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
63 / 145
LAB4: MySQL InnoDB Cluster (2)
Wait just a bit if a restart is required ()which is not the case here) and create a single
instance cluster
mysql-js> dba.checkInstanceCon guration('clusteradmin@mysql3')
mysql-js> c clusteradmin@mysql3:3306
mysql-js> cluster = dba.createCluster('perconalive')
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
64 / 145
LAB4: Cluster Status
mysql-js> cluster.status()
{
"clusterName": "perconalive",
"defaultReplicaSet": {
"name": "default",
"primary": "mysql3:3306",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"mysql3:3306": {
"address": "mysql3:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
}
}
},
"groupInformationSourceMember": "mysql://clusteradmin@mysql3:3306"
}
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
65 / 145
Add mysql4 to the Group:
restore the backup
set the purged GTIDs
use MySQL Shell
LAB5: add mysql4 to the cluster (1)
 
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
66 / 145
LAB5: add mysql4 to the cluster (2)
Copy the backup from mysql1 to mysql4:
[mysql1 ~]# scp -r /tmp/backup mysql4:/tmp
And restore it:
[mysql4 ~]# xtrabackup --copy-back --target-dir=/tmp/backup
[mysql4 ~]# chown -R mysql. /var/lib/mysql
Start MySQL on mysql4:
[mysql4 ~]# systemctl start mysqld
[mysql4 ~]# mysql_upgrade
[mysql4 ~]# mysqlsh clusteradmin@mysql4 --sql -e "restart"
67 / 145
LAB5: MySQL InnoDB Cluster (3)
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 mysql4 and set GTID_PURGED
[mysql4 ~]# mysqlsh
mysql-js> c clusteradmin@mysql4
mysql-js> sql
mysql-sql> SET global gtid_purged="VALUE FOUND PREVIOUSLY";
68 / 145
LAB5: MySQL Shell to add an instance (4)
Let´s add mysql4 (check configuration, check instance and add to cluster all in one
command that can be done from the opened shell in mysql3):
mysql-js> dba.con gureInstance('clusteradmin@mysql4')
mysql-js> cluster.addInstance('clusteradmin@mysql4')
mysql-js> cluster.status()
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
69 / 145
LAB5: MySQL Shell to add an instance (4)
Let´s add mysql4 (check configuration, check instance and add to cluster all in one
command that can be done from the opened shell in mysql3):
mysql-js> dba.con gureInstance('clusteradmin@mysql4')
mysql-js> cluster.addInstance('clusteradmin@mysql4')
mysql-js> cluster.status()
As no restart is required some missing privileges (not in available 5.7) are not necessary,
but in case you need them those are the missing grant:
mysql-sql> GRANT SYSTEM_VARIABLES_ADMIN, PERSIST_RO_VARIABLES_ADMIN
ON *.* TO 'clusteradmin'@'%';
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
70 / 145
Cluster Status
mysql-js> cluster.status()
{
"clusterName": "perconalive",
"defaultReplicaSet": {
"name": "default",
"primary": "mysql3:3306",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures. 1 member is not a
"topology": {
"mysql3:3306": {
"address": "mysql3:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"mysql4:3306": {
"address": "mysql4:3306",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "RECOVERING"
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
71 / 145
Recovering progress
On standard MySQL, monitor the group_replication_recovery channel to see
the progress:
mysql4> show slave status for channel 'group_replication_recovery'G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
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 @ 2018 Oracle and/or its affiliates. All rights reserved.
72 / 145
Cluster Status
{
"clusterName": "perconalive",
"defaultReplicaSet": {
"name": "default",
"primary": "mysql3:3306",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"mysql3:3306": {
"address": "mysql3:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"mysql4:3306": {
"address": "mysql4:3306",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
}
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
73 / 145
Asynchronous Replication
When a group is created, the asynchronous SQL Thread is stopped and needs to be
restarted.
Verify that replication from mysql1 is still running on mysql3, and restart the SQL
Thread:
mysql-sql> c clusteradmin@mysql3
mysql-sql> SHOW SLAVE STATUSG
mysql-sql> START SLAVE SQL_THREAD;
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
74 / 145
point the application
to the cluster
Migrate the application
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
75 / 145
LAB6: Migrate the application
Now we need to point the application to mysql3, this is the only downtime !
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
76 / 145
LAB6: Migrate the application
Now we need to point the application to mysql3, this is the only downtime !
Make sure the master and replica is in sync
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
77 / 145
LAB6: Migrate the application
Now we need to point the application to mysql3, this is the only downtime !
Make sure the master and replica is in sync
Start application, connecting to the Group Replication master (mysql3)
...
[ 21257s] threads: 4, tps: 12.00, reads: 167.94, writes: 47.98, response time: 1
[ 21258s] threads: 4, tps: 6.00, reads: 83.96, writes: 23.99, response time: 1
[ 21259s] threads: 4, tps: 7.00, reads: 98.05, writes: 28.01, response time: 1
[ 31250s] threads: 4, tps: 8.00, reads: 111.95, writes: 31.99, response time: 3
[ 31251s] threads: 4, tps: 11.00, reads: 154.01, writes: 44.00, response time: 1
[ 31252s] threads: 4, tps: 11.00, reads: 153.94, writes: 43.98, response time: 1
[ 31253s] threads: 4, tps: 10.01, reads: 140.07, writes: 40.02, response time: 1
^C
[mysql1 ~]# run_app.sh mysql3
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
78 / 145
LAB6: Migrate the application
Make sure gtid_executed range on mysql2 is lower or equal than on mysql3
mysql[2-3]> SHOW GLOBAL VARIABLES LIKE 'gtid_executed'G
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
79 / 145
LAB6: Migrate the application
Make sure gtid_executed range on mysql2 is lower or equal than on mysql3
mysql[2-3]> SHOW GLOBAL VARIABLES LIKE 'gtid_executed'G
When they are OK, stop asynchronous replication on mysql2 and mysql3:
mysql2> STOP SLAVE;
mysql3> STOP SLAVE;
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
80 / 145
LAB6: Migrate the application
Make sure gtid_executed range on mysql2 is lower or equal than on mysql3
mysql[2-3]> SHOW GLOBAL VARIABLES LIKE 'gtid_executed'G
When they are OK, stop asynchronous replication on mysql2 and mysql3:
mysql2> STOP SLAVE;
mysql3> STOP SLAVE;
Now they can forget about mysql1:
mysql[2-3]> RESET SLAVE ALL FOR CHANNEL '';
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
81 / 145
previous slave
(mysql2) can now
be part of the cluster
Add a third instance
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
82 / 145
LAB7: Add mysql2 to the group
We first upgrade to MySQL 8.0.13 :
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
83 / 145
LAB7: Add mysql2 to the group
We first upgrade to MySQL 8.0.13 :
[mysql2 ~]# systemctl stop mysqld
[mysql2 ~]# rpm -Uvh /root/rpms/*rpm --nodeps --force
[mysql2 ~]# systemctl start mysqld
[mysql2 ~]# mysql_upgrade
[mysql2 ~]# systemctl restart mysqld
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
84 / 145
LAB7: Add mysql2 to the group (2)
mysql-js> dba.con gureInstance('clusteradmin@mysql2')
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
85 / 145
LAB7: Add mysql2 to the group (2)
mysql-js> dba.con gureInstance('clusteradmin@mysql2')
In case you don't have the cluster object in your shell anymore, you can still retrieve
it:
mysql-js> c clusteradmin@mysql3
mysql-js> cluster = dba.getCluster()
Add mysql2 to the cluster:
mysql-js> cluster.checkInstanceState('clusteradmin@mysql2')
mysql-js> cluster.addInstance("clusteradmin@mysql2:3306")
mysql-js> cluster.status()
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
86 / 145
LAB7: Add mysql2 to the group (3)
{
"clusterName": "perconalive",
"defaultReplicaSet": {
"name": "default",
"primary": "mysql3:3306",
"ssl": "REQUIRED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
"mysql2:3306": {
"address": "mysql2:3306",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"mysql3:3306": {
"address": "mysql3:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"mysql4:3306": {
87 / 145
writing to a single server
Single Primary Mode
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
88 / 145
Default = Single Primary Mode
By default, MySQL InnoDB Cluster enables Single Primary Mode.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
89 / 145
Default = Single Primary Mode
By default, MySQL InnoDB Cluster enables Single Primary Mode.
mysql> show global variables like 'group_replication_single_primary_mode';
+---------------------------------------+-------+
| Variable_name | Value |
+---------------------------------------+-------+
| group_replication_single_primary_mode | ON |
+---------------------------------------+-------+
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
90 / 145
Default = Single Primary Mode
By default, MySQL InnoDB Cluster enables Single Primary Mode.
mysql> show global variables like 'group_replication_single_primary_mode';
+---------------------------------------+-------+
| Variable_name | Value |
+---------------------------------------+-------+
| group_replication_single_primary_mode | ON |
+---------------------------------------+-------+
In Single Primary Mode, a single member acts as the writable master (PRIMARY) and
the rest of the members act as hot-standbys (SECONDARY).
The group itself coordinates and configures itself automatically to determine which
member will act as the PRIMARY, through a leader election mechanism.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
91 / 145
Who´s the Primary Master ?
You can already see it in the output of cluster.status()
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
92 / 145
Who´s the Primary Master ?
You can already see it in the output of cluster.status()
But you can also check in performance_schema:
mysql> select member_host
from performance_schema.replication_group_members
where member_role='PRIMARY';
+-------------+
| member_host |
+-------------+
| mysql3 |
+-------------+
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
93 / 145
Create a Multi-Primary Cluster:
It´s also possible to create a Multi-Primary Cluster using the Shell:
mysql-js> cluster=dba.createCluster('perconalive',{multiMaster: true})
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
94 / 145
Create a Multi-Primary Cluster:
It´s also possible to create a Multi-Primary Cluster using the Shell:
mysql-js> cluster=dba.createCluster('perconalive',{multiMaster: true})
A new InnoDB cluster will be created on instance 'clusteradmin@mysql3:3306'.
The MySQL InnoDB cluster is going to be setup in advanced Multi-Master Mode.
Before continuing you have to con rm that you understand the requirements and
limitations of Multi-Master Mode. Please read the manual before proceeding.
I have read the MySQL InnoDB cluster manual and I understand the requirements
and limitations of advanced Multi-Master Mode.
Con rm [y|N]:
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
95 / 145
Create a Multi-Primary Cluster:
It´s also possible to create a Multi-Primary Cluster using the Shell:
mysql-js> cluster=dba.createCluster('perconalive',{multiMaster: true})
A new InnoDB cluster will be created on instance 'clusteradmin@mysql3:3306'.
The MySQL InnoDB cluster is going to be setup in advanced Multi-Master Mode.
Before continuing you have to con rm that you understand the requirements and
limitations of Multi-Master Mode. Please read the manual before proceeding.
I have read the MySQL InnoDB cluster manual and I understand the requirements
and limitations of advanced Multi-Master Mode.
Con rm [y|N]:
Or you can force it to avoid interaction (for automation) :
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
96 / 145
Create a Multi-Primary Cluster:
It´s also possible to create a Multi-Primary Cluster using the Shell:
mysql-js> cluster=dba.createCluster('perconalive',{multiMaster: true})
A new InnoDB cluster will be created on instance 'clusteradmin@mysql3:3306'.
The MySQL InnoDB cluster is going to be setup in advanced Multi-Master Mode.
Before continuing you have to con rm that you understand the requirements and
limitations of Multi-Master Mode. Please read the manual before proceeding.
I have read the MySQL InnoDB cluster manual and I understand the requirements
and limitations of advanced Multi-Master Mode.
Con rm [y|N]:
Or you can force it to avoid interaction (for automation) :
> cluster=dba.createCluster('perconalive',{multiMaster: true, force: true})
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
97 / 145
Changes in MySQL 8.0.13!
Change to/from single primary mode online:
mysql3> SELECT group_replication_switch_to_multi_primary_mode();
mysql3> SELECT group_replication_switch_to_single_primary_mode();
Choose primary node
mysql3> SELECT group_replication_set_as_primary(server_uuid);
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
98 / 145
Dynamically change to Multi Primary Mode
mysql3> SELECT group_replication_switch_to_multi_primary_mode();
+--------------------------------------------------+
| group_replication_switch_to_multi_primary_mode() |
+--------------------------------------------------+
| Mode switched to multi-primary successfully. |
+--------------------------------------------------+
mysql3> select member_host
from performance_schema.replication_group_members
where member_role='PRIMARY';
+-------------+
| member_host |
+-------------+
| mysql2 |
| mysql3 |
| mysql4 |
+-------------+
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
99 / 145
Dynamically change to Single Primary Mode
mysql3> SELECT group_replication_switch_to_single_primary_mode(@@server_uuid);
+----------------------------------------------------------------+
| group_replication_switch_to_single_primary_mode(@@server_uuid) |
+----------------------------------------------------------------+
| Mode switched to single-primary successfully. |
+----------------------------------------------------------------+
mysql3> select member_host
from performance_schema.replication_group_members
where member_role='PRIMARY';
+-------------+
| member_host |
+-------------+
| mysql3 |
+-------------+
1 row in set (0.33 sec)
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
100 / 145
Preview of MySQL Shell 8.0.14 !
JS> cluster.setPrimaryInstance('mysql1:3306')
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
101 / 145
Preview of MySQL Shell 8.0.14 !
JS> cluster.setPrimaryInstance('mysql1:3306')
JS> cluster.switchToMultiPrimaryMode()
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
102 / 145
Preview of MySQL Shell 8.0.14 !
JS> cluster.setPrimaryInstance('mysql1:3306')
JS> cluster.switchToMultiPrimaryMode()
JS> cluster.switchToSinglePrimaryMode()
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
103 / 145
get more info
Monitoring
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
104 / 145
Performance Schema
Group Replication uses Performance_Schema to expose status
mysql3> SELECT * FROM performance_schema.replication_group_membersG
*************************** 1. row ***************************
CHANNEL_NAME: group_replication_applier
MEMBER_ID: ade14d5c-9e1e-11e7-b034-08002718d305
MEMBER_HOST: mysql4
MEMBER_PORT: 3306
MEMBER_STATE: ONLINE
MEMBER_ROLE: SECONDARY
MEMBER_VERSION: 8.0.13
*************************** 2. row ***************************
CHANNEL_NAME: group_replication_applier
MEMBER_ID: b9d01593-9dfb-11e7-8ca6-08002718d305
MEMBER_HOST: mysql3
MEMBER_PORT: 3306
MEMBER_STATE: ONLINE
MEMBER_ROLE: PRIMARY
MEMBER_VERSION: 8.0.13
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
105 / 145
mysql3> SELECT * FROM performance_schema.replication_connection_statusG
*************************** 1. row ***************************
CHANNEL_NAME: group_replication_applier
GROUP_NAME: 8fc848d7-9e1c-11e7-9407...
SOURCE_UUID: 8fc848d7-9e1c-11e7-9407...
THREAD_ID: NULL
SERVICE_STATE: ON
COUNT_RECEIVED_HEARTBEATS: 0
LAST_HEARTBEAT_TIMESTAMP: 0000-00-00 00:00:00
RECEIVED_TRANSACTION_SET: 8fc848d7-9e1c-11e7-9407...
b9d01593-9dfb-11e7-8ca6-08002718d305:1-21,
da2f0910-8767-11e6-b82d-08002718d305:1-164741
LAST_ERROR_NUMBER: 0
LAST_ERROR_MESSAGE:
LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00
LAST_QUEUED_TRANSACTION: 8fc848d7-9e1c-11e7-9407...
LAST_QUEUED_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00
LAST_QUEUED_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00
LAST_QUEUED_TRANSACTION_START_QUEUE_TIMESTAMP: 2017-09-20 16:22:36.486...
LAST_QUEUED_TRANSACTION_END_QUEUE_TIMESTAMP: 2017-09-20 16:22:36.486...
QUEUEING_TRANSACTION:
QUEUEING_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00
QUEUEING_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00
QUEUEING_TRANSACTION_START_QUEUE_TIMESTAMP: 0000-00-00 00:00:00
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
106 / 145
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 @ 2018 Oracle and/or its affiliates. All rights reserved.
107 / 145
Status information & metrics
Members
mysql> select member_host, member_state, member_role,
member_version
from performance_schema.replication_group_members;
+-------------+--------------+-------------+----------------+
| member_host | member_state | member_role | member_version |
+-------------+--------------+-------------+----------------+
| mysql3 | ONLINE | PRIMARY | 8.0.13 |
| mysql4 | ONLINE | SECONDARY | 8.0.13 |
| mysql2 | ONLINE | SECONDARY | 8.0.13 |
+-------------+--------------+-------------+----------------+
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
108 / 145
Status information & metrics - connections
To see group_replication_applier and
group_replication_recovery:
mysql> SELECT * FROM performance_schema.replication_connection_statusG
8.0Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
109 / 145
Status information & metrics
Previously there were only local node statistics, now they are exposed all
over the Group
mysql> select * from performance_schema.replication_group_member_statsG
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
110 / 145
Status information & metrics
Previously there were only local node statistics, now they are exposed all
over the Group
mysql> select * from performance_schema.replication_group_member_statsG
*************************** 1. row ***************************
CHANNEL_NAME: group_replication_applier
VIEW_ID: 15059231192196925:2
MEMBER_ID: ade14d5c-9e1e-11e7-b034-08002...
COUNT_TRANSACTIONS_IN_QUEUE: 0
COUNT_TRANSACTIONS_CHECKED: 27992
COUNT_CONFLICTS_DETECTED: 0
COUNT_TRANSACTIONS_ROWS_VALIDATING: 0
TRANSACTIONS_COMMITTED_ALL_MEMBERS: 8fc848d7-9e1c-11e7-9407-08002...
b9d01593-9dfb-11e7-8ca6-08002718d305:1-21,
da2f0910-8767-11e6-b82d-08002718d305:1-164741
LAST_CONFLICT_FREE_TRANSACTION: 8fc848d7-9e1c-11e7-9407-08002...
COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE: 0
COUNT_TRANSACTIONS_REMOTE_APPLIED: 27992
COUNT_TRANSACTIONS_LOCAL_PROPOSED: 0
COUNT_TRANSACTIONS_LOCAL_ROLLBACK: 0
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
111 / 145
*************************** 2. row ***************************
CHANNEL_NAME: group_replication_applier
VIEW_ID: 15059231192196925:2
MEMBER_ID: b9d01593-9dfb-11e7-8ca6-08002...
COUNT_TRANSACTIONS_IN_QUEUE: 0
COUNT_TRANSACTIONS_CHECKED: 28000
COUNT_CONFLICTS_DETECTED: 0
COUNT_TRANSACTIONS_ROWS_VALIDATING: 0
TRANSACTIONS_COMMITTED_ALL_MEMBERS: 8fc848d7-9e1c-11e7-9407-08002...
b9d01593-9dfb-11e7-8ca6-08002718d305:1-21,
da2f0910-8767-11e6-b82d-08002718d305:1-164741
LAST_CONFLICT_FREE_TRANSACTION: 8fc848d7-9e1c-11e7-9407-08002...
COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE: 0
COUNT_TRANSACTIONS_REMOTE_APPLIED: 1
COUNT_TRANSACTIONS_LOCAL_PROPOSED: 28000
COUNT_TRANSACTIONS_LOCAL_ROLLBACK: 0
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
112 / 145
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 @ 2018 Oracle and/or its affiliates. All rights reserved.
113 / 145
Status during recovery
mysql> SHOW SLAVE STATUS FOR CHANNEL 'group_replication_recovery'G
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
114 / 145
Status during recovery
mysql> SHOW SLAVE STATUS FOR CHANNEL '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.00000
...
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 @ 2018 Oracle and/or its affiliates. All rights reserved.
115 / 145
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 sys can be found at https://goo.gl/XFp3bt
On the primary node:
[mysql1 ˜]# scp /root/addition_to_sys_8.0.2.sql mysql3:/root
[mysql3 ~]# mysql < /root/addition_to_sys_8.0.2.sql
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
116 / 145
Sys Schema
Is this node part of PRIMARY Partition:
mysql3> SELECT sys.gr_member_in_primary_partition();
+------------------------------------+
| sys.gr_node_in_primary_partition() |
+------------------------------------+
| YES |
+------------------------------------+
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
117 / 145
Sys Schema
Is this node part of PRIMARY Partition:
mysql3> SELECT sys.gr_member_in_primary_partition();
+------------------------------------+
| sys.gr_node_in_primary_partition() |
+------------------------------------+
| YES |
+------------------------------------+
To use as healthcheck:
mysql3> SELECT * FROM sys.gr_member_routing_candidate_status;
+------------------+-----------+---------------------+----------------------+
| viable_candidate | read_only | transactions_behind | transactions_to_cert |
+------------------+-----------+---------------------+----------------------+
| YES | YES | 0 | 0 |
+------------------+-----------+---------------------+----------------------+
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
118 / 145
LAB8: Sys Schema - Health Check
On one of the non Primary nodes, run the following command:
mysql-sql> ush tables with read lock;
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
119 / 145
LAB8: Sys Schema - Health Check
On one of the non Primary nodes, run the following command:
mysql-sql> ush tables with read lock;
Now you can verify what the healthcheck exposes to you:
mysql-sql> SELECT * FROM sys.gr_member_routing_candidate_status;
+------------------+-----------+---------------------+----------------------+
| viable_candidate | read_only | transactions_behind | transactions_to_cert |
+------------------+-----------+---------------------+----------------------+
| YES | YES | 950 | 0 |
+------------------+-----------+---------------------+----------------------+
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
120 / 145
LAB8: Sys Schema - Health Check
On one of the non Primary nodes, run the following command:
mysql-sql> ush tables with read lock;
Now you can verify what the healthcheck exposes to you:
mysql-sql> SELECT * FROM sys.gr_member_routing_candidate_status;
+------------------+-----------+---------------------+----------------------+
| viable_candidate | read_only | transactions_behind | transactions_to_cert |
+------------------+-----------+---------------------+----------------------+
| YES | YES | 950 | 0 |
+------------------+-----------+---------------------+----------------------+
mysql-sql> UNLOCK TABLES;
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
121 / 145
application interaction
MySQL Router
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
122 / 145
MySQL Router
MySQL Router is lightweight middleware that provides transparent routing between your
application and backend MySQL Servers. It can be used for a wide variety of use cases,
such as providing high availability and scalability by effectively routing database traffic
to appropriate backend MySQL Servers.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
123 / 145
MySQL Router
MySQL Router is lightweight middleware that provides transparent routing between your
application and backend MySQL Servers. It can be used for a wide variety of use cases,
such as providing high availability and scalability by effectively routing database traffic
to appropriate backend MySQL Servers.
MySQL Router doesn´t require any specific configuration. It configures itself
automatically (bootstrap) using MySQL InnoDB Cluster´s metadata.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
124 / 145
LAB9: MySQL Router
We will now use mysqlrouter between our application and the cluster.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
125 / 145
LAB9: MySQL Router (2)
Configure MySQL Router that will run on the app server (mysql1). We bootstrap it
using the Primary-Master:
[root@mysql1 ˜]# mysqlrouter --bootstrap clusteradmin@mysql3:3306 
--user mysqlrouter
Please enter MySQL password for clusteradmin:
Bootstrapping system MySQL Router instance...
Checking for old Router accounts
Creating account mysql_router1_rvbecwmlc6uf@'%'
MySQL Router has now been con gured for the InnoDB cluster 'perconalive'.
The following connection information can be used to connect to the cluster after
Classic MySQL protocol connections to cluster 'perconalive':
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
X protocol connections to cluster 'perconalive':
- Read/Write Connections: localhost:64460
- Read/Only Connections: localhost:64470
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
126 / 145
LAB9: MySQL Router (3)
Now let´s modify the configuration file to listen on port 3306:
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
127 / 145
LAB9: MySQL Router (3)
Now let´s modify the configuration file to listen on port 3306:
in /etc/mysqlrouter/mysqlrouter.conf:
[routing:perconalive_default_rw]
-bind_port=6446
+bind_port=3306
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
128 / 145
LAB9: MySQL Router (3)
Now let´s modify the configuration file to listen on port 3306:
in /etc/mysqlrouter/mysqlrouter.conf:
[routing:perconalive_default_rw]
-bind_port=6446
+bind_port=3306
We can stop mysqld on mysql1 and start mysqlrouter:
[mysql1 ~]# systemctl stop mysqld
[mysql1 ~]# systemctl start mysqlrouter
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
129 / 145
LAB9: MySQL Router (4)
Before killing a member we will change systemd´s default behavior that restarts
mysqld immediately:
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
130 / 145
LAB9: MySQL Router (4)
Before killing a member we will change systemd´s default behavior that restarts
mysqld immediately:
in /usr/lib/systemd/system/mysqld.service add the following under
[Service]
RestartSec=30
[mysql3 ~]# systemctl daemon-reload
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
131 / 145
LAB9: MySQL Router (5)
Now we can point the application to the router (back to mysql1):
[mysql1 ~]# run_app.sh
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
132 / 145
LAB9: MySQL Router (5)
Now we can point the application to the router (back to mysql1):
[mysql1 ~]# run_app.sh
Check app and kill mysqld on mysql3 (the Primary Master R/W node) !
[mysql3 ~]# kill -9 $(pidof mysqld)
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
133 / 145
LAB9: MySQL Router (5)
Now we can point the application to the router (back to mysql1):
[mysql1 ~]# run_app.sh
Check app and kill mysqld on mysql3 (the Primary Master R/W node) !
[mysql3 ~]# kill -9 $(pidof mysqld)
mysql2> select member_host as `primary`
from performance_schema.replication_group_members
where member_role='PRIMARY';
+----------+
| primary |
+----------+
| mysql4 |
+----------+
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
134 / 145
ProxySQL / HA Proxy / F5 / ...
3rd party router/proxy
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
135 / 145
3rd party router/proxy
MySQL InnoDB Cluster can also work with third party router / proxy.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
136 / 145
3rd party router/proxy
MySQL InnoDB Cluster can also work with third party router / proxy.
If you need some specific features that are not yet available in MySQL Router, like
transparent R/W splitting, then you can use your software of choice.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
137 / 145
3rd party router/proxy
MySQL InnoDB Cluster can also work with third party router / proxy.
If you need some specific features that are not yet available in MySQL Router, like
transparent R/W splitting, then you can use your software of choice.
The important part of such implementation is to use a good health check to verify if the
MySQL server you plan to route the traffic is in a valid state.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
138 / 145
3rd party router/proxy
MySQL InnoDB Cluster can also work with third party router / proxy.
If you need some specific features that are not yet available in MySQL Router, like
transparent R/W splitting, then you can use your software of choice.
The important part of such implementation is to use a good health check to verify if the
MySQL server you plan to route the traffic is in a valid state.
MySQL Router implements that natively, and it´s very easy to deploy.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
139 / 145
ProxySQL also has native support for Group
Replication which makes it maybe the best
choice for advanced users.
3rd party router/proxy
MySQL InnoDB Cluster can also work with third party router / proxy.
If you need some specific features that are not yet available in MySQL Router, like
transparent R/W splitting, then you can use your software of choice.
The important part of such implementation is to use a good health check to verify if the
MySQL server you plan to route the traffic is in a valid state.
MySQL Router implements that natively, and it´s very easy to deploy.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
140 / 145
operational tasks
Recovering Node
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
141 / 145
Recovering Nodes/Members
The old master (mysql3) got killed.
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
142 / 145
Recovering Nodes/Members
The old master (mysql3) got killed.
MySQL got restarted automatically by systemd
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
143 / 145
Recovering Nodes/Members
The old master (mysql3) got killed.
MySQL got restarted automatically by systemd
And mysql3 joined back the cluster automatically !
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
144 / 145
Thank you !
Any Questions ?
Copyright @ 2018 Oracle and/or its affiliates. All rights reserved.
145 / 145

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

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
 
MySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & OperationsMySQL InnoDB Cluster - Advanced Configuration & Operations
MySQL InnoDB Cluster - Advanced Configuration & Operations
 
MySQL 8 High Availability with InnoDB Clusters
MySQL 8 High Availability with InnoDB ClustersMySQL 8 High Availability with InnoDB Clusters
MySQL 8 High Availability with InnoDB Clusters
 
MySQL High Availability Solutions
MySQL High Availability SolutionsMySQL High Availability Solutions
MySQL High Availability Solutions
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group Replication
 
Percona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesPercona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL Architectures
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
 
High Availability in MySQL 8 using InnoDB Cluster
High Availability in MySQL 8 using InnoDB ClusterHigh Availability in MySQL 8 using InnoDB Cluster
High Availability in MySQL 8 using InnoDB Cluster
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바
 
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)
 
Disaster Recovery with MySQL InnoDB ClusterSet - What is it and how do I use it?
Disaster Recovery with MySQL InnoDB ClusterSet - What is it and how do I use it?Disaster Recovery with MySQL InnoDB ClusterSet - What is it and how do I use it?
Disaster Recovery with MySQL InnoDB ClusterSet - What is it and how do I use it?
 
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
 
Automated master failover
Automated master failoverAutomated master failover
Automated master failover
 
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 GTID Concepts, Implementation and troubleshooting
MySQL GTID Concepts, Implementation and troubleshooting MySQL GTID Concepts, Implementation and troubleshooting
MySQL GTID Concepts, Implementation and troubleshooting
 
Upgrade from MySQL 5.7 to MySQL 8.0
Upgrade from MySQL 5.7 to MySQL 8.0Upgrade from MySQL 5.7 to MySQL 8.0
Upgrade from MySQL 5.7 to MySQL 8.0
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
 
MySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - TutorialMySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster / ReplicaSet - Tutorial
 

Ähnlich wie MySQL InnoDB Cluster and Group Replication in a nutshell hands-on tutorial

Ähnlich wie MySQL InnoDB Cluster and Group Replication in a nutshell hands-on tutorial (20)

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 !
 
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
 
MySQL Group Replication - HandsOn Tutorial
MySQL Group Replication - HandsOn TutorialMySQL Group Replication - HandsOn Tutorial
MySQL Group Replication - HandsOn 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...
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
 
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 !!
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
 
MySQL Shell/AdminAPI - MySQL Architectures Made Easy For All!
MySQL Shell/AdminAPI - MySQL Architectures Made Easy For All!MySQL Shell/AdminAPI - MySQL Architectures Made Easy For All!
MySQL Shell/AdminAPI - MySQL Architectures Made Easy For All!
 
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
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to 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 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 ...
 
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
 
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
 
the State of the Dolphin - October 2020
the State of the Dolphin - October 2020the State of the Dolphin - October 2020
the State of the Dolphin - October 2020
 
MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08MySQL Database Architectures - 2022-08
MySQL Database Architectures - 2022-08
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A2 run vmware_workloads_on_public_cloud-without_any_change
A2 run vmware_workloads_on_public_cloud-without_any_changeA2 run vmware_workloads_on_public_cloud-without_any_change
A2 run vmware_workloads_on_public_cloud-without_any_change
 
Alta Disponibilidade no MySQL 5.7
Alta Disponibilidade no MySQL 5.7Alta Disponibilidade no MySQL 5.7
Alta Disponibilidade no MySQL 5.7
 
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
 

Mehr von Frederic Descamps

Mehr von Frederic Descamps (20)

MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
MySQL Innovation & Cloud Day - Document Store avec MySQL HeatWave Database Se...
 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
 
RivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and HistogramsRivieraJUG - MySQL Indexes and Histograms
RivieraJUG - MySQL Indexes and Histograms
 
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdfRivieraJUG - MySQL 8.0 - What's new for developers.pdf
RivieraJUG - MySQL 8.0 - What's new for developers.pdf
 
MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8
 
State of the Dolphin - May 2022
State of the Dolphin - May 2022State of the Dolphin - May 2022
State of the Dolphin - May 2022
 
Percona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio CodePercona Live 2022 - MySQL Shell for Visual Studio Code
Percona Live 2022 - MySQL Shell for Visual Studio Code
 
Percona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database SystemPercona Live 2022 - The Evolution of a MySQL Database System
Percona Live 2022 - The Evolution of a MySQL Database System
 
LinuxFest Northwest 2022 - The Evolution of a MySQL Database System
LinuxFest Northwest 2022 - The Evolution of a MySQL Database SystemLinuxFest Northwest 2022 - The Evolution of a MySQL Database System
LinuxFest Northwest 2022 - The Evolution of a MySQL Database System
 
Pi Day 2022 - from IoT to MySQL HeatWave Database Service
Pi Day 2022 -  from IoT to MySQL HeatWave Database ServicePi Day 2022 -  from IoT to MySQL HeatWave Database Service
Pi Day 2022 - from IoT to MySQL HeatWave Database Service
 
Confoo 2022 - le cycle d'une instance MySQL
Confoo 2022  - le cycle d'une instance MySQLConfoo 2022  - le cycle d'une instance MySQL
Confoo 2022 - le cycle d'une instance MySQL
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0Les nouveautés de MySQL 8.0
Les nouveautés de MySQL 8.0
 
State of The Dolphin - May 2021
State of The Dolphin - May 2021State of The Dolphin - May 2021
State of The Dolphin - May 2021
 
MySQL Shell for DBAs
MySQL Shell for DBAsMySQL Shell for DBAs
MySQL Shell for DBAs
 
Deploying Magento on OCI with MDS
Deploying Magento on OCI with MDSDeploying Magento on OCI with MDS
Deploying Magento on OCI with MDS
 
MySQL Router REST API
MySQL Router REST APIMySQL Router REST API
MySQL Router REST API
 
From single MySQL instance to High Availability: the journey to MySQL InnoDB ...
From single MySQL instance to High Availability: the journey to MySQL InnoDB ...From single MySQL instance to High Availability: the journey to MySQL InnoDB ...
From single MySQL instance to High Availability: the journey to MySQL InnoDB ...
 
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native -  Why to use MySQL 8.0 and how to use it on oci with MDSCloud native -  Why to use MySQL 8.0 and how to use it on oci with MDS
Cloud native - Why to use MySQL 8.0 and how to use it on oci with MDS
 
MySQL Database Service Webinar: Installing Drupal in oci with mds
MySQL Database Service Webinar: Installing Drupal in oci with mdsMySQL Database Service Webinar: Installing Drupal in oci with mds
MySQL Database Service Webinar: Installing Drupal in oci with mds
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

MySQL InnoDB Cluster and Group Replication in a nutshell hands-on tutorial

  • 3. MySQL InnoDB Cluster in a Nutshell Hands-On Tutorial Percona Live Europe - Frankfurt 2018 Frédéric Descamps - MySQL Community Manager - Oracle Kenny Gryp - ■■■■■ ■■■■■■■ ■■■■■■■ - ■■■■■■ 3 / 145
  • 4.   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 @ 2018 Oracle and/or its affiliates. All rights reserved. 4 / 145
  • 5. Who are we ? Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 5 / 145
  • 6. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 6 / 145
  • 7. Frédéric Descamps @lefred MySQL Evangelist Managing MySQL since 3.23 devops believer http://about.me/lefred   Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 7 / 145
  • 8. Kenny Gryp @gryp Houseman Aspiring electrician   Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 8 / 145
  • 9. how will the session proceed? Agenda Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 9 / 145
  • 10. Agenda Prepare your workstation Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 10 / 145
  • 11. Agenda Prepare your workstation What are MySQL InnoDB Cluster & Group Replication ? Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 11 / 145
  • 12. Agenda Prepare your workstation What are MySQL InnoDB Cluster & Group Replication ? Migration from Master-Slave to GR Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 12 / 145
  • 13. Agenda Prepare your workstation What are MySQL InnoDB Cluster & Group Replication ? Migration from Master-Slave to GR How to monitor ? Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 13 / 145
  • 14. Agenda Prepare your workstation What are MySQL InnoDB Cluster & Group Replication ? Migration from Master-Slave to GR How to monitor ? Application interaction Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 14 / 145
  • 15. VirtualBox Setup your workstation Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 15 / 145
  • 16. Setup your workstation Install VirtualBox 5.2 On the USB key, copy PLEU_18_GR.ova on your laptop and doubleclick on it Ensure you have vboxnet0 network interface Older VirtualBox: VirtualBox Pref. -> Network -> Host-Only Networks -> + New VirtualBox: Global Tools -> Host Network Manager -> + Start all virtual machines (mysql1, mysql2, mysql3 & mysql4) Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 16 / 145
  • 17. Setup your workstation Install VirtualBox 5.2 On the USB key, copy PLEU_18_GR.ova on your laptop and doubleclick on it Ensure you have vboxnet0 network interface Older VirtualBox: VirtualBox Pref. -> Network -> Host-Only Networks -> + New VirtualBox: Global Tools -> Host Network Manager -> + Start all virtual machines (mysql1, mysql2, mysql3 & mysql4) Try to connect to all VM´s from your terminal or putty (root password is X) : ssh -p 8821 root@127.0.0.1 mysql1 ssh -p 8822 root@127.0.0.1 mysql2 ssh -p 8823 root@127.0.0.1 mysql3 ssh -p 8824 root@127.0.0.1 mysql4 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 17 / 145
  • 18. LAB1: Current situation Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 18 / 145
  • 19. all running database servers (mysql1 & mysql2) are using MySQL 5.7.24 LAB1: Current situation Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 19 / 145
  • 20. launch run_app.sh on mysql1 into a screen session verify that mysql2 is a running slave LAB1: Current situation Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 20 / 145
  • 21. Summary   +--------+----------+--------------+----------------+ | | ROLE | SSH PORT | INTERNAL IP | +--------+----------+--------------+----------------+ | | | | | | mysql1 | master | 8821 | 192.168.91.11 | | | | | | | mysql2 | slave | 8822 | 192.168.91.12 | | | | | | | mysql3 | n/a | 8823 | 192.168.91.13 | | | | | | | mysql4 | n/a | 8824 | 192.168.91.14 | | | | | | +--------+----------+--------------++---------------+ Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 21 / 145
  • 22. Summary   +--------+----------+--------------+----------------+ | | ROLE | SSH PORT | INTERNAL IP | +--------+----------+--------------+----------------+ | | | | | | mysql1 | master | 8821 | 192.168.91.11 | | | | | | | mysql2 | slave | 8822 | 192.168.91.12 | | | | | | | mysql3 | n/a | 8823 | 192.168.91.13 | | | | | | | mysql4 | n/a | 8824 | 192.168.91.14 | | | | | | +--------+----------+--------------++---------------+ write this down somewhere ! Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 22 / 145
  • 23. Easy High Availability MySQL InnoDB Cluster Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 23 / 145
  • 24. InnoDB cluster Ease-of-Use Extreme Scale-Out Out-of-Box Solution Built-in HA High Performance Everything Integrated Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 24 / 145
  • 25. InnoDB Cluster's Architecture Application MySQL Connector MySQL Router MySQL Shell InnoDB cluster Application MySQL Connector MySQL Router Mp M M Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 25 / 145
  • 26. Group Replication: heart of MySQL InnoDB Cluster Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 26 / 145
  • 27. Group Replication: heart of MySQL InnoDB Cluster Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 27 / 145
  • 28. MySQL Group Replication but what is it ?!? Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 28 / 145
  • 29. MySQL Group Replication but what is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 29 / 145
  • 30. MySQL Group Replication but what is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 30 / 145
  • 31. MySQL Group Replication but what is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory Paxos based protocol Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 31 / 145
  • 32. MySQL Group Replication but what is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory Paxos based protocol GR allows to write on all Group Members (cluster nodes) simultaneously while retaining consistency Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 32 / 145
  • 33. MySQL Group Replication but what is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory Paxos based protocol GR allows to write on all Group Members (cluster nodes) simultaneously while retaining consistency GR implements conflict detection and resolution Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 33 / 145
  • 34. MySQL Group Replication but what is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory Paxos based protocol GR allows to write on all Group Members (cluster nodes) simultaneously while retaining consistency GR implements conflict detection and resolution GR allows automatic distributed recovery Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 34 / 145
  • 35. MySQL Group Replication but what is it ?!? GR is a plugin for MySQL, made by MySQL and packaged with MySQL GR is an implementation of Replicated Database State Machine theory Paxos based protocol GR allows to write on all Group Members (cluster nodes) simultaneously while retaining consistency GR implements conflict detection and resolution GR allows automatic distributed recovery Supported on all MySQL platforms !! Linux, Windows, Solaris, OSX, FreeBSD Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 35 / 145
  • 36. And for users ? Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 36 / 145
  • 37. And for users ? not longer necessary to handle server fail-over manually or with a complicated script Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 37 / 145
  • 38. And for users ? not longer necessary to handle server fail-over manually or with a complicated script GR provides fault tolerance Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 38 / 145
  • 39. And for users ? not longer necessary to handle server fail-over manually or with a complicated script GR provides fault tolerance GR enables update-everywhere setups Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 39 / 145
  • 40. And for users ? not longer necessary to handle server fail-over manually or with a complicated script GR provides fault tolerance GR enables update-everywhere setups GR handles crashes, failures, re-connects automatically Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 40 / 145
  • 41. And for users ? not longer necessary to handle server fail-over manually or with a complicated script GR provides fault tolerance GR enables update-everywhere setups GR handles crashes, failures, re-connects automatically Allows an easy setup of a highly available MySQL service! Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 41 / 145
  • 42. ready ? Migration from Master-Slave to GR Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 42 / 145
  • 43. The plan Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 43 / 145
  • 44. These are the 10 steps for the migration: 1) We install and setup MySQL InnoDB Cluster on one of the new servers The plan Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 44 / 145
  • 45. 2) we restore a backup 3) we update to MySQL 8.0 4) setup asynchronous replication on the new server. The plan Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 45 / 145
  • 46. 5) we add a new instance to our group The plan Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 46 / 145
  • 47. 6) we point the application to one of our new nodes. 7) we wait and check that asynchronous replication is caught up 8) we stop those asynchronous slaves The plan Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 47 / 145
  • 48. 9) we upgrade and attach mysql2 (previous slave) to the group The plan Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 48 / 145
  • 49. 10) use MySQL Router for directing traffic The plan Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 49 / 145
  • 50. LAB2: Verify if your environment can be upgraded to MySQL 8.0 We will first create an admin account on mysql1 that we will use throughout the tutorial: mysql1> CREATE USER clusteradmin@'%' identi ed by 'mysql'; mysql1> GRANT ALL PRIVILEGES ON *.* TO clusteradmin@'%' WITH GRANT OPTION; Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 50 / 145
  • 51. LAB2: Verify if your environment can be upgraded to MySQL 8.0 We will first create an admin account on mysql1 that we will use throughout the tutorial: mysql1> CREATE USER clusteradmin@'%' identi ed by 'mysql'; mysql1> GRANT ALL PRIVILEGES ON *.* TO clusteradmin@'%' WITH GRANT OPTION; Now, we use MySQL Shell to check if the settings on mysql1 can be upgraded to MySQL 8.0 without problem: Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 51 / 145
  • 52. LAB2: Verify if your environment can be upgraded to MySQL 8.0 We will first create an admin account on mysql1 that we will use throughout the tutorial: mysql1> CREATE USER clusteradmin@'%' identi ed by 'mysql'; mysql1> GRANT ALL PRIVILEGES ON *.* TO clusteradmin@'%' WITH GRANT OPTION; Now, we use MySQL Shell to check if the settings on mysql1 can be upgraded to MySQL 8.0 without problem: # mysqlsh -- util check-for-server-upgrade clusteradmin@mysql1 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 52 / 145
  • 53. LAB2: Beautiful MySQL Shell You can setup a better shell environment : # mysqlsh mysql-js> shell.options['history.autoSave']=true # cp /usr/share/mysqlsh/prompt/prompt_256pl+aw.json ~/.mysqlsh/prompt.json # mysqlsh clusteradmin@mysql2 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 53 / 145
  • 54. MySQL 8.0.13 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 54 / 145
  • 55. LAB2: Prepare mysql3 (2) Asynchronous slave Copy the backup from mysql1 to mysql3: [mysql1 ~]# scp -r /tmp/backup mysql3:/tmp And restore it: [mysql3 ~]# xtrabackup --copy-back --target-dir=/tmp/backup [mysql3 ~]# chown -R mysql. /var/lib/mysql 55 / 145
  • 56. LAB2: Prepare mysql3 (3) Asynchronous slave Let´s start MySQL on mysql3: [mysql3 ~]# systemctl start mysqld Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 56 / 145
  • 57. LAB2: Prepare mysql3 (3) Asynchronous slave Let´s start MySQL on mysql3: [mysql3 ~]# systemctl start mysqld [mysql3 ~]# mysql_upgrade Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 57 / 145
  • 58. LAB2: Prepare mysql3 (3) Asynchronous slave Let´s start MySQL on mysql3: [mysql3 ~]# systemctl start mysqld [mysql3 ~]# mysql_upgrade And restart mysqld as recommended after having run mysql_upgrade: [mysql3 ~]# systemctl restart mysqld or # mysqlsh clusteradmin@mysql3 --sql -e "restart" Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 58 / 145
  • 59. find the GTIDs purged change MASTER set the purged GTIDs start replication LAB3: mysql3 as asynchronous slave (1)   Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 59 / 145
  • 60. 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 mysql3 and setup replication: mysql> CHANGE MASTER TO MASTER_HOST="mysql1", MASTER_USER="repl", MASTER_PASSWORD='X', MASTER_AUTO_POSITION=1; mysql> RESET MASTER; mysql> SET global gtid_purged="VALUE FOUND PREVIOUSLY"; mysql> START SLAVE; Check that you receive the application´s traffic 60 / 145
  • 61. Administration made easy and more... MySQL InnoDB Cluster Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 61 / 145
  • 62. LAB4: MySQL InnoDB Cluster Create a single instance cluster (mysql3) # mysqlsh Let´s verify if our server is ready to become a member of a new cluster: mysql-js> dba.checkInstanceCon guration('clusteradmin@mysql3') Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 62 / 145
  • 63. LAB4: MySQL InnoDB Cluster Create a single instance cluster (mysql3) # mysqlsh Let´s verify if our server is ready to become a member of a new cluster: mysql-js> dba.checkInstanceCon guration('clusteradmin@mysql3') Change the configuration ! mysql-js> dba.con gureInstance('clusteradmin@mysql3') Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 63 / 145
  • 64. LAB4: MySQL InnoDB Cluster (2) Wait just a bit if a restart is required ()which is not the case here) and create a single instance cluster mysql-js> dba.checkInstanceCon guration('clusteradmin@mysql3') mysql-js> c clusteradmin@mysql3:3306 mysql-js> cluster = dba.createCluster('perconalive') Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 64 / 145
  • 65. LAB4: Cluster Status mysql-js> cluster.status() { "clusterName": "perconalive", "defaultReplicaSet": { "name": "default", "primary": "mysql3:3306", "ssl": "REQUIRED", "status": "OK_NO_TOLERANCE", "statusText": "Cluster is NOT tolerant to any failures.", "topology": { "mysql3:3306": { "address": "mysql3:3306", "mode": "R/W", "readReplicas": {}, "role": "HA", "status": "ONLINE" } } }, "groupInformationSourceMember": "mysql://clusteradmin@mysql3:3306" } Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 65 / 145
  • 66. Add mysql4 to the Group: restore the backup set the purged GTIDs use MySQL Shell LAB5: add mysql4 to the cluster (1)   Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 66 / 145
  • 67. LAB5: add mysql4 to the cluster (2) Copy the backup from mysql1 to mysql4: [mysql1 ~]# scp -r /tmp/backup mysql4:/tmp And restore it: [mysql4 ~]# xtrabackup --copy-back --target-dir=/tmp/backup [mysql4 ~]# chown -R mysql. /var/lib/mysql Start MySQL on mysql4: [mysql4 ~]# systemctl start mysqld [mysql4 ~]# mysql_upgrade [mysql4 ~]# mysqlsh clusteradmin@mysql4 --sql -e "restart" 67 / 145
  • 68. LAB5: MySQL InnoDB Cluster (3) 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 mysql4 and set GTID_PURGED [mysql4 ~]# mysqlsh mysql-js> c clusteradmin@mysql4 mysql-js> sql mysql-sql> SET global gtid_purged="VALUE FOUND PREVIOUSLY"; 68 / 145
  • 69. LAB5: MySQL Shell to add an instance (4) Let´s add mysql4 (check configuration, check instance and add to cluster all in one command that can be done from the opened shell in mysql3): mysql-js> dba.con gureInstance('clusteradmin@mysql4') mysql-js> cluster.addInstance('clusteradmin@mysql4') mysql-js> cluster.status() Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 69 / 145
  • 70. LAB5: MySQL Shell to add an instance (4) Let´s add mysql4 (check configuration, check instance and add to cluster all in one command that can be done from the opened shell in mysql3): mysql-js> dba.con gureInstance('clusteradmin@mysql4') mysql-js> cluster.addInstance('clusteradmin@mysql4') mysql-js> cluster.status() As no restart is required some missing privileges (not in available 5.7) are not necessary, but in case you need them those are the missing grant: mysql-sql> GRANT SYSTEM_VARIABLES_ADMIN, PERSIST_RO_VARIABLES_ADMIN ON *.* TO 'clusteradmin'@'%'; Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 70 / 145
  • 71. Cluster Status mysql-js> cluster.status() { "clusterName": "perconalive", "defaultReplicaSet": { "name": "default", "primary": "mysql3:3306", "ssl": "REQUIRED", "status": "OK_NO_TOLERANCE", "statusText": "Cluster is NOT tolerant to any failures. 1 member is not a "topology": { "mysql3:3306": { "address": "mysql3:3306", "mode": "R/W", "readReplicas": {}, "role": "HA", "status": "ONLINE" }, "mysql4:3306": { "address": "mysql4:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "RECOVERING" Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 71 / 145
  • 72. Recovering progress On standard MySQL, monitor the group_replication_recovery channel to see the progress: mysql4> show slave status for channel 'group_replication_recovery'G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event 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 @ 2018 Oracle and/or its affiliates. All rights reserved. 72 / 145
  • 73. Cluster Status { "clusterName": "perconalive", "defaultReplicaSet": { "name": "default", "primary": "mysql3:3306", "ssl": "REQUIRED", "status": "OK_NO_TOLERANCE", "statusText": "Cluster is NOT tolerant to any failures.", "topology": { "mysql3:3306": { "address": "mysql3:3306", "mode": "R/W", "readReplicas": {}, "role": "HA", "status": "ONLINE" }, "mysql4:3306": { "address": "mysql4:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "ONLINE" } Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 73 / 145
  • 74. Asynchronous Replication When a group is created, the asynchronous SQL Thread is stopped and needs to be restarted. Verify that replication from mysql1 is still running on mysql3, and restart the SQL Thread: mysql-sql> c clusteradmin@mysql3 mysql-sql> SHOW SLAVE STATUSG mysql-sql> START SLAVE SQL_THREAD; Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 74 / 145
  • 75. point the application to the cluster Migrate the application Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 75 / 145
  • 76. LAB6: Migrate the application Now we need to point the application to mysql3, this is the only downtime ! Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 76 / 145
  • 77. LAB6: Migrate the application Now we need to point the application to mysql3, this is the only downtime ! Make sure the master and replica is in sync Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 77 / 145
  • 78. LAB6: Migrate the application Now we need to point the application to mysql3, this is the only downtime ! Make sure the master and replica is in sync Start application, connecting to the Group Replication master (mysql3) ... [ 21257s] threads: 4, tps: 12.00, reads: 167.94, writes: 47.98, response time: 1 [ 21258s] threads: 4, tps: 6.00, reads: 83.96, writes: 23.99, response time: 1 [ 21259s] threads: 4, tps: 7.00, reads: 98.05, writes: 28.01, response time: 1 [ 31250s] threads: 4, tps: 8.00, reads: 111.95, writes: 31.99, response time: 3 [ 31251s] threads: 4, tps: 11.00, reads: 154.01, writes: 44.00, response time: 1 [ 31252s] threads: 4, tps: 11.00, reads: 153.94, writes: 43.98, response time: 1 [ 31253s] threads: 4, tps: 10.01, reads: 140.07, writes: 40.02, response time: 1 ^C [mysql1 ~]# run_app.sh mysql3 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 78 / 145
  • 79. LAB6: Migrate the application Make sure gtid_executed range on mysql2 is lower or equal than on mysql3 mysql[2-3]> SHOW GLOBAL VARIABLES LIKE 'gtid_executed'G Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 79 / 145
  • 80. LAB6: Migrate the application Make sure gtid_executed range on mysql2 is lower or equal than on mysql3 mysql[2-3]> SHOW GLOBAL VARIABLES LIKE 'gtid_executed'G When they are OK, stop asynchronous replication on mysql2 and mysql3: mysql2> STOP SLAVE; mysql3> STOP SLAVE; Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 80 / 145
  • 81. LAB6: Migrate the application Make sure gtid_executed range on mysql2 is lower or equal than on mysql3 mysql[2-3]> SHOW GLOBAL VARIABLES LIKE 'gtid_executed'G When they are OK, stop asynchronous replication on mysql2 and mysql3: mysql2> STOP SLAVE; mysql3> STOP SLAVE; Now they can forget about mysql1: mysql[2-3]> RESET SLAVE ALL FOR CHANNEL ''; Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 81 / 145
  • 82. previous slave (mysql2) can now be part of the cluster Add a third instance Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 82 / 145
  • 83. LAB7: Add mysql2 to the group We first upgrade to MySQL 8.0.13 : Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 83 / 145
  • 84. LAB7: Add mysql2 to the group We first upgrade to MySQL 8.0.13 : [mysql2 ~]# systemctl stop mysqld [mysql2 ~]# rpm -Uvh /root/rpms/*rpm --nodeps --force [mysql2 ~]# systemctl start mysqld [mysql2 ~]# mysql_upgrade [mysql2 ~]# systemctl restart mysqld Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 84 / 145
  • 85. LAB7: Add mysql2 to the group (2) mysql-js> dba.con gureInstance('clusteradmin@mysql2') Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 85 / 145
  • 86. LAB7: Add mysql2 to the group (2) mysql-js> dba.con gureInstance('clusteradmin@mysql2') In case you don't have the cluster object in your shell anymore, you can still retrieve it: mysql-js> c clusteradmin@mysql3 mysql-js> cluster = dba.getCluster() Add mysql2 to the cluster: mysql-js> cluster.checkInstanceState('clusteradmin@mysql2') mysql-js> cluster.addInstance("clusteradmin@mysql2:3306") mysql-js> cluster.status() Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 86 / 145
  • 87. LAB7: Add mysql2 to the group (3) { "clusterName": "perconalive", "defaultReplicaSet": { "name": "default", "primary": "mysql3:3306", "ssl": "REQUIRED", "status": "OK", "statusText": "Cluster is ONLINE and can tolerate up to ONE failure.", "topology": { "mysql2:3306": { "address": "mysql2:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "ONLINE" }, "mysql3:3306": { "address": "mysql3:3306", "mode": "R/W", "readReplicas": {}, "role": "HA", "status": "ONLINE" }, "mysql4:3306": { 87 / 145
  • 88. writing to a single server Single Primary Mode Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 88 / 145
  • 89. Default = Single Primary Mode By default, MySQL InnoDB Cluster enables Single Primary Mode. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 89 / 145
  • 90. Default = Single Primary Mode By default, MySQL InnoDB Cluster enables Single Primary Mode. mysql> show global variables like 'group_replication_single_primary_mode'; +---------------------------------------+-------+ | Variable_name | Value | +---------------------------------------+-------+ | group_replication_single_primary_mode | ON | +---------------------------------------+-------+ Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 90 / 145
  • 91. Default = Single Primary Mode By default, MySQL InnoDB Cluster enables Single Primary Mode. mysql> show global variables like 'group_replication_single_primary_mode'; +---------------------------------------+-------+ | Variable_name | Value | +---------------------------------------+-------+ | group_replication_single_primary_mode | ON | +---------------------------------------+-------+ In Single Primary Mode, a single member acts as the writable master (PRIMARY) and the rest of the members act as hot-standbys (SECONDARY). The group itself coordinates and configures itself automatically to determine which member will act as the PRIMARY, through a leader election mechanism. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 91 / 145
  • 92. Who´s the Primary Master ? You can already see it in the output of cluster.status() Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 92 / 145
  • 93. Who´s the Primary Master ? You can already see it in the output of cluster.status() But you can also check in performance_schema: mysql> select member_host from performance_schema.replication_group_members where member_role='PRIMARY'; +-------------+ | member_host | +-------------+ | mysql3 | +-------------+ Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 93 / 145
  • 94. Create a Multi-Primary Cluster: It´s also possible to create a Multi-Primary Cluster using the Shell: mysql-js> cluster=dba.createCluster('perconalive',{multiMaster: true}) Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 94 / 145
  • 95. Create a Multi-Primary Cluster: It´s also possible to create a Multi-Primary Cluster using the Shell: mysql-js> cluster=dba.createCluster('perconalive',{multiMaster: true}) A new InnoDB cluster will be created on instance 'clusteradmin@mysql3:3306'. The MySQL InnoDB cluster is going to be setup in advanced Multi-Master Mode. Before continuing you have to con rm that you understand the requirements and limitations of Multi-Master Mode. Please read the manual before proceeding. I have read the MySQL InnoDB cluster manual and I understand the requirements and limitations of advanced Multi-Master Mode. Con rm [y|N]: Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 95 / 145
  • 96. Create a Multi-Primary Cluster: It´s also possible to create a Multi-Primary Cluster using the Shell: mysql-js> cluster=dba.createCluster('perconalive',{multiMaster: true}) A new InnoDB cluster will be created on instance 'clusteradmin@mysql3:3306'. The MySQL InnoDB cluster is going to be setup in advanced Multi-Master Mode. Before continuing you have to con rm that you understand the requirements and limitations of Multi-Master Mode. Please read the manual before proceeding. I have read the MySQL InnoDB cluster manual and I understand the requirements and limitations of advanced Multi-Master Mode. Con rm [y|N]: Or you can force it to avoid interaction (for automation) : Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 96 / 145
  • 97. Create a Multi-Primary Cluster: It´s also possible to create a Multi-Primary Cluster using the Shell: mysql-js> cluster=dba.createCluster('perconalive',{multiMaster: true}) A new InnoDB cluster will be created on instance 'clusteradmin@mysql3:3306'. The MySQL InnoDB cluster is going to be setup in advanced Multi-Master Mode. Before continuing you have to con rm that you understand the requirements and limitations of Multi-Master Mode. Please read the manual before proceeding. I have read the MySQL InnoDB cluster manual and I understand the requirements and limitations of advanced Multi-Master Mode. Con rm [y|N]: Or you can force it to avoid interaction (for automation) : > cluster=dba.createCluster('perconalive',{multiMaster: true, force: true}) Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 97 / 145
  • 98. Changes in MySQL 8.0.13! Change to/from single primary mode online: mysql3> SELECT group_replication_switch_to_multi_primary_mode(); mysql3> SELECT group_replication_switch_to_single_primary_mode(); Choose primary node mysql3> SELECT group_replication_set_as_primary(server_uuid); Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 98 / 145
  • 99. Dynamically change to Multi Primary Mode mysql3> SELECT group_replication_switch_to_multi_primary_mode(); +--------------------------------------------------+ | group_replication_switch_to_multi_primary_mode() | +--------------------------------------------------+ | Mode switched to multi-primary successfully. | +--------------------------------------------------+ mysql3> select member_host from performance_schema.replication_group_members where member_role='PRIMARY'; +-------------+ | member_host | +-------------+ | mysql2 | | mysql3 | | mysql4 | +-------------+ Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 99 / 145
  • 100. Dynamically change to Single Primary Mode mysql3> SELECT group_replication_switch_to_single_primary_mode(@@server_uuid); +----------------------------------------------------------------+ | group_replication_switch_to_single_primary_mode(@@server_uuid) | +----------------------------------------------------------------+ | Mode switched to single-primary successfully. | +----------------------------------------------------------------+ mysql3> select member_host from performance_schema.replication_group_members where member_role='PRIMARY'; +-------------+ | member_host | +-------------+ | mysql3 | +-------------+ 1 row in set (0.33 sec) Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 100 / 145
  • 101. Preview of MySQL Shell 8.0.14 ! JS> cluster.setPrimaryInstance('mysql1:3306') Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 101 / 145
  • 102. Preview of MySQL Shell 8.0.14 ! JS> cluster.setPrimaryInstance('mysql1:3306') JS> cluster.switchToMultiPrimaryMode() Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 102 / 145
  • 103. Preview of MySQL Shell 8.0.14 ! JS> cluster.setPrimaryInstance('mysql1:3306') JS> cluster.switchToMultiPrimaryMode() JS> cluster.switchToSinglePrimaryMode() Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 103 / 145
  • 104. get more info Monitoring Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 104 / 145
  • 105. Performance Schema Group Replication uses Performance_Schema to expose status mysql3> SELECT * FROM performance_schema.replication_group_membersG *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: ade14d5c-9e1e-11e7-b034-08002718d305 MEMBER_HOST: mysql4 MEMBER_PORT: 3306 MEMBER_STATE: ONLINE MEMBER_ROLE: SECONDARY MEMBER_VERSION: 8.0.13 *************************** 2. row *************************** CHANNEL_NAME: group_replication_applier MEMBER_ID: b9d01593-9dfb-11e7-8ca6-08002718d305 MEMBER_HOST: mysql3 MEMBER_PORT: 3306 MEMBER_STATE: ONLINE MEMBER_ROLE: PRIMARY MEMBER_VERSION: 8.0.13 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 105 / 145
  • 106. mysql3> SELECT * FROM performance_schema.replication_connection_statusG *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier GROUP_NAME: 8fc848d7-9e1c-11e7-9407... SOURCE_UUID: 8fc848d7-9e1c-11e7-9407... THREAD_ID: NULL SERVICE_STATE: ON COUNT_RECEIVED_HEARTBEATS: 0 LAST_HEARTBEAT_TIMESTAMP: 0000-00-00 00:00:00 RECEIVED_TRANSACTION_SET: 8fc848d7-9e1c-11e7-9407... b9d01593-9dfb-11e7-8ca6-08002718d305:1-21, da2f0910-8767-11e6-b82d-08002718d305:1-164741 LAST_ERROR_NUMBER: 0 LAST_ERROR_MESSAGE: LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00 LAST_QUEUED_TRANSACTION: 8fc848d7-9e1c-11e7-9407... LAST_QUEUED_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00 LAST_QUEUED_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00 LAST_QUEUED_TRANSACTION_START_QUEUE_TIMESTAMP: 2017-09-20 16:22:36.486... LAST_QUEUED_TRANSACTION_END_QUEUE_TIMESTAMP: 2017-09-20 16:22:36.486... QUEUEING_TRANSACTION: QUEUEING_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 0000-00-00 00:00:00 QUEUEING_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 0000-00-00 00:00:00 QUEUEING_TRANSACTION_START_QUEUE_TIMESTAMP: 0000-00-00 00:00:00 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 106 / 145
  • 107. 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 @ 2018 Oracle and/or its affiliates. All rights reserved. 107 / 145
  • 108. Status information & metrics Members mysql> select member_host, member_state, member_role, member_version from performance_schema.replication_group_members; +-------------+--------------+-------------+----------------+ | member_host | member_state | member_role | member_version | +-------------+--------------+-------------+----------------+ | mysql3 | ONLINE | PRIMARY | 8.0.13 | | mysql4 | ONLINE | SECONDARY | 8.0.13 | | mysql2 | ONLINE | SECONDARY | 8.0.13 | +-------------+--------------+-------------+----------------+ Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 108 / 145
  • 109. Status information & metrics - connections To see group_replication_applier and group_replication_recovery: mysql> SELECT * FROM performance_schema.replication_connection_statusG 8.0Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 109 / 145
  • 110. Status information & metrics Previously there were only local node statistics, now they are exposed all over the Group mysql> select * from performance_schema.replication_group_member_statsG Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 110 / 145
  • 111. Status information & metrics Previously there were only local node statistics, now they are exposed all over the Group mysql> select * from performance_schema.replication_group_member_statsG *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier VIEW_ID: 15059231192196925:2 MEMBER_ID: ade14d5c-9e1e-11e7-b034-08002... COUNT_TRANSACTIONS_IN_QUEUE: 0 COUNT_TRANSACTIONS_CHECKED: 27992 COUNT_CONFLICTS_DETECTED: 0 COUNT_TRANSACTIONS_ROWS_VALIDATING: 0 TRANSACTIONS_COMMITTED_ALL_MEMBERS: 8fc848d7-9e1c-11e7-9407-08002... b9d01593-9dfb-11e7-8ca6-08002718d305:1-21, da2f0910-8767-11e6-b82d-08002718d305:1-164741 LAST_CONFLICT_FREE_TRANSACTION: 8fc848d7-9e1c-11e7-9407-08002... COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE: 0 COUNT_TRANSACTIONS_REMOTE_APPLIED: 27992 COUNT_TRANSACTIONS_LOCAL_PROPOSED: 0 COUNT_TRANSACTIONS_LOCAL_ROLLBACK: 0 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 111 / 145
  • 112. *************************** 2. row *************************** CHANNEL_NAME: group_replication_applier VIEW_ID: 15059231192196925:2 MEMBER_ID: b9d01593-9dfb-11e7-8ca6-08002... COUNT_TRANSACTIONS_IN_QUEUE: 0 COUNT_TRANSACTIONS_CHECKED: 28000 COUNT_CONFLICTS_DETECTED: 0 COUNT_TRANSACTIONS_ROWS_VALIDATING: 0 TRANSACTIONS_COMMITTED_ALL_MEMBERS: 8fc848d7-9e1c-11e7-9407-08002... b9d01593-9dfb-11e7-8ca6-08002718d305:1-21, da2f0910-8767-11e6-b82d-08002718d305:1-164741 LAST_CONFLICT_FREE_TRANSACTION: 8fc848d7-9e1c-11e7-9407-08002... COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE: 0 COUNT_TRANSACTIONS_REMOTE_APPLIED: 1 COUNT_TRANSACTIONS_LOCAL_PROPOSED: 28000 COUNT_TRANSACTIONS_LOCAL_ROLLBACK: 0 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 112 / 145
  • 113. 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 @ 2018 Oracle and/or its affiliates. All rights reserved. 113 / 145
  • 114. Status during recovery mysql> SHOW SLAVE STATUS FOR CHANNEL 'group_replication_recovery'G Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 114 / 145
  • 115. Status during recovery mysql> SHOW SLAVE STATUS FOR CHANNEL '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.00000 ... 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 @ 2018 Oracle and/or its affiliates. All rights reserved. 115 / 145
  • 116. 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 sys can be found at https://goo.gl/XFp3bt On the primary node: [mysql1 ˜]# scp /root/addition_to_sys_8.0.2.sql mysql3:/root [mysql3 ~]# mysql < /root/addition_to_sys_8.0.2.sql Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 116 / 145
  • 117. Sys Schema Is this node part of PRIMARY Partition: mysql3> SELECT sys.gr_member_in_primary_partition(); +------------------------------------+ | sys.gr_node_in_primary_partition() | +------------------------------------+ | YES | +------------------------------------+ Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 117 / 145
  • 118. Sys Schema Is this node part of PRIMARY Partition: mysql3> SELECT sys.gr_member_in_primary_partition(); +------------------------------------+ | sys.gr_node_in_primary_partition() | +------------------------------------+ | YES | +------------------------------------+ To use as healthcheck: mysql3> SELECT * FROM sys.gr_member_routing_candidate_status; +------------------+-----------+---------------------+----------------------+ | viable_candidate | read_only | transactions_behind | transactions_to_cert | +------------------+-----------+---------------------+----------------------+ | YES | YES | 0 | 0 | +------------------+-----------+---------------------+----------------------+ Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 118 / 145
  • 119. LAB8: Sys Schema - Health Check On one of the non Primary nodes, run the following command: mysql-sql> ush tables with read lock; Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 119 / 145
  • 120. LAB8: Sys Schema - Health Check On one of the non Primary nodes, run the following command: mysql-sql> ush tables with read lock; Now you can verify what the healthcheck exposes to you: mysql-sql> SELECT * FROM sys.gr_member_routing_candidate_status; +------------------+-----------+---------------------+----------------------+ | viable_candidate | read_only | transactions_behind | transactions_to_cert | +------------------+-----------+---------------------+----------------------+ | YES | YES | 950 | 0 | +------------------+-----------+---------------------+----------------------+ Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 120 / 145
  • 121. LAB8: Sys Schema - Health Check On one of the non Primary nodes, run the following command: mysql-sql> ush tables with read lock; Now you can verify what the healthcheck exposes to you: mysql-sql> SELECT * FROM sys.gr_member_routing_candidate_status; +------------------+-----------+---------------------+----------------------+ | viable_candidate | read_only | transactions_behind | transactions_to_cert | +------------------+-----------+---------------------+----------------------+ | YES | YES | 950 | 0 | +------------------+-----------+---------------------+----------------------+ mysql-sql> UNLOCK TABLES; Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 121 / 145
  • 122. application interaction MySQL Router Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 122 / 145
  • 123. MySQL Router MySQL Router is lightweight middleware that provides transparent routing between your application and backend MySQL Servers. It can be used for a wide variety of use cases, such as providing high availability and scalability by effectively routing database traffic to appropriate backend MySQL Servers. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 123 / 145
  • 124. MySQL Router MySQL Router is lightweight middleware that provides transparent routing between your application and backend MySQL Servers. It can be used for a wide variety of use cases, such as providing high availability and scalability by effectively routing database traffic to appropriate backend MySQL Servers. MySQL Router doesn´t require any specific configuration. It configures itself automatically (bootstrap) using MySQL InnoDB Cluster´s metadata. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 124 / 145
  • 125. LAB9: MySQL Router We will now use mysqlrouter between our application and the cluster. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 125 / 145
  • 126. LAB9: MySQL Router (2) Configure MySQL Router that will run on the app server (mysql1). We bootstrap it using the Primary-Master: [root@mysql1 ˜]# mysqlrouter --bootstrap clusteradmin@mysql3:3306 --user mysqlrouter Please enter MySQL password for clusteradmin: Bootstrapping system MySQL Router instance... Checking for old Router accounts Creating account mysql_router1_rvbecwmlc6uf@'%' MySQL Router has now been con gured for the InnoDB cluster 'perconalive'. The following connection information can be used to connect to the cluster after Classic MySQL protocol connections to cluster 'perconalive': - Read/Write Connections: localhost:6446 - Read/Only Connections: localhost:6447 X protocol connections to cluster 'perconalive': - Read/Write Connections: localhost:64460 - Read/Only Connections: localhost:64470 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 126 / 145
  • 127. LAB9: MySQL Router (3) Now let´s modify the configuration file to listen on port 3306: Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 127 / 145
  • 128. LAB9: MySQL Router (3) Now let´s modify the configuration file to listen on port 3306: in /etc/mysqlrouter/mysqlrouter.conf: [routing:perconalive_default_rw] -bind_port=6446 +bind_port=3306 Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 128 / 145
  • 129. LAB9: MySQL Router (3) Now let´s modify the configuration file to listen on port 3306: in /etc/mysqlrouter/mysqlrouter.conf: [routing:perconalive_default_rw] -bind_port=6446 +bind_port=3306 We can stop mysqld on mysql1 and start mysqlrouter: [mysql1 ~]# systemctl stop mysqld [mysql1 ~]# systemctl start mysqlrouter Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 129 / 145
  • 130. LAB9: MySQL Router (4) Before killing a member we will change systemd´s default behavior that restarts mysqld immediately: Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 130 / 145
  • 131. LAB9: MySQL Router (4) Before killing a member we will change systemd´s default behavior that restarts mysqld immediately: in /usr/lib/systemd/system/mysqld.service add the following under [Service] RestartSec=30 [mysql3 ~]# systemctl daemon-reload Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 131 / 145
  • 132. LAB9: MySQL Router (5) Now we can point the application to the router (back to mysql1): [mysql1 ~]# run_app.sh Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 132 / 145
  • 133. LAB9: MySQL Router (5) Now we can point the application to the router (back to mysql1): [mysql1 ~]# run_app.sh Check app and kill mysqld on mysql3 (the Primary Master R/W node) ! [mysql3 ~]# kill -9 $(pidof mysqld) Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 133 / 145
  • 134. LAB9: MySQL Router (5) Now we can point the application to the router (back to mysql1): [mysql1 ~]# run_app.sh Check app and kill mysqld on mysql3 (the Primary Master R/W node) ! [mysql3 ~]# kill -9 $(pidof mysqld) mysql2> select member_host as `primary` from performance_schema.replication_group_members where member_role='PRIMARY'; +----------+ | primary | +----------+ | mysql4 | +----------+ Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 134 / 145
  • 135. ProxySQL / HA Proxy / F5 / ... 3rd party router/proxy Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 135 / 145
  • 136. 3rd party router/proxy MySQL InnoDB Cluster can also work with third party router / proxy. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 136 / 145
  • 137. 3rd party router/proxy MySQL InnoDB Cluster can also work with third party router / proxy. If you need some specific features that are not yet available in MySQL Router, like transparent R/W splitting, then you can use your software of choice. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 137 / 145
  • 138. 3rd party router/proxy MySQL InnoDB Cluster can also work with third party router / proxy. If you need some specific features that are not yet available in MySQL Router, like transparent R/W splitting, then you can use your software of choice. The important part of such implementation is to use a good health check to verify if the MySQL server you plan to route the traffic is in a valid state. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 138 / 145
  • 139. 3rd party router/proxy MySQL InnoDB Cluster can also work with third party router / proxy. If you need some specific features that are not yet available in MySQL Router, like transparent R/W splitting, then you can use your software of choice. The important part of such implementation is to use a good health check to verify if the MySQL server you plan to route the traffic is in a valid state. MySQL Router implements that natively, and it´s very easy to deploy. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 139 / 145
  • 140. ProxySQL also has native support for Group Replication which makes it maybe the best choice for advanced users. 3rd party router/proxy MySQL InnoDB Cluster can also work with third party router / proxy. If you need some specific features that are not yet available in MySQL Router, like transparent R/W splitting, then you can use your software of choice. The important part of such implementation is to use a good health check to verify if the MySQL server you plan to route the traffic is in a valid state. MySQL Router implements that natively, and it´s very easy to deploy. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 140 / 145
  • 141. operational tasks Recovering Node Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 141 / 145
  • 142. Recovering Nodes/Members The old master (mysql3) got killed. Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 142 / 145
  • 143. Recovering Nodes/Members The old master (mysql3) got killed. MySQL got restarted automatically by systemd Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 143 / 145
  • 144. Recovering Nodes/Members The old master (mysql3) got killed. MySQL got restarted automatically by systemd And mysql3 joined back the cluster automatically ! Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 144 / 145
  • 145. Thank you ! Any Questions ? Copyright @ 2018 Oracle and/or its affiliates. All rights reserved. 145 / 145