SlideShare a Scribd company logo
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Creating MySQLGroup Replicaiton
with Router
Ivan Ma
馬楚成
2016-June
February Copyright 2015, Oracle
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes 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 upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Our Goal
3
Experiencing
MySQL Group Replicaiton &
MySQL Router
Experiencing
MySQL Group Replicaiton &
MySQL Router
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
4
What is Group Replication?
Group Replication Use Cases
Setting up Group Replication
Conflict Resolution
Recovery
DBA Tools
2
3
4
5
1
5
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL
Replication
Group
Replication*
Shared Disk/
Virtualization Solutions
MySQL Cluster
MySQL High Availability Solutions
99 99 .. 99 99 99 %%
5
*In Labs*In Labs
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Replication Concept
• Group Replication Strategy
• Synchronized Replication
• Topology of Group Replication
- Master-Master(s)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Group Replication (InnoDB Engine)
Group Replication
“Multi-master update anywhere replication plugin for MySQL with built-in
automaticconflict detection,distributedrecovery and group membership.”
7
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Group MySQL Replication - Active/Active Update
Anywhere
8
M M M M M
Com. API
Replication
Plugin
API
MySQL
Server
Group Comm.
System (Corosync)
Group Communication
System
Clients
ReplicationGroup
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
9
What is Group Replication?
Group Replication Use Cases
Setting up Group Replication
Conflict Resolution
Recovery
DBA Tools
2
3
4
5
1
5
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
The good thing about MySQL Group Replication
Group Replication Plugin
–Auto- Switch over
–Providing highly available database services
–Flexibility – to add or remove MySQL Nodes
10
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
The good things about MySQL Group Replication
Group Replication Plugin
–Simple Installation
–HA: If there are many server nodes ins offline status, still working
–Group Replication – All nodes provides full set of data by Replication
11
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Requirements (by Design)
• Only Support InnoDB engine
• Requires Primary Key(for rowid indentification)
• Global Transaction Identifiers (GTIDs)
• Optimistic execution: transactions may abort on COMMIT due to conflicts
with concurrent transactions on other members
12
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Full GTID support!
• All group members share the same UUID, the group name.
13
M M M M M
INSERT y;
Will have GTID: group_name:2
INSERT x;
Will have GTID: group_name:1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Full GTID support!
• Users can specify the identifier for the transaction.
14
M M M M M
INSERT y;
Will have GTID: group_name:1
SET GTID_NEXT= “UUID:50”
INSERT x;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Full GTID support!
• You can even replicate from a outside server to a group, global identifiers
will be preserved.
15
M M M M M
Conflictswill be detected!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Auto-increment configuration/handling
• Group is configured not to generate the same auto-increment value on all
members.
16
M M M M M
INSERT y;
y: 4
INSERT z;
z: 11
INSERT x;
x: 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
[1]: http://mysqlhighavailability.com/mysql-group-replication-auto-increment-configuration-handling/
Auto-increment configuration/handling
• By default, the offset is provided by server_id and increment is 7 [1].
17
M M M M M
INSERT y;
y: 4
INSERT z;
z: 11
INSERT x;
x: 1
server_id: 1
server_id: 4
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Auto-increment configuration/handling
• Users can change the increment size to their needs using
GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT option.
18
M M M M M
INSERT y;
y: 4
INSERT z;
z: 11
INSERT x;
x: 1
server_id: 1
server_id: 4
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
19
What is Group Replication?
Group Replication Use Cases
Setting Up Group Replication
Conflict Resolution
Recovery
DBA Tools
2
3
4
5
1
5
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Basics of Installing MySQL Group Replication for MySQL
• MySQL 5.7.10
• MySQL Group Replication Plugin – Lab 0.7
– MySQL Labs :: MySQL Group Replication for MySQL Server 5.7.10
– http://labs.mysql.com/
– group_replication.so / group_replication.dll
20
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Uses MySQL InnoDB Semantics
• Load the plugin and start replicating.
21
mysql> SET GLOBAL group_replication_group_name=
mysql> START
mysql> show variables like 'group_re%';
+
| Variable_name | Value |
+
| group_replication_allow_local_disjoint_gtids_join | OFF |
| group_replication_allow_local_lower_version_join | OFF |
| group_replication_auto_increment_increment | 7 |
| group_replication_bootstrap_group | OFF |
| group_replication_components_stop_timeout | 31536000 |
| group_replication_compression_threshold | 0 |
| group_replication_force_peer_addresses | |
| group_replication_group_name | 8a94f357
| group_replication_local_address | primary:4306 |
| group_replication_peer_addresses | primary:4306,primary:4316 |
| group_replication_poll_spin_loops | 0 |
| group_replication_recovery_complete_at | TRANSACTIONS_APPLIED |
| group_replication_recovery_reconnect_interval | 120 |
| group_replication_recovery_retry_count | 2 |
...
| group_replication_start_on_boot | ON |
+
24 rows in set (0.00 sec)
mysql> SET GLOBAL group_replication_group_name= "8a94f357-aab4-11df-86ab-c80aa9429562";
mysql> START GROUP_REPLICATION;
mysql> show variables like 'group_re%';
+---------------------------------------------------+--------------------------------------+
| Variable_name | Value |
+---------------------------------------------------+--------------------------------------+
| group_replication_allow_local_disjoint_gtids_join | OFF |
| group_replication_allow_local_lower_version_join | OFF |
| group_replication_auto_increment_increment | 7 |
| group_replication_bootstrap_group | OFF |
| group_replication_components_stop_timeout | 31536000 |
| group_replication_compression_threshold | 0 |
| group_replication_force_peer_addresses | |
| group_replication_group_name | 8a94f357-aab4-11df-86ab-c80aa9429562 |
| group_replication_local_address | primary:4306 |
| group_replication_peer_addresses | primary:4306,primary:4316 |
| group_replication_poll_spin_loops | 0 |
| group_replication_recovery_complete_at | TRANSACTIONS_APPLIED |
| group_replication_recovery_reconnect_interval | 120 |
| group_replication_recovery_retry_count | 2 |
...
| group_replication_start_on_boot | ON |
+---------------------------------------------------+--------------------------------------+
24 rows in set (0.00 sec)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Set Most Group Replication Variables in my.cnf
or (Startup parameters)
• The local node address (host, channel)
– /etc/hosts [ 127.0.0.1 primary ]
– Instances: primary:3306, primary:3316
• The group nodes peer addresses (a group of host and channels)
– group_replication_peer_addresses=primary:4306,primary:4316
– group_replication_local_address=primary:4306(for 3306)
– group_replication_local_address=primary:4316(for 3316)
– group_replication_recovery_user=rpl_user
– group_replication_recovery_password=rpl_pass
• Plugin location and loading plugin
22
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Sample : 3306
• [mysqld]
• datadir=/home/mysql/data
• basedir=/usr
• port=3306
• socket=/home/mysql/data/my.sock
• log-bin
• binlog-format=row
• binlog-checksum=NONE
• server-id=101
• gtid-mode=on
• enforce-gtid-consistency=true
• log-slave-updates=true
• master-info-repository=TABLE
• relay-log-info-repository=TABLE
23
• # Extraction Algorithm
• transaction-write-set-extraction=MURMUR32
• plugin-load=group_replication.so
• group_replication_group_name=8a94f357-aab4-11df-86ab-c80aa9429562
• group_replication_recovery_retry_count=2
• group_replication_recovery_reconnect_interval=120
• group_replication_local_address=primary:4306
• group_replication_peer_addresses=primary:4306,primary:4316
• group_replication_bootstrap_group=1
• group_replication_start_on_boot=0
• group_replication_recovery_user=rpl_user
• group_replication_recovery_password=rpl_pass
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Set Up Group Replication
00-createdb.sh Create the 2 databases
01-startdb.sh StartUp 2 database instances (3306 and 3316) with
standard configuration (no plugin installed)
02-mysqlupgrade.sh Not Necessary!!!
JUST IN CASE, the database does not have the latest
version from the PLUGIN.
03-createRpl.sh Create replication user on the 2 database instances
e.g. rpl_user / rpl_pass
04-restart-with-gcs.sh Restartthe 2 database instances with GROUP
REPLICATION configuration
05-setgrp.sh Set up the GROUP REPLICATION for the 2 instances
and
START GROUP_REPLICATION;
xx-chkgcs.sh <port> Check the status of the GROUP REPLICATION
24
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
00-createdb.sh
• CreateDatabase using “mysqld --initializate”
– --initialize-insecure : To initialize the database with “root” and empty password
– Initialize 2 databases
• /home/mysql/data
• /home/mysql/data2
25
rm -rf /home/mysql/data
rm -rf /home/mysql/data2
mysqld --initialize-insecure --user=mysql --
explicit_defaults_for_timestamp --basedir=/usr/local/mysql --
datadir=/home/mysql/data
mysqld --initialize-insecure --user=mysql --
explicit_defaults_for_timestamp --basedir=/usr/local/mysql --
datadir=/home/mysql/data2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• [mysqld]
• datadir=/home/mysql/data
• basedir=/usr
• port=3306
• socket=/home/mysql/data/my.sock
• log-bin
• binlog-format=row
• binlog-checksum=NONE
• server-id=101
• gtid-mode=on
• enforce-gtid-consistency=true
• log-slave-updates=true
• master-info-repository=TABLE
• relay-log-info-repository=TABLE
• transaction-write-set-extraction=MURMUR32
• [mysqld]
• datadir=/home/mysql/data2
• basedir=/usr
• port=3316
• socket=/home/mysql/data2/my.sock
• log-bin
• binlog-format=row
• binlog-checksum=NONE
• server-id=102
• gtid-mode=on
• enforce-gtid-consistency=true
• log-slave-updates=true
• master-info-repository=TABLE
• relay-log-info-repository=TABLE
• transaction-write-set-extraction=MURMUR32
26
01-startdb.sh
mysqld --defaults-file=config/my.cnf >
/home/mysql/data/my.log 2>&1 &
mysqld --defaults-file=config/my2.cnf >
/home/mysql/data2/my.log 2>&1 &
my.cnf my.2cnf
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
03-createRpl.sh
• Creating the Replication Recovery User : rpl_user / rpl_pass
• Granting the “replication slave”
27
mysql -uroot -h127.0.0.1 -P3306 -e "grant replication slave on *.* to rpl_user@'%' identified by 'rpl_pass';“
mysql -uroot -h127.0.0.1 -P3316 -e "grant replication slave on *.* to rpl_user@'%' identified by 'rpl_pass';”
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• Port = 3306
• group_replication_start_on_boot=0
• grouop_replication_bootstrap_group=1
• Port = 3316
• group_replication_start_on_boot=0
• grouop_replication_bootstrap_group=0
28
04-restart-with-gcs.sh
mysqladmin -uroot -h127.0.0.1 -P3306 shutdown
mysqladmin -uroot -h127.0.0.1 -P3316 shutdown
sleep 5
mysqld --defaults-file=config/myG1.cnf --plugin-load=group_replication.so --group_replication_bootstrap_group=1 --group-
replication_start_on_boot=0 
> /home/mysql/data/my.log 2>&1 &
mysqld --defaults-file=config/myG2.cnf --plugin-load=group_replication.so --group_replication_bootstrap_group=0 --group-
replication_start_on_boot=0 
> /home/mysql/data2/my.log 2>&1 &
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 29
MySQL Group Replication Settings
• #myG1.cnf (in addition to my.cnf) - 3306
• plugin-load=group_replication.so
• group_replication_group_name=8a94f357-aab4-11df-86ab-
c80aa9429562
• group_replication_recovery_retry_count=2
• group_replication_recovery_reconnect_interval=120
• group_replication_local_address=primary:4306
• group_replication_peer_addresses=primary:4306,primary:4316
• group_replication_bootstrap_group=1
• group_replication_start_on_boot=0
• #myG2.cnf (In addition to my2.cnf) - 3316
• plugin-load=group_replication.so
• group_replication_group_name=8a94f357-aab4-11df-86ab-
c80aa9429562
• group_replication_recovery_retry_count=2
• group_replication_recovery_reconnect_interval=120
• group_replication_local_address=primary:4316
• group_replication_peer_addresses=primary:4306,primary:4316
• group_replication_bootstrap_group=0
• group_replication_start_on_boot=0
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
05-setgrp.sh
Starting Up Group Replication (bootstrap)
• Setup the Recovery User for channel ‘group_replication_recovery’
• Start the bootstrap FIRST (3306) with setting group_replication_bootstrap_group=1
•
30
mysql -uroot -h127.0.0.1 -P3306 << EOL1
reset master;
reset slave;
SET GLOBAL group_replication_group_name= "8a94f357-aab4-11df-86ab-c80aa9429562";
SET GLOBAL group_replication_recovery_retry_count= 2;
SET GLOBAL group_replication_recovery_reconnect_interval=120;
SET GLOBAL group_replication_local_address="primary:4306";
SET GLOBAL group_replication_peer_addresses="primary:4306,primary:4316";
START GROUP_REPLICATION;
show warnings;
EOL1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
05-setgrp.sh
Starting Up Group Replication (other than bootstrap)
• Setup the Recovery User for channel ‘group_replication_recovery’
• Start other instances with setting group_replication_bootstrap_group=0
•
31
mysql -uroot -h127.0.0.1 -P3316 << EOL2
reset master;
reset slave;
SET GLOBAL group_replication_group_name= "8a94f357-aab4-11df-86ab-c80aa9429562";
SET GLOBAL group_replication_recovery_retry_count= 2;
SET GLOBAL group_replication_recovery_reconnect_interval=120;
SET GLOBAL group_replication_local_address="primary:4316";
SET GLOBAL group_replication_peer_addresses="primary:4306,primary:4316";
START GROUP_REPLICATION;
show warnings;
EOL2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
xx-chkgcs.sh <port>
32
mysql -uroot -h127.0.0.1 -P$1 << EOL2
SELECT * FROM performance_schema.replication_connection_statusG
SELECT * FROM performance_schema.replication_group_members;
SELECT * FROM performance_schema.replication_group_member_statsG
EOL2
*************************** 1. row ***************************
CHANNEL_NAME: group_replication_applier
GROUP_NAME: 8a94f357-aab4-11df-86ab-c80aa9429562
…
SERVICE_STATE: ON
…
RECEIVED_TRANSACTION_SET: 8a94f357-aab4-11df-86ab-c80aa9429562:1-8
…
*************************** 2. row ***************************
CHANNEL_NAME: group_replication_recovery
GROUP_NAME:
…
SERVICE_STATE: OFF
…
CHANNEL_NAME MEMBER_ID MEMBER_HOST MEMBER_PORT MEMBER_STATE
group_replication_applier 1ada3020-1d99-11e6-b299-080027558cda virtual-102.localhost 3306 ONLINE
group_replication_applier 1de2e5fb-1d99-11e6-b51a-080027558cda virtual-102.localhost 3316 ONLINE
*************************** 1. row ***************************
CHANNEL_NAME: group_replication_applier
VIEW_ID: 14639729171658053:8
MEMBER_ID: 1ada3020-1d99-11e6-b299-
080027558cda
COUNT_TRANSACTIONS_IN_QUEUE: 0
COUNT_TRANSACTIONS_CHECKED: 0
COUNT_CONFLICTS_DETECTED: 0
COUNT_TRANSACTIONS_VALIDATING: 0
TRANSACTIONS_COMMITTED_ALL_MEMBERS: 8a94f357-aab4-11df-86ab-
c80aa9429562:1-8
LAST_CONFLICT_FREE_TRANSACTION: 8a94f357-aab4-11df-86ab-
c80aa9429562:8
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Limitations
• Concurrent DDL is unsupported
• CTAS (Create Table As SELECT) is unsupported
– GTID Consistency (Not because of the GROUP REPLICATION)
33
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
34
What is Group Replication?
Group Replication Use Cases
Setting Up Group Replication
Conflict Resolution
Recovery
DBA Tools
2
3
4
5
1
5
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Conflict Resolution
•There is global total order for transactions
•All servers apply the same set of changes in the same
order, therefore they remain consistent within the group
–First committer wins
35
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Multi-Master: Update Anywhere
• Any two transactions on differentserverscan write to the same row
• Conflictswill automatically be detected and handled
36
M M M M M
BEGIN;
UPDATE t1 SET c1=2
WHERE C1 =0;
TRX2,node 4:
M M M M M
BEGIN;
UPDATE t1 SET c1=1
WHERE C1=0;
TRX1,node 1:
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Multi-Master: Update Anywhere
• TRX1commits
• TRX2rollbacks
37
M M M M M
COMMIT;
but Rollback
TRX2,node 4:
M M M M M
COMMIT;
TRX1,node 1:
OK
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Multi-Master: Update Anywhere
• TRX1commits
• TRX2rollbacks
38
M M M M M
BEGIN;
UPDATE t1 SET c1=2
WHERE C1 =0;
TRX2,node 4:
M M M M M
BEGIN;
UPDATE t1 SET c1=1
WHERE C1=0;
TRX1,node 1:
OK
M M M M M
Consistency!
SELECT * FROM T1;
c1 =1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Group Replication Agenda
39
What is Group Replication?
Group Replication Use Cases
Setting Up Group Replication
Conflict Resolution
Recovery
DBA Tools
2
3
4
5
1
5
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Recovery in Group Replication
•Recovery is run when a new node is added
•Recovery is run when a node that had previously been
added but has been offline comes back online
40
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Automatic Distributed Server Recovery
• Node that joins the group automatically synchronizes with other
nodes
41
M M M M M N
Setto join group
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Automatic Distributed Server Recovery
• Node that joins the group automatically synchronizes with other
nodes
42
M M M M M N
ONLINE
RECOVERING
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Automatic Distributed Server Recovery
• Node that joins the group automatically synchronized with other
nodes
43
M M M M M M
ONLINE
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
How To Check If Node is Recovering
44
mysql>
+
| CHANNEL_NAME
MEMBER_STATE |
+
| group_replication_applier | 87951d24
ONLINE
| group_replication_applier | 8cab8898
RECOVERING
mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+--------------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT |
MEMBER_STATE |
+---------------------------+--------------------------------------+--------------------------+-------------+--------------+
| group_replication_applier | 87951d24-9e08-11e5-9029-9e92014f86b5 | Kathys-MacBook-Pro.local | 3307 |
ONLINE |
| group_replication_applier | 8cab8898-9e08-11e5-9888-001772f67b84 | Kathys-MacBook-Pro.local | 3308 |
RECOVERING |
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Group Replication Agenda
45
What is Group Replication?
Group Replication Use Cases
Installing 5.7 and Group Replication Plugin
Conflict Resolution
Recovery
DBA Tools
2
3
4
5
1
6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
How To Check If Node is Online
46
mysql> START
SELECT * FROM performance_schema.replication_group_members;
+
| CHANNEL_NAME
MEMBER_STATE |
+
| group_replication_applier | 0a40c9e8
ONLINE
| group_replication_applier | 14b680b6
ONLINE
| group_replication_applier | 191e28ca
ONLINE
+
3 rows in set (0.00 sec)
mysql> START GROUP_REPLICATION;
SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+--------------------------+-------------+--------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT |
MEMBER_STATE |
+---------------------------+--------------------------------------+--------------------------+-------------+--------------+
| group_replication_applier | 0a40c9e8-9dce-11e5-b91f-a5ae79553d33 | Kathys-MacBook-Pro.local | 3308 |
ONLINE |
| group_replication_applier | 14b680b6-9dce-11e5-ab41-f8fc0628b71d | Kathys-MacBook-Pro.local | 3309 |
ONLINE |
| group_replication_applier | 191e28ca-9dce-11e5-ac10-fe18781605d5 | Kathys-MacBook-Pro.local | 3310 |
ONLINE |
+---------------------------+--------------------------------------+--------------------------+-------------+--------------+
3 rows in set (0.00 sec)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Check Settings of Group Replication
47
mysql SELECT * FROM performance_schema.replication_group_member_statsG
*************************** 1. row ***************************
1 row in set (0.00 sec)
mysql> SELECT * FROM performance_schema.replication_group_member_statsG
*************************** 1. row ***************************
CHANNEL_NAME: group_replication_applier
VIEW_ID: 235307401:3
MEMBER_ID: a236a0ec-9e9b-11e5-8be3-8b41a7829667
COUNT_TRANSACTIONS_IN_QUEUE: 0
COUNT_TRANSACTIONS_CHECKED: 12
COUNT_CONFLICTS_DETECTED: 5
COUNT_TRANSACTIONS_VALIDATING: 6
TRANSACTIONS_COMMITTED_ALL_MEMBERS:
LAST_CONFLICT_FREE_TRANSACTION: 8a94f357-aab4-11df-86ab-c80aa9429562:3
1 row in set (0.00 sec)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Disaster Recovery
Backup and Restore
High Availability
MySQL Enterprise Edition – Business
Durability
48
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
And More
Security
Monitoring
Backup
24x7 Support
MySQL Enterprise
Engineering
49
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Learn More
http://mysqlhighavailability.com/tag/mysql-group-replication/
• MySQL Group Replication Install Information
• News/Updates
• Blogs
http://labs.mysql.com
• Download and evaluate all MySQL Group Replication from
the labs
50
Hkosc group replication-lecture_lab07

More Related Content

PDF
Why MySQL High Availability Matters
PDF
MySQL InnoDB Cluster / ReplicaSet - Tutorial
PDF
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
PDF
MySQL High Availability with Group Replication
PPTX
MySQL 8.0 Released Update
PDF
MySQL InnoDB Cluster HA Overview & Demo
PDF
MySQL User Camp: GTIDs
PDF
FOSSASIA 2015: MySQL Group Replication
Why MySQL High Availability Matters
MySQL InnoDB Cluster / ReplicaSet - Tutorial
MySQL InnoDB Cluster and MySQL Group Replication @HKOSC 2017
MySQL High Availability with Group Replication
MySQL 8.0 Released Update
MySQL InnoDB Cluster HA Overview & Demo
MySQL User Camp: GTIDs
FOSSASIA 2015: MySQL Group Replication

What's hot (20)

PDF
MySQL Replication Performance Tuning for Fun and Profit!
PDF
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
PDF
MySQL Replication Performance in the Cloud
PDF
Sharding and Scale-out using MySQL Fabric
PDF
MySQL 8.0 InnoDB Cluster demo
PDF
Everything You Need to Know About MySQL Group Replication
PDF
MySQL Enterprise Edition - Complete Guide (2019)
PDF
MySQL Developer Day conference: MySQL Replication and Scalability
PDF
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
PDF
Unlocking Big Data Insights with MySQL
PDF
MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...
PDF
Oracle Database In-Memory Meets Oracle RAC
PDF
Mysql User Camp : 20th June - Mysql New Features
PDF
Oracle RAC BP for Upgrade & More by Anil Nair and Markus Michalewicz
PDF
MySQL sys schema deep dive
PDF
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
PDF
Oracle RAC - Customer Proven Scalability
PDF
MySQL Technology Overview
PDF
Oracle Database Cloud Fleet Maintenance
PDF
MySQL Group Replication - HandsOn Tutorial
MySQL Replication Performance Tuning for Fun and Profit!
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
MySQL Replication Performance in the Cloud
Sharding and Scale-out using MySQL Fabric
MySQL 8.0 InnoDB Cluster demo
Everything You Need to Know About MySQL Group Replication
MySQL Enterprise Edition - Complete Guide (2019)
MySQL Developer Day conference: MySQL Replication and Scalability
MySQL InnoDB Cluster: Management and Troubleshooting with MySQL Shell
Unlocking Big Data Insights with MySQL
MySQL InnoDB Cluster / ReplicaSet - Making Provisioning & Troubleshooting as ...
Oracle Database In-Memory Meets Oracle RAC
Mysql User Camp : 20th June - Mysql New Features
Oracle RAC BP for Upgrade & More by Anil Nair and Markus Michalewicz
MySQL sys schema deep dive
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
Oracle RAC - Customer Proven Scalability
MySQL Technology Overview
Oracle Database Cloud Fleet Maintenance
MySQL Group Replication - HandsOn Tutorial
Ad

Similar to Hkosc group replication-lecture_lab07 (20)

PDF
MySQL Group Replication - an Overview
PDF
MySQL Group Replication
PPTX
ConFoo MySQL Replication Evolution : From Simple to Group Replication
PDF
MySQL Replication Update -- Zendcon 2016
PDF
Confoo 202 - MySQL Group Replication and ReplicaSet
PDF
MySQL Replication Basics -Ohio Linux Fest 2016
PPTX
MySQL Replication Evolution -- Confoo Montreal 2017
PDF
MySQL 5.6 Replication Webinar
ODP
MySQL 101 PHPTek 2017
PDF
MySQL Group Replication
PDF
MySQL Group Replication
PPTX
MySQL Replication Overview -- PHPTek 2016
PDF
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
PDF
MySQL InnoDB Cluster: High Availability Made Easy!
PDF
Replication Whats New in Mysql 8
PDF
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...
PPTX
Migrate your EOL MySQL servers to HA Complaint GR Cluster / InnoDB Cluster Wi...
PDF
MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...
PDF
Evolution of MySQL Parallel Replication
PDF
MySQL InnoDB Cluster and Group Replication - OSI 2017 Bangalore
MySQL Group Replication - an Overview
MySQL Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group Replication
MySQL Replication Update -- Zendcon 2016
Confoo 202 - MySQL Group Replication and ReplicaSet
MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL 5.6 Replication Webinar
MySQL 101 PHPTek 2017
MySQL Group Replication
MySQL Group Replication
MySQL Replication Overview -- PHPTek 2016
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
MySQL InnoDB Cluster: High Availability Made Easy!
Replication Whats New in Mysql 8
DataOpsbarcelona 2019: Deep dive into MySQL Group Replication... the magic e...
Migrate your EOL MySQL servers to HA Complaint GR Cluster / InnoDB Cluster Wi...
MySQL innodb cluster and Group Replication in a nutshell - hands-on tutorial ...
Evolution of MySQL Parallel Replication
MySQL InnoDB Cluster and Group Replication - OSI 2017 Bangalore
Ad

More from Ivan Ma (16)

PDF
Exploring MySQL Operator for Kubernetes in Python
PDF
20201106 hk-py con-mysql-shell
PDF
20200613 my sql-ha-deployment
PDF
20191001 bkk-secret-of inno-db_clusterv1
PDF
20190817 coscup-oracle my sql innodb cluster sharing
PDF
20190615 hkos-mysql-troubleshootingandperformancev2
PDF
20180420 hk-the powerofmysql8
PDF
20171104 hk-py con-mysql-documentstore_v1
PDF
What's New in MySQL 8.0 @ HKOSC 2017
PDF
20161029 py con-mysq-lv3
PDF
20160821 coscup-my sql57docstorelab01
PDF
20151010 my sq-landjavav2a
PDF
01 demystifying mysq-lfororacledbaanddeveloperv1
PDF
Exploring mysql cluster 7.4
PDF
20150110 my sql-performanceschema
PDF
20141011 my sql clusterv01pptx
Exploring MySQL Operator for Kubernetes in Python
20201106 hk-py con-mysql-shell
20200613 my sql-ha-deployment
20191001 bkk-secret-of inno-db_clusterv1
20190817 coscup-oracle my sql innodb cluster sharing
20190615 hkos-mysql-troubleshootingandperformancev2
20180420 hk-the powerofmysql8
20171104 hk-py con-mysql-documentstore_v1
What's New in MySQL 8.0 @ HKOSC 2017
20161029 py con-mysq-lv3
20160821 coscup-my sql57docstorelab01
20151010 my sq-landjavav2a
01 demystifying mysq-lfororacledbaanddeveloperv1
Exploring mysql cluster 7.4
20150110 my sql-performanceschema
20141011 my sql clusterv01pptx

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
Teaching material agriculture food technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
MYSQL Presentation for SQL database connectivity
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Cloud computing and distributed systems.
Review of recent advances in non-invasive hemoglobin estimation
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced methodologies resolving dimensionality complications for autism neur...
20250228 LYD VKU AI Blended-Learning.pptx
Teaching material agriculture food technology
Dropbox Q2 2025 Financial Results & Investor Presentation
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
MYSQL Presentation for SQL database connectivity
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Machine learning based COVID-19 study performance prediction
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25 Week I
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Cloud computing and distributed systems.

Hkosc group replication-lecture_lab07

  • 1. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Creating MySQLGroup Replicaiton with Router Ivan Ma 馬楚成 2016-June February Copyright 2015, Oracle
  • 2. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes 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 upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 2
  • 3. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Our Goal 3 Experiencing MySQL Group Replicaiton & MySQL Router Experiencing MySQL Group Replicaiton & MySQL Router
  • 4. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Program Agenda 4 What is Group Replication? Group Replication Use Cases Setting up Group Replication Conflict Resolution Recovery DBA Tools 2 3 4 5 1 5
  • 5. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL Replication Group Replication* Shared Disk/ Virtualization Solutions MySQL Cluster MySQL High Availability Solutions 99 99 .. 99 99 99 %% 5 *In Labs*In Labs
  • 6. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Replication Concept • Group Replication Strategy • Synchronized Replication • Topology of Group Replication - Master-Master(s)
  • 7. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL Group Replication (InnoDB Engine) Group Replication “Multi-master update anywhere replication plugin for MySQL with built-in automaticconflict detection,distributedrecovery and group membership.” 7
  • 8. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Group MySQL Replication - Active/Active Update Anywhere 8 M M M M M Com. API Replication Plugin API MySQL Server Group Comm. System (Corosync) Group Communication System Clients ReplicationGroup
  • 9. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Program Agenda 9 What is Group Replication? Group Replication Use Cases Setting up Group Replication Conflict Resolution Recovery DBA Tools 2 3 4 5 1 5
  • 10. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | The good thing about MySQL Group Replication Group Replication Plugin –Auto- Switch over –Providing highly available database services –Flexibility – to add or remove MySQL Nodes 10
  • 11. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | The good things about MySQL Group Replication Group Replication Plugin –Simple Installation –HA: If there are many server nodes ins offline status, still working –Group Replication – All nodes provides full set of data by Replication 11
  • 12. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Requirements (by Design) • Only Support InnoDB engine • Requires Primary Key(for rowid indentification) • Global Transaction Identifiers (GTIDs) • Optimistic execution: transactions may abort on COMMIT due to conflicts with concurrent transactions on other members 12
  • 13. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Full GTID support! • All group members share the same UUID, the group name. 13 M M M M M INSERT y; Will have GTID: group_name:2 INSERT x; Will have GTID: group_name:1
  • 14. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Full GTID support! • Users can specify the identifier for the transaction. 14 M M M M M INSERT y; Will have GTID: group_name:1 SET GTID_NEXT= “UUID:50” INSERT x;
  • 15. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Full GTID support! • You can even replicate from a outside server to a group, global identifiers will be preserved. 15 M M M M M Conflictswill be detected!
  • 16. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Auto-increment configuration/handling • Group is configured not to generate the same auto-increment value on all members. 16 M M M M M INSERT y; y: 4 INSERT z; z: 11 INSERT x; x: 1
  • 17. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | [1]: http://mysqlhighavailability.com/mysql-group-replication-auto-increment-configuration-handling/ Auto-increment configuration/handling • By default, the offset is provided by server_id and increment is 7 [1]. 17 M M M M M INSERT y; y: 4 INSERT z; z: 11 INSERT x; x: 1 server_id: 1 server_id: 4
  • 18. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Auto-increment configuration/handling • Users can change the increment size to their needs using GROUP_REPLICATION_AUTO_INCREMENT_INCREMENT option. 18 M M M M M INSERT y; y: 4 INSERT z; z: 11 INSERT x; x: 1 server_id: 1 server_id: 4
  • 19. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Program Agenda 19 What is Group Replication? Group Replication Use Cases Setting Up Group Replication Conflict Resolution Recovery DBA Tools 2 3 4 5 1 5
  • 20. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Basics of Installing MySQL Group Replication for MySQL • MySQL 5.7.10 • MySQL Group Replication Plugin – Lab 0.7 – MySQL Labs :: MySQL Group Replication for MySQL Server 5.7.10 – http://labs.mysql.com/ – group_replication.so / group_replication.dll 20
  • 21. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Uses MySQL InnoDB Semantics • Load the plugin and start replicating. 21 mysql> SET GLOBAL group_replication_group_name= mysql> START mysql> show variables like 'group_re%'; + | Variable_name | Value | + | group_replication_allow_local_disjoint_gtids_join | OFF | | group_replication_allow_local_lower_version_join | OFF | | group_replication_auto_increment_increment | 7 | | group_replication_bootstrap_group | OFF | | group_replication_components_stop_timeout | 31536000 | | group_replication_compression_threshold | 0 | | group_replication_force_peer_addresses | | | group_replication_group_name | 8a94f357 | group_replication_local_address | primary:4306 | | group_replication_peer_addresses | primary:4306,primary:4316 | | group_replication_poll_spin_loops | 0 | | group_replication_recovery_complete_at | TRANSACTIONS_APPLIED | | group_replication_recovery_reconnect_interval | 120 | | group_replication_recovery_retry_count | 2 | ... | group_replication_start_on_boot | ON | + 24 rows in set (0.00 sec) mysql> SET GLOBAL group_replication_group_name= "8a94f357-aab4-11df-86ab-c80aa9429562"; mysql> START GROUP_REPLICATION; mysql> show variables like 'group_re%'; +---------------------------------------------------+--------------------------------------+ | Variable_name | Value | +---------------------------------------------------+--------------------------------------+ | group_replication_allow_local_disjoint_gtids_join | OFF | | group_replication_allow_local_lower_version_join | OFF | | group_replication_auto_increment_increment | 7 | | group_replication_bootstrap_group | OFF | | group_replication_components_stop_timeout | 31536000 | | group_replication_compression_threshold | 0 | | group_replication_force_peer_addresses | | | group_replication_group_name | 8a94f357-aab4-11df-86ab-c80aa9429562 | | group_replication_local_address | primary:4306 | | group_replication_peer_addresses | primary:4306,primary:4316 | | group_replication_poll_spin_loops | 0 | | group_replication_recovery_complete_at | TRANSACTIONS_APPLIED | | group_replication_recovery_reconnect_interval | 120 | | group_replication_recovery_retry_count | 2 | ... | group_replication_start_on_boot | ON | +---------------------------------------------------+--------------------------------------+ 24 rows in set (0.00 sec)
  • 22. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Set Most Group Replication Variables in my.cnf or (Startup parameters) • The local node address (host, channel) – /etc/hosts [ 127.0.0.1 primary ] – Instances: primary:3306, primary:3316 • The group nodes peer addresses (a group of host and channels) – group_replication_peer_addresses=primary:4306,primary:4316 – group_replication_local_address=primary:4306(for 3306) – group_replication_local_address=primary:4316(for 3316) – group_replication_recovery_user=rpl_user – group_replication_recovery_password=rpl_pass • Plugin location and loading plugin 22
  • 23. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Sample : 3306 • [mysqld] • datadir=/home/mysql/data • basedir=/usr • port=3306 • socket=/home/mysql/data/my.sock • log-bin • binlog-format=row • binlog-checksum=NONE • server-id=101 • gtid-mode=on • enforce-gtid-consistency=true • log-slave-updates=true • master-info-repository=TABLE • relay-log-info-repository=TABLE 23 • # Extraction Algorithm • transaction-write-set-extraction=MURMUR32 • plugin-load=group_replication.so • group_replication_group_name=8a94f357-aab4-11df-86ab-c80aa9429562 • group_replication_recovery_retry_count=2 • group_replication_recovery_reconnect_interval=120 • group_replication_local_address=primary:4306 • group_replication_peer_addresses=primary:4306,primary:4316 • group_replication_bootstrap_group=1 • group_replication_start_on_boot=0 • group_replication_recovery_user=rpl_user • group_replication_recovery_password=rpl_pass
  • 24. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Set Up Group Replication 00-createdb.sh Create the 2 databases 01-startdb.sh StartUp 2 database instances (3306 and 3316) with standard configuration (no plugin installed) 02-mysqlupgrade.sh Not Necessary!!! JUST IN CASE, the database does not have the latest version from the PLUGIN. 03-createRpl.sh Create replication user on the 2 database instances e.g. rpl_user / rpl_pass 04-restart-with-gcs.sh Restartthe 2 database instances with GROUP REPLICATION configuration 05-setgrp.sh Set up the GROUP REPLICATION for the 2 instances and START GROUP_REPLICATION; xx-chkgcs.sh <port> Check the status of the GROUP REPLICATION 24
  • 25. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 00-createdb.sh • CreateDatabase using “mysqld --initializate” – --initialize-insecure : To initialize the database with “root” and empty password – Initialize 2 databases • /home/mysql/data • /home/mysql/data2 25 rm -rf /home/mysql/data rm -rf /home/mysql/data2 mysqld --initialize-insecure --user=mysql -- explicit_defaults_for_timestamp --basedir=/usr/local/mysql -- datadir=/home/mysql/data mysqld --initialize-insecure --user=mysql -- explicit_defaults_for_timestamp --basedir=/usr/local/mysql -- datadir=/home/mysql/data2
  • 26. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | • [mysqld] • datadir=/home/mysql/data • basedir=/usr • port=3306 • socket=/home/mysql/data/my.sock • log-bin • binlog-format=row • binlog-checksum=NONE • server-id=101 • gtid-mode=on • enforce-gtid-consistency=true • log-slave-updates=true • master-info-repository=TABLE • relay-log-info-repository=TABLE • transaction-write-set-extraction=MURMUR32 • [mysqld] • datadir=/home/mysql/data2 • basedir=/usr • port=3316 • socket=/home/mysql/data2/my.sock • log-bin • binlog-format=row • binlog-checksum=NONE • server-id=102 • gtid-mode=on • enforce-gtid-consistency=true • log-slave-updates=true • master-info-repository=TABLE • relay-log-info-repository=TABLE • transaction-write-set-extraction=MURMUR32 26 01-startdb.sh mysqld --defaults-file=config/my.cnf > /home/mysql/data/my.log 2>&1 & mysqld --defaults-file=config/my2.cnf > /home/mysql/data2/my.log 2>&1 & my.cnf my.2cnf
  • 27. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 03-createRpl.sh • Creating the Replication Recovery User : rpl_user / rpl_pass • Granting the “replication slave” 27 mysql -uroot -h127.0.0.1 -P3306 -e "grant replication slave on *.* to rpl_user@'%' identified by 'rpl_pass';“ mysql -uroot -h127.0.0.1 -P3316 -e "grant replication slave on *.* to rpl_user@'%' identified by 'rpl_pass';”
  • 28. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | • Port = 3306 • group_replication_start_on_boot=0 • grouop_replication_bootstrap_group=1 • Port = 3316 • group_replication_start_on_boot=0 • grouop_replication_bootstrap_group=0 28 04-restart-with-gcs.sh mysqladmin -uroot -h127.0.0.1 -P3306 shutdown mysqladmin -uroot -h127.0.0.1 -P3316 shutdown sleep 5 mysqld --defaults-file=config/myG1.cnf --plugin-load=group_replication.so --group_replication_bootstrap_group=1 --group- replication_start_on_boot=0 > /home/mysql/data/my.log 2>&1 & mysqld --defaults-file=config/myG2.cnf --plugin-load=group_replication.so --group_replication_bootstrap_group=0 --group- replication_start_on_boot=0 > /home/mysql/data2/my.log 2>&1 &
  • 29. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 29 MySQL Group Replication Settings • #myG1.cnf (in addition to my.cnf) - 3306 • plugin-load=group_replication.so • group_replication_group_name=8a94f357-aab4-11df-86ab- c80aa9429562 • group_replication_recovery_retry_count=2 • group_replication_recovery_reconnect_interval=120 • group_replication_local_address=primary:4306 • group_replication_peer_addresses=primary:4306,primary:4316 • group_replication_bootstrap_group=1 • group_replication_start_on_boot=0 • #myG2.cnf (In addition to my2.cnf) - 3316 • plugin-load=group_replication.so • group_replication_group_name=8a94f357-aab4-11df-86ab- c80aa9429562 • group_replication_recovery_retry_count=2 • group_replication_recovery_reconnect_interval=120 • group_replication_local_address=primary:4316 • group_replication_peer_addresses=primary:4306,primary:4316 • group_replication_bootstrap_group=0 • group_replication_start_on_boot=0
  • 30. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 05-setgrp.sh Starting Up Group Replication (bootstrap) • Setup the Recovery User for channel ‘group_replication_recovery’ • Start the bootstrap FIRST (3306) with setting group_replication_bootstrap_group=1 • 30 mysql -uroot -h127.0.0.1 -P3306 << EOL1 reset master; reset slave; SET GLOBAL group_replication_group_name= "8a94f357-aab4-11df-86ab-c80aa9429562"; SET GLOBAL group_replication_recovery_retry_count= 2; SET GLOBAL group_replication_recovery_reconnect_interval=120; SET GLOBAL group_replication_local_address="primary:4306"; SET GLOBAL group_replication_peer_addresses="primary:4306,primary:4316"; START GROUP_REPLICATION; show warnings; EOL1
  • 31. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 05-setgrp.sh Starting Up Group Replication (other than bootstrap) • Setup the Recovery User for channel ‘group_replication_recovery’ • Start other instances with setting group_replication_bootstrap_group=0 • 31 mysql -uroot -h127.0.0.1 -P3316 << EOL2 reset master; reset slave; SET GLOBAL group_replication_group_name= "8a94f357-aab4-11df-86ab-c80aa9429562"; SET GLOBAL group_replication_recovery_retry_count= 2; SET GLOBAL group_replication_recovery_reconnect_interval=120; SET GLOBAL group_replication_local_address="primary:4316"; SET GLOBAL group_replication_peer_addresses="primary:4306,primary:4316"; START GROUP_REPLICATION; show warnings; EOL2
  • 32. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | xx-chkgcs.sh <port> 32 mysql -uroot -h127.0.0.1 -P$1 << EOL2 SELECT * FROM performance_schema.replication_connection_statusG SELECT * FROM performance_schema.replication_group_members; SELECT * FROM performance_schema.replication_group_member_statsG EOL2 *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier GROUP_NAME: 8a94f357-aab4-11df-86ab-c80aa9429562 … SERVICE_STATE: ON … RECEIVED_TRANSACTION_SET: 8a94f357-aab4-11df-86ab-c80aa9429562:1-8 … *************************** 2. row *************************** CHANNEL_NAME: group_replication_recovery GROUP_NAME: … SERVICE_STATE: OFF … CHANNEL_NAME MEMBER_ID MEMBER_HOST MEMBER_PORT MEMBER_STATE group_replication_applier 1ada3020-1d99-11e6-b299-080027558cda virtual-102.localhost 3306 ONLINE group_replication_applier 1de2e5fb-1d99-11e6-b51a-080027558cda virtual-102.localhost 3316 ONLINE *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier VIEW_ID: 14639729171658053:8 MEMBER_ID: 1ada3020-1d99-11e6-b299- 080027558cda COUNT_TRANSACTIONS_IN_QUEUE: 0 COUNT_TRANSACTIONS_CHECKED: 0 COUNT_CONFLICTS_DETECTED: 0 COUNT_TRANSACTIONS_VALIDATING: 0 TRANSACTIONS_COMMITTED_ALL_MEMBERS: 8a94f357-aab4-11df-86ab- c80aa9429562:1-8 LAST_CONFLICT_FREE_TRANSACTION: 8a94f357-aab4-11df-86ab- c80aa9429562:8
  • 33. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Limitations • Concurrent DDL is unsupported • CTAS (Create Table As SELECT) is unsupported – GTID Consistency (Not because of the GROUP REPLICATION) 33
  • 34. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Program Agenda 34 What is Group Replication? Group Replication Use Cases Setting Up Group Replication Conflict Resolution Recovery DBA Tools 2 3 4 5 1 5
  • 35. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Conflict Resolution •There is global total order for transactions •All servers apply the same set of changes in the same order, therefore they remain consistent within the group –First committer wins 35
  • 36. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Multi-Master: Update Anywhere • Any two transactions on differentserverscan write to the same row • Conflictswill automatically be detected and handled 36 M M M M M BEGIN; UPDATE t1 SET c1=2 WHERE C1 =0; TRX2,node 4: M M M M M BEGIN; UPDATE t1 SET c1=1 WHERE C1=0; TRX1,node 1:
  • 37. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Multi-Master: Update Anywhere • TRX1commits • TRX2rollbacks 37 M M M M M COMMIT; but Rollback TRX2,node 4: M M M M M COMMIT; TRX1,node 1: OK
  • 38. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Multi-Master: Update Anywhere • TRX1commits • TRX2rollbacks 38 M M M M M BEGIN; UPDATE t1 SET c1=2 WHERE C1 =0; TRX2,node 4: M M M M M BEGIN; UPDATE t1 SET c1=1 WHERE C1=0; TRX1,node 1: OK M M M M M Consistency! SELECT * FROM T1; c1 =1
  • 39. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Group Replication Agenda 39 What is Group Replication? Group Replication Use Cases Setting Up Group Replication Conflict Resolution Recovery DBA Tools 2 3 4 5 1 5
  • 40. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Recovery in Group Replication •Recovery is run when a new node is added •Recovery is run when a node that had previously been added but has been offline comes back online 40
  • 41. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Automatic Distributed Server Recovery • Node that joins the group automatically synchronizes with other nodes 41 M M M M M N Setto join group
  • 42. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Automatic Distributed Server Recovery • Node that joins the group automatically synchronizes with other nodes 42 M M M M M N ONLINE RECOVERING
  • 43. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Automatic Distributed Server Recovery • Node that joins the group automatically synchronized with other nodes 43 M M M M M M ONLINE
  • 44. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | How To Check If Node is Recovering 44 mysql> + | CHANNEL_NAME MEMBER_STATE | + | group_replication_applier | 87951d24 ONLINE | group_replication_applier | 8cab8898 RECOVERING mysql> SELECT * FROM performance_schema.replication_group_members; +---------------------------+--------------------------------------+--------------------------+-------------+--------------+ | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | +---------------------------+--------------------------------------+--------------------------+-------------+--------------+ | group_replication_applier | 87951d24-9e08-11e5-9029-9e92014f86b5 | Kathys-MacBook-Pro.local | 3307 | ONLINE | | group_replication_applier | 8cab8898-9e08-11e5-9888-001772f67b84 | Kathys-MacBook-Pro.local | 3308 | RECOVERING |
  • 45. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Group Replication Agenda 45 What is Group Replication? Group Replication Use Cases Installing 5.7 and Group Replication Plugin Conflict Resolution Recovery DBA Tools 2 3 4 5 1 6
  • 46. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | How To Check If Node is Online 46 mysql> START SELECT * FROM performance_schema.replication_group_members; + | CHANNEL_NAME MEMBER_STATE | + | group_replication_applier | 0a40c9e8 ONLINE | group_replication_applier | 14b680b6 ONLINE | group_replication_applier | 191e28ca ONLINE + 3 rows in set (0.00 sec) mysql> START GROUP_REPLICATION; SELECT * FROM performance_schema.replication_group_members; +---------------------------+--------------------------------------+--------------------------+-------------+--------------+ | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | +---------------------------+--------------------------------------+--------------------------+-------------+--------------+ | group_replication_applier | 0a40c9e8-9dce-11e5-b91f-a5ae79553d33 | Kathys-MacBook-Pro.local | 3308 | ONLINE | | group_replication_applier | 14b680b6-9dce-11e5-ab41-f8fc0628b71d | Kathys-MacBook-Pro.local | 3309 | ONLINE | | group_replication_applier | 191e28ca-9dce-11e5-ac10-fe18781605d5 | Kathys-MacBook-Pro.local | 3310 | ONLINE | +---------------------------+--------------------------------------+--------------------------+-------------+--------------+ 3 rows in set (0.00 sec)
  • 47. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Check Settings of Group Replication 47 mysql SELECT * FROM performance_schema.replication_group_member_statsG *************************** 1. row *************************** 1 row in set (0.00 sec) mysql> SELECT * FROM performance_schema.replication_group_member_statsG *************************** 1. row *************************** CHANNEL_NAME: group_replication_applier VIEW_ID: 235307401:3 MEMBER_ID: a236a0ec-9e9b-11e5-8be3-8b41a7829667 COUNT_TRANSACTIONS_IN_QUEUE: 0 COUNT_TRANSACTIONS_CHECKED: 12 COUNT_CONFLICTS_DETECTED: 5 COUNT_TRANSACTIONS_VALIDATING: 6 TRANSACTIONS_COMMITTED_ALL_MEMBERS: LAST_CONFLICT_FREE_TRANSACTION: 8a94f357-aab4-11df-86ab-c80aa9429562:3 1 row in set (0.00 sec)
  • 48. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Disaster Recovery Backup and Restore High Availability MySQL Enterprise Edition – Business Durability 48
  • 49. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | And More Security Monitoring Backup 24x7 Support MySQL Enterprise Engineering 49
  • 50. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Learn More http://mysqlhighavailability.com/tag/mysql-group-replication/ • MySQL Group Replication Install Information • News/Updates • Blogs http://labs.mysql.com • Download and evaluate all MySQL Group Replication from the labs 50