126
1 / 126

MySQL InnoDB Cluster - Group Replication

Embed Size (px)

Citation preview

Page 1: MySQL InnoDB Cluster - Group Replication

1 / 126

Page 2: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication in a nutshell

the core of MySQL InnoDB Cluster

 

Oracle Open World

September 19th 2016

 

Frédéric Descamps

MySQL Community Manager

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

2 / 126

Page 3: MySQL InnoDB Cluster - Group Replication

 

Safe Harbor StatementThe following is intended to outline our general product direction. It is intended forinformation purpose only, and may not be incorporated into any contract. It is not acommitment to deliver any material, code, or functionality, and should not be relied up inmaking purchasing decisions. The development, release and timing of any features orfunctionality described for Oracle's product remains at the sole discretion of Oracle.

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

3 / 126

Page 4: MySQL InnoDB Cluster - Group Replication

Join us!

MySQL Community Reception @ OracleOpenWorld

Celebrate, Have Fun and Mingle with Oracle’s MySQL Engineers & Your Peers

Tuesday, September 20, 7.00 pmJillian’s at Metreon: 175 Fourth Street, San Francisco

At the corner of Howard and 4th st.; only 2-min walk from Moscone Center (sameplace as last year)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

4 / 126

Page 5: MySQL InnoDB Cluster - Group Replication

about.me/lefred

Who am I ?

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

5 / 126

Page 6: MySQL InnoDB Cluster - Group Replication

Frédéric Descamps@lefredMySQL EvangelistManaging MySQL since 3.23devops believer

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

6 / 126

Page 7: MySQL InnoDB Cluster - Group Replication

get more at the conference

MySQL Group Replication

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

7 / 126

Page 8: MySQL InnoDB Cluster - Group Replication

Other sessionsCON2907 - MySQL High AvailabilityMatt LordCON4669 - MySQL High Availability with Group ReplicationNuno GomesCON3373 - The State of the Art of MySQL ReplicationLuis SoaresHOL2912 - Building a Highly Available MySQL Database Service with Group ReplicationMatt Lord

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

8 / 126

Page 9: MySQL InnoDB Cluster - Group Replication

AgendaGroup Replication concepts

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

9 / 126

Page 10: MySQL InnoDB Cluster - Group Replication

AgendaGroup Replication conceptsUsing new & cool tools

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

10 / 126

Page 11: MySQL InnoDB Cluster - Group Replication

AgendaGroup Replication conceptsUsing new & cool toolsApplication interaction

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

11 / 126

Page 12: MySQL InnoDB Cluster - Group Replication

the magic explained

Group Replication Concept

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

12 / 126

Page 13: MySQL InnoDB Cluster - Group Replication

Group Replication : what is it ?

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

13 / 126

Page 14: MySQL InnoDB Cluster - Group Replication

Group Replication : what is it ?MySQL is one of the major components of MySQL InnoDB Cluster

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

14 / 126

Page 15: MySQL InnoDB Cluster - Group Replication

Group Replication : what is it ?MySQL is one of the major components of MySQL InnoDB Cluster  

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

15 / 126

Page 16: MySQL InnoDB Cluster - Group Replication

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

16 / 126

Page 17: MySQL InnoDB Cluster - Group Replication

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

17 / 126

Page 18: MySQL InnoDB Cluster - Group Replication

Group replication is a plugin !

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

18 / 126

Page 19: MySQL InnoDB Cluster - Group Replication

Group replication is a plugin !GR is a plugin for MySQL, made by MySQL and packaged with MySQL

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

19 / 126

Page 20: MySQL InnoDB Cluster - Group Replication

Group replication is a plugin !GR is a plugin for MySQL, made by MySQL and packaged with MySQLGR is an implementation of Replicated Database State Machine theory

MySQL Group Communication System (GCS) is based on Paxos

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

20 / 126

Page 21: MySQL InnoDB Cluster - Group Replication

Group replication is a plugin !GR is a plugin for MySQL, made by MySQL and packaged with MySQLGR is an implementation of Replicated Database State Machine theory

MySQL Group Communication System (GCS) is based on PaxosProvides virtually synchronous replication for MySQL 5.7+

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

21 / 126

Page 22: MySQL InnoDB Cluster - Group Replication

Group replication is a plugin !GR is a plugin for MySQL, made by MySQL and packaged with MySQLGR is an implementation of Replicated Database State Machine theory

MySQL Group Communication System (GCS) is based on PaxosProvides virtually synchronous replication for MySQL 5.7+Supported on all MySQL platforms !!

Linux, Windows, Solaris, OSX, FreeBSD

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

22 / 126

Page 23: MySQL InnoDB Cluster - Group Replication

 

 

 

“Multi-master update anywhere replication plugin for MySQL with built-in conflictdetection and resolution, automatic distributed recovery, and group membership.”

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

23 / 126

Page 24: MySQL InnoDB Cluster - Group Replication

Group Replication : how does it work ?

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

24 / 126

Page 25: MySQL InnoDB Cluster - Group Replication

Group Replication : how does it work ?A node (member of the group) send the changes (binlog events) made by atransaction to the group through the GCS.

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

25 / 126

Page 26: MySQL InnoDB Cluster - Group Replication

Group Replication : how does it work ?A node (member of the group) send the changes (binlog events) made by atransaction to the group through the GCS.All members consume the writeset and certify it

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

26 / 126

Page 27: MySQL InnoDB Cluster - Group Replication

Group Replication : how does it work ?A node (member of the group) send the changes (binlog events) made by atransaction to the group through the GCS.All members consume the writeset and certify itIf passed it is applied, if failed, transaction is rolled back on originating server anddiscarded at other servers.

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

27 / 126

Page 28: MySQL InnoDB Cluster - Group Replication

OK... but how does it work ?!

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

28 / 126

Page 29: MySQL InnoDB Cluster - Group Replication

OK... but how does it work ?!It's just magic !

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

29 / 126

Page 30: MySQL InnoDB Cluster - Group Replication

OK... but how does it work ?!It's just magic !

... no, in fact the writesets replication is synchronous and then certification and apply ofthe changes are local to each nodes and asynchronous.

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

30 / 126

Page 31: MySQL InnoDB Cluster - Group Replication

OK... but how does it work ?!It's just magic !

... no, in fact the writesets replication is synchronous and then certification and apply ofthe changes are local to each nodes and asynchronous.

not that easy to understand... right ? Let's illustrate this...

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

31 / 126

Page 32: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (autocommit)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

32 / 126

Page 33: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (autocommit)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

33 / 126

Page 34: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (autocommit)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

34 / 126

Page 35: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (autocommit)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

35 / 126

Page 36: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (autocommit)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

36 / 126

Page 37: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (autocommit)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

37 / 126

Page 38: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (autocommit)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

38 / 126

Page 39: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (full transaction)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

39 / 126

Page 40: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (full transaction)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

40 / 126

Page 41: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (full transaction)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

41 / 126

Page 42: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (full transaction)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

42 / 126

Page 43: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (full transaction)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

43 / 126

Page 44: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (full transaction)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

44 / 126

Page 45: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (full transaction)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

45 / 126

Page 46: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (full transaction)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

46 / 126

Page 47: MySQL InnoDB Cluster - Group Replication

MySQL Group Replication (full transaction)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

47 / 126

Page 48: MySQL InnoDB Cluster - Group Replication

Group Replication : Optimistic LockingWith GR we use what we call optimistic locking, it means we consider a resource free andthis will be confirmed or not during certification.

Let's first have a look at the traditional locking to compare.

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

48 / 126

Page 49: MySQL InnoDB Cluster - Group Replication

Traditional locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

49 / 126

Page 50: MySQL InnoDB Cluster - Group Replication

Traditional locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

50 / 126

Page 51: MySQL InnoDB Cluster - Group Replication

Traditional locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

51 / 126

Page 52: MySQL InnoDB Cluster - Group Replication

Traditional locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

52 / 126

Page 53: MySQL InnoDB Cluster - Group Replication

Traditional locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

53 / 126

Page 54: MySQL InnoDB Cluster - Group Replication

Traditional locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

54 / 126

Page 55: MySQL InnoDB Cluster - Group Replication

Optimistic Locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

55 / 126

Page 56: MySQL InnoDB Cluster - Group Replication

Optimistic Locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

56 / 126

Page 57: MySQL InnoDB Cluster - Group Replication

Optimistic Locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

57 / 126

Page 58: MySQL InnoDB Cluster - Group Replication

Optimistic Locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

58 / 126

Page 59: MySQL InnoDB Cluster - Group Replication

Optimistic Locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

59 / 126

Page 60: MySQL InnoDB Cluster - Group Replication

Optimistic Locking

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

60 / 126

Page 61: MySQL InnoDB Cluster - Group Replication

Optimistic Locking

The system returns error 149 as certification failed:

ERROR 1180 (HY000): Got error 149 during COMMIT

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

61 / 126

Page 62: MySQL InnoDB Cluster - Group Replication

Group Replication : requirementsexclusively use of InnoDB tables only

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

62 / 126

Page 63: MySQL InnoDB Cluster - Group Replication

Group Replication : requirementsexclusively use of InnoDB tables onlyevery tables must have a PK defined

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

63 / 126

Page 64: MySQL InnoDB Cluster - Group Replication

Group Replication : requirementsexclusively use of InnoDB tables onlyevery tables must have a PK definedonly IPV4 is supported

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

64 / 126

Page 65: MySQL InnoDB Cluster - Group Replication

Group Replication : requirementsexclusively use of InnoDB tables onlyevery tables must have a PK definedonly IPV4 is supporteda good network with low latency is important

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

65 / 126

Page 66: MySQL InnoDB Cluster - Group Replication

Group Replication : requirementsexclusively use of InnoDB tables onlyevery tables must have a PK definedonly IPV4 is supporteda good network with low latency is importantmaximum of 9 members per group

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

66 / 126

Page 67: MySQL InnoDB Cluster - Group Replication

Group Replication : requirementsexclusively use of InnoDB tables onlyevery tables must have a PK definedonly IPV4 is supporteda good network with low latency is importantmaximum of 9 members per grouplog-bin must be enabled and only ROW format is supported

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

67 / 126

Page 68: MySQL InnoDB Cluster - Group Replication

Group Replication : requirements (2)enable GTIDs

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

68 / 126

Page 69: MySQL InnoDB Cluster - Group Replication

Group Replication : requirements (2)enable GTIDsreplication meta-data must be stored on system tables

--master-info-repository=TABLE --relay-log-info-repository=TABLE

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

69 / 126

Page 70: MySQL InnoDB Cluster - Group Replication

Group Replication : requirements (2)enable GTIDsreplication meta-data must be stored on system tables

--master-info-repository=TABLE --relay-log-info-repository=TABLE

writesets extraction must be enabled

--transaction-write-set-extraction=XXHASH64

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

70 / 126

Page 71: MySQL InnoDB Cluster - Group Replication

Group Replication : requirements (2)enable GTIDsreplication meta-data must be stored on system tables

--master-info-repository=TABLE --relay-log-info-repository=TABLE

writesets extraction must be enabled

--transaction-write-set-extraction=XXHASH64

log-slave-updates must be enabled

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

71 / 126

Page 72: MySQL InnoDB Cluster - Group Replication

Group Replication : limitationsThere are also some technical limitations:

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

72 / 126

Page 73: MySQL InnoDB Cluster - Group Replication

Group Replication : limitationsThere are also some technical limitations:

binlog checksum is not supported

--binlog-checksum=NONE

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

73 / 126

Page 74: MySQL InnoDB Cluster - Group Replication

Group Replication : limitationsThere are also some technical limitations:

binlog checksum is not supported

--binlog-checksum=NONE

Savepoints are not supported

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

74 / 126

Page 75: MySQL InnoDB Cluster - Group Replication

Group Replication : limitationsThere are also some technical limitations:

binlog checksum is not supported

--binlog-checksum=NONE

Savepoints are not supportedSERIALIZABLE is not supported as transaction isolation level

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

75 / 126

Page 76: MySQL InnoDB Cluster - Group Replication

Group Replication : limitationsThere are also some technical limitations:

binlog checksum is not supported

--binlog-checksum=NONE

Savepoints are not supportedSERIALIZABLE is not supported as transaction isolation levelan object cannot be changed concurrently at different servers by two operations,where one of them is a DDL and the other is either a DML or DDL.

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

76 / 126

Page 77: MySQL InnoDB Cluster - Group Replication

are we compatible ?

Pre-study

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

77 / 126

Page 78: MySQL InnoDB Cluster - Group Replication

Is my workload ready for Group Replication ?Large transactions are more vulnerable because:

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

78 / 126

Page 79: MySQL InnoDB Cluster - Group Replication

Is my workload ready for Group Replication ?Large transactions are more vulnerable because:

Large write set may increase the likelihood of certification conflicts

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

79 / 126

Page 80: MySQL InnoDB Cluster - Group Replication

Is my workload ready for Group Replication ?Large transactions are more vulnerable because:

Large write set may increase the likelihood of certification conflictsTransaction taking longer to execute may be more vulnerable to be aborted by acertified transaction.

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

80 / 126

Page 81: MySQL InnoDB Cluster - Group Replication

Is my workload ready for Group Replication ?Large transactions are more vulnerable because:

Large write set may increase the likelihood of certification conflictsTransaction taking longer to execute may be more vulnerable to be aborted by acertified transaction.

Small transactions changing a very small set of data (hotspots):

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

81 / 126

Page 82: MySQL InnoDB Cluster - Group Replication

Is my workload ready for Group Replication ?Large transactions are more vulnerable because:

Large write set may increase the likelihood of certification conflictsTransaction taking longer to execute may be more vulnerable to be aborted by acertified transaction.

Small transactions changing a very small set of data (hotspots):Concurrently executing them at different sites will trade-off contention with rollbacks due to the optimistic execution

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

82 / 126

Page 83: MySQL InnoDB Cluster - Group Replication

Therefore, when using Group Replication, we should pay attention to these points:

PK is mandatory (and a good one is better)avoid large transactionsavoid hotspot

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

83 / 126

Page 84: MySQL InnoDB Cluster - Group Replication

Scheme verificationWe will see now a list a queries that allows us to analyze our scheme. We will look for:

non InnoDB tablestables without PKtables with a bad PK

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

84 / 126

Page 85: MySQL InnoDB Cluster - Group Replication

Non InnoDB tables

 

SELECT table_schema, table_name, engine, table_rows, (index_length+data_length)/1024/1024 AS sizeMB FROM information_schema.tables WHERE engine != 'innodb' AND table_schema NOT IN ('information_schema', 'mysql', 'performance_schema');

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 85 / 126

Page 86: MySQL InnoDB Cluster - Group Replication

Tables Without Primary Keyselect tables.table_schema, tables.table_name, tables.engine, tables.table_rowsfrom information_schema.tablesleft join ( select table_schema, table_name from information_schema.statistics group by table_schema, table_name, index_name having sum( case when non_unique = 0 and nullable != 'YES' then 1 else 0 end ) = count(*)) pukson tables.table_schema = puks.table_schemaand tables.table_name = puks.table_namewhere puks.table_name is nulland tables.table_type = 'BASE TABLE' and engine='InnoDB';

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 86 / 126

Page 87: MySQL InnoDB Cluster - Group Replication

Tables with bad primarky keys

 

set SQL_MODE=""; select a.TABLE_SCHEMA,a.TABLE_NAME, b.ENGINE, a.COLUMN_NAME, a.DATA_TYPE, a.COLUMN_TYPE, a.COLUMN_KEY, b.TABLE_ROWS from information_schema.COLUMNS as a join information_schema.TABLES as b on b.TABLE_NAME=a.TABLE_NAME and b.TABLE_SCHEMA=a.TABLE_SCHEMA where COLUMN_KEY='PRI' and ENGINE="InnoDB" and DATA_TYPE not like '%int' and DATA_TYPE not like 'enum%' and DATA_TYPE not like 'date%' and DATA_TYPE not like 'time%' and a.TABLE_SCHEMA not in ('mysql','sys')group by table_schema, table_name;

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 87 / 126

Page 88: MySQL InnoDB Cluster - Group Replication

Workload analysisNow it's time to play with Performance_Schema to analyze our workload.

The goal is to identify:

transactions with most statements (and most writes in particular)transactions with most rows affectedlargest statements by row affectedqueries updating most the same PK and therefore having to wait more)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

88 / 126

Page 89: MySQL InnoDB Cluster - Group Replication

Setup Performance_Schema

We need to enable some consumers and instruments:

update performance_schema.setup_consumers set enabled = 'yes' where name like 'events_statement%' or name like 'events_transaction%';

update performance_schema.setup_instruments set enabled = 'yes', timed = 'yes' where name = 'transaction';

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 89 / 126

Page 90: MySQL InnoDB Cluster - Group Replication

Find the transactions with most statements

 

select t.thread_id, t.event_id, count(*) statement_count, sum(s.rows_affected) rows_affected, length(replace(group_concat( case when s.event_name = "statement/sql/update" then 1 when s.event_name = "statement/sql/insert" then 1 when s.event_name = "statement/sql/delete" then 1 else null end),',','')) as "# write statements" from performance_schema.events_transactions_history_long t join performance_schema.events_statements_history_long s on t.thread_id = s.thread_id and t.event_id = s.nesting_event_id group by t.thread_id, t.event_id order by rows_affected desc limit 10;

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 90 / 126

Page 91: MySQL InnoDB Cluster - Group Replication

Find the transactions with most statements

It's possible to see what are all these statements in one transaction:

set group_concat_max_len = 1000000;

select t.thread_id, t.event_id, count(*) statement_count, sum(s.rows_affected) rows_affected, group_concat(sql_text order by s.event_id separator '\n') statements from performance_schema.events_transactions_history_long t join performance_schema.events_statements_history_long s on t.thread_id = s.thread_id and t.event_id = s.nesting_event_id group by t.thread_id, t.event_id order by statement_count desc limit 1\G

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 91 / 126

Page 92: MySQL InnoDB Cluster - Group Replication

Find the transactions with most rows affected

 

select t.thread_id, t.event_id, count(*) statement_count, sum(s.rows_affected) rows_affected, length(replace(group_concat( case when s.event_name = "statement/sql/update" then 1 when s.event_name = "statement/sql/insert" then 1 when s.event_name = "statement/sql/delete" then 1 else null end),',','')) as "# write statements" from performance_schema.events_transactions_history_long t join performance_schema.events_statements_history_long s on t.thread_id = s.thread_id and t.event_id = s.nesting_event_id group by t.thread_id, t.event_id order by rows_affected desc limit 10;

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 92 / 126

Page 93: MySQL InnoDB Cluster - Group Replication

Find the transactions with most rows affected

It's again possible the see what are the statements:

select t.thread_id, t.event_id, count(*) statement_count, sum(s.rows_affected) rows_affected, group_concat(sql_text order by s.event_id separator '\n') statements from performance_schema.events_transactions_history_long t join performance_schema.events_statements_history_long s on t.thread_id = s.thread_id and t.event_id = s.nesting_event_id group by t.thread_id, t.event_id order by rows_affected desc limit 1\G

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 93 / 126

Page 94: MySQL InnoDB Cluster - Group Replication

Find the transactions with most rows affected

It's again possible the see what are the statements:

select t.thread_id, t.event_id, count(*) statement_count, sum(s.rows_affected) rows_affected, group_concat(sql_text order by s.event_id separator '\n') statements from performance_schema.events_transactions_history_long t join performance_schema.events_statements_history_long s on t.thread_id = s.thread_id and t.event_id = s.nesting_event_id group by t.thread_id, t.event_id order by rows_affected desc limit 1\G

Don't forget to verify the auto_commit ones are they are not returned with the queryabove.

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 94 / 126

Page 95: MySQL InnoDB Cluster - Group Replication

Find largest statements by row affected

 

select query, db, rows_affected, rows_affected_avg from sys.statement_analysis order by rows_affected_avg desc limit 10;

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 95 / 126

Page 96: MySQL InnoDB Cluster - Group Replication

Find queries that write the most.

Looking for lots of updates/timer_wait to the same PKs.

 

select * from performance_schema.events_statements_history_long where rows_affected > 1 order by timer_wait desc limit 20\G

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

 96 / 126

Page 97: MySQL InnoDB Cluster - Group Replication

help me to configure my InnoDB Cluster

Using new cool tools

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

97 / 126

Page 98: MySQL InnoDB Cluster - Group Replication

MySQL ShellThe MySQL Team extended MySQL Shell to use the new Admin API.

Now MySQL Shell is a single unified client for all adminstrative and operatons tasks.

Multi-Language:

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

98 / 126

Page 99: MySQL InnoDB Cluster - Group Replication

MySQL ShellThe MySQL Team extended MySQL Shell to use the new Admin API.

Now MySQL Shell is a single unified client for all adminstrative and operatons tasks.

Multi-Language:JavaScript

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

99 / 126

Page 100: MySQL InnoDB Cluster - Group Replication

MySQL ShellThe MySQL Team extended MySQL Shell to use the new Admin API.

Now MySQL Shell is a single unified client for all adminstrative and operatons tasks.

Multi-Language:JavaScriptPython

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

100 / 126

Page 101: MySQL InnoDB Cluster - Group Replication

MySQL ShellThe MySQL Team extended MySQL Shell to use the new Admin API.

Now MySQL Shell is a single unified client for all adminstrative and operatons tasks.

Multi-Language:JavaScriptPythonSQL

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

101 / 126

Page 102: MySQL InnoDB Cluster - Group Replication

MySQL ShellThe MySQL Team extended MySQL Shell to use the new Admin API.

Now MySQL Shell is a single unified client for all adminstrative and operatons tasks.

Multi-Language:JavaScriptPythonSQL

Supports both Document and Relational models

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

102 / 126

Page 103: MySQL InnoDB Cluster - Group Replication

MySQL ShellThe MySQL Team extended MySQL Shell to use the new Admin API.

Now MySQL Shell is a single unified client for all adminstrative and operatons tasks.

Multi-Language:JavaScriptPythonSQL

Supports both Document and Relational modelsExposes full Development and Admin API

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

103 / 126

Page 104: MySQL InnoDB Cluster - Group Replication

MySQL Shell: Admin APImysql-js> dba.help()

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

104 / 126

Page 105: MySQL InnoDB Cluster - Group Replication

MySQL Shell: Admin APImysql-js> dba.help()

the global variable dba is used to access the MySQL API

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

105 / 126

Page 106: MySQL InnoDB Cluster - Group Replication

MySQL Shell: Admin APImysql-js> dba.help()

the global variable dba is used to access the MySQL APIperform DBA operations to manage MySQL InnoDB Cluster:

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

106 / 126

Page 107: MySQL InnoDB Cluster - Group Replication

MySQL Shell: Admin APImysql-js> dba.help()

the global variable dba is used to access the MySQL APIperform DBA operations to manage MySQL InnoDB Cluster:

create cluster

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

107 / 126

Page 108: MySQL InnoDB Cluster - Group Replication

MySQL Shell: Admin APImysql-js> dba.help()

the global variable dba is used to access the MySQL APIperform DBA operations to manage MySQL InnoDB Cluster:

create clusterdeploy MySQL instances (in sandbox only for the moment)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

108 / 126

Page 109: MySQL InnoDB Cluster - Group Replication

MySQL Shell: Admin APImysql-js> dba.help()

the global variable dba is used to access the MySQL APIperform DBA operations to manage MySQL InnoDB Cluster:

create clusterdeploy MySQL instances (in sandbox only for the moment)get cluster info

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

109 / 126

Page 110: MySQL InnoDB Cluster - Group Replication

MySQL Shell: Admin APImysql-js> dba.help()

the global variable dba is used to access the MySQL APIperform DBA operations to manage MySQL InnoDB Cluster:

create clusterdeploy MySQL instances (in sandbox only for the moment)get cluster infostart/stop MySQL instances

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

110 / 126

Page 111: MySQL InnoDB Cluster - Group Replication

MySQL Shell: Admin APImysql-js> dba.help()

the global variable dba is used to access the MySQL APIperform DBA operations to manage MySQL InnoDB Cluster:

create clusterdeploy MySQL instances (in sandbox only for the moment)get cluster infostart/stop MySQL instancesvalidate MySQL instances

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

111 / 126

Page 112: MySQL InnoDB Cluster - Group Replication

mysqlprovisionThe mysqlprovision utility is designed to facilitate the management of MySQL GroupReplication, allowing users to start a replica set (a new replication group), to add/removemembers to/from an existing group. It can also check if an instance meets all therequirements to successfully create a new group or to be added to an existing group. Thisutility is also capable of modifying MySQL option files of existing instances in order forthem to meet the requirements of Group Replication.

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

112 / 126

Page 113: MySQL InnoDB Cluster - Group Replication

let's create our first MySQL InnoDB Cluster

Demo time !

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

113 / 126

Page 114: MySQL InnoDB Cluster - Group Replication

MySQL InnoDB Cluster

demo

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

114 / 126

Page 115: MySQL InnoDB Cluster - Group Replication

full HA ?

Application interaction

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

115 / 126

Page 116: MySQL InnoDB Cluster - Group Replication

MySQL RouterMySQL ShellMySQL Group ReplicationMySQL Server

MySQL InnoDB ClusterSo MySQL InnoDB Cluster is composed by:

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

116 / 126

Page 117: MySQL InnoDB Cluster - Group Replication

MySQL RouterMySQL ShellMySQL Group ReplicationMySQL Server

MySQL InnoDB ClusterSo MySQL InnoDB Cluster is composed by:

 

CON2907 - MySQL High Availability - Matt Lord - Wed 12:15

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

117 / 126

Page 118: MySQL InnoDB Cluster - Group Replication

MySQL RouterTransparent client connection routing (TCP level 4)

load balancingconnection failover

Native support for InnoDB Clusters

understands Group Replication topologyutilizes metadata schema stored on each members

bootstrap and auto-configsupports multi-master and single primary modes

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

118 / 126

Page 119: MySQL InnoDB Cluster - Group Replication

MySQL Router & Group Replication

Quick demo !

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

119 / 126

Page 120: MySQL InnoDB Cluster - Group Replication

MySQL Router & Group Replication

demo

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

120 / 126

Page 121: MySQL InnoDB Cluster - Group Replication

Any other alternatives ?

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

121 / 126

Page 122: MySQL InnoDB Cluster - Group Replication

Any other alternatives ?It's possible to use MySQL Group Replication with other proxies/load-balancers

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

122 / 126

Page 123: MySQL InnoDB Cluster - Group Replication

Any other alternatives ?It's possible to use MySQL Group Replication with other proxies/load-balancers

HAProxy : http://lefred.be/content/mysql-group-replication-as-ha-solution/

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

123 / 126

Page 124: MySQL InnoDB Cluster - Group Replication

ProxySQL : http://lefred.be/content/ha-with-mysql-group-replication-and-proxysql/

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

124 / 126

Page 125: MySQL InnoDB Cluster - Group Replication

Questions ?

Thank you !   

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

125 / 126

Page 126: MySQL InnoDB Cluster - Group Replication

Join us!Register: http://tinyurl.com/mysqloow16

MySQL Community Reception @ OracleOpenWorld

Tuesday, September 20, 7.00 pmJillian’s at Metreon: 175 Fourth Street, San Francisco

At the corner of Howard and 4th st.; only 2-min walk from Moscone Center (sameplace as last year)

Copyright @ 2016 Oracle and/or its affiliates. All rights reserved.

126 / 126