mysql group replication @osi days 2014

28

Upload: manish-kumar

Post on 05-Jul-2015

168 views

Category:

Software


0 download

DESCRIPTION

A high level presentation of MySQL Group Replication presented at OSI days, 2014. Here is the agenda for the talk. 1. Introduction to group replication. 2. Use cases 3. Internals 4. Monitoring 5. Limitations 6. References

TRANSCRIPT

Page 1: MySQL Group Replication @osi days 2014
Page 2: MySQL Group Replication @osi days 2014

2 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Open Source India, 2014

MySQL Group Replication

Manish Kumar ([email protected])Senior Member technical Staff, MySQL Replication Team

Page 3: MySQL Group Replication @osi days 2014

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.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Page 4: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

MySQL Labs features are not fit for production.

They are provided solely for testing purposes, to try the latest bug fixes and generally to keep up with the development.

Please, do not use these binaries in production.

Instead, install them on a spare server.

If you are looking for production ready binaries, please visit MySQL Downloads.

Page 5: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

MySQL Group Replication :

Multi-master update everywhere with conflict resolution.

Automatic distributed member recovery— When a server joins the group, it gets all the missing transactions before actually

start serving requests.

Page 6: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

M M M M M

ReplicationPlugin

API

MySQLServer

Group Comm.System (Corosync)Group Comm.

System (Corosync)

Group-Based Replication Plugin

M M M M M

ReplicationPlugin

API

MySQLServer

Group Comm.System (Corosync)

Group-Based Replication Plugin

Page 7: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

M M M M M

Update ...

Application issues an update.

Group-Based Replication Plugin

Page 8: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

M M M M M

ReplicationEvents

Application issues an update.

Master executes and multi/broadcasts the update to the other servers.

Group-Based Replication Plugin

Page 9: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

M M M M M

Application issues an update.

Master executes and multi/broadcasts the update to the other servers.

Servers receive same transaction in the same order and check for conflicts.

Group-Based Replication Plugin

Page 10: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

M M M M M

Application issues an update.

Master executes and multi/broadcasts the update to the other servers.

Servers receive same transaction in the same order and check for conflicts.

All servers, independently, decide to commit the transaction – no conflicts.

Group-Based Replication Plugin

Page 11: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Application issues an update.

Master executes and multi/broadcasts the update to the other servers.

Servers receive same transaction in the same order and check for conflicts.

All servers, independently, decide to commit the transaction – no conflicts.

Originating master replies to the application.

M M M M M

Group-Based Replication Plugin

Page 12: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

MySQL Group Replication: Use Cases

● Automatic group membership management and failure detection - No need for server fail-over

● No single point of failure - Automatic reconfiguration

Page 13: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Under the hood

● Each server can belong to a group.

● The Group is identified by a name which is the Group UUID string, so group behaves like a single server.

● The Group UUID is used to log transactions.

● Whenever a server joins or leaves, it will start a new stable period in time on which servers can agree on distributed decisions. A special message called View Message is sent to each group member notifying that.

● Server join/leave can be issue manually or by scripts by DBA.

● Server leave can be caused also by node failures.

Page 14: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Current used group communication toolkit is Corosync. It provides:— Virtual synchrony guarantees for creating replicated state machines.

Replicated state machine simple definition:— If a set of processes with the same initial state receives the same set of deterministic

messages at the same order, them will reach the same state.

All write operations are sent to all group members for certification.

Read operations are only local.

Under the hood

Page 15: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

s1

s2

UPDATEdbv: 1

dbv: 2

s3dbv: 2

dbv: 2COMMIT

COMMIT

COMMIT

cv: 11 >= 1

OK

1 >= 1

OK

1 >= 1

OK

cv: 1

cv: 1

dbv: 1

dbv: 1

cv: 2

cv: 2

cv: 2

s ← serverv ← snapshot versionsn ← certifier sequence number (write set version)

Certification - Positive

Page 16: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

s1

s2

T1: UPDATEdbv: 1

dbv: 2

s3dbv: 2

dbv: 2T1: COMMIT

T1: COMMIT

T1: COMMIT

cv: 1

cv: 1

cv: 1

1 >= 1

OK

1 >= 1

OK

1 >= 1

OK

T2: UPDATE cv: 2

cv: 2

cv: 2

1 >= 2

KO

1 >= 2

KO

1 >= 2

KO

dbv: 1

dbv: 1

s ← serverv ← snapshot versionsn ← certifier sequence number (write set version)

Certification - Negative

Page 17: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Automated distributed member recovery

R1

R2

R3

R4

GCS

R1

R2

R3

R4

R4 joins the group.

GCS

Page 18: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Automated distributed member recovery

R1

R2

R3

R4

R1 is R4 Donor

GCS

R1

R2

R3

R4

GCS

Page 19: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Automated distributed member recovery

R1

R2

R3

R4

GCS

R1

R2

R3

R4

GCS

Page 20: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Automated distributed member recovery

R1

R2

R3

R4

GCS

R1

R2

R3

R4

R4 has caught upwith the view!

GCS

Page 21: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

R1

R2

R3

R4

GCS

R1

R2

R3

R4

GCS

Execute bufferedtransactions from the view.

Automated distributed member recovery

Page 22: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

– REPLICATION_NODE_STATUS● Statistics regarding Applier and Certifier module.

– REPLICATION_CONNECTION_NODES● Information regarding different nodes in the group and its

connection details

– REPLICATION_CONNECTION_STATUS● Extended table to give details about the group connection status.

PERFORMANCE SCHEMA TABLE

Page 23: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

node1> SELECT * FROM performance_schema.replication_node_status\G *************************** 1. row *************************** GROUP_NAME: 8a84f397-aaa4-18df-89ab-c70aa9823561 NODE_ID: 2af09cb1-3e46-11e4-9e45-ecf4bb227f3b TRANSACTIONS_IN_QUEUE: 0 CERTIFIED_TRANSACTIONS: 12 POSITIVELY_CERTIFIED: 7 NEGATIVELY_CERTIFIED: 5 CERTIFICATION_DB_SIZE: 6 STABLE_SET: 8a84f397-aaa4-18df-89ab-c70aa9823561:1-7 LAST_CERTIFIED_TRANSACTION: 8a84f397-aaa4-18df-89ab-c70aa9823561:7 APPLIER_MODULE_STATUS: ON

Replication Monitoring: replication_node_status

Page 24: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

node1> SELECT * FROM performance_schema.replication_connection_nodes\G *************************** 1. row *************************** GROUP_NAME 8a94f357-aab4-11df-86ab-c80aa9429573 NODE_ID 597dbb72-3e2c-11e4-9d9d-ecf4bb227f3b NODE_HOST nightfury NODE_PORT 13000 NODE_STATE ONLINE *************************** 2. row *************************** GROUP_NAME 8a94f357-aab4-11df-86ab-c80aa9429573 NODE_ID 59efb8a1-3e2c-11e4-9d9d-ecf4bb227f3b NODE_HOST nightfury NODE_PORT 13001 NODE_STATE ONLINE *************************** 3. row *************************** GROUP_NAME 8a94f357-aab4-11df-86ab-c80aa9429573 NODE_ID 5a706f6b-3e2c-11e4-9d9d-ecf4bb227f3b NODE_HOST nightfury NODE_PORT 13002 NODE_STATE RECOVERING

Replication Monitoring: replication_node_status

Page 25: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Replication Monitoring: replication_node_status

node1> SELECT * FROM performance_schema.replication_connection_status\G *************************** 1. row *************************** GROUP_NAME: 8a94f357-aab4-11df-86ab-c80aa9429563 SOURCE_UUID: 8a94f357-aab4-11df-86ab-c80aa9429563 THREAD_ID: NULL SERVICE_STATE: ON COUNT_RECEIVED_HEARTBEATS: 0 LAST_HEARTBEAT_TIMESTAMP: 0000-00-00 00:00:00 RECEIVED_TRANSACTION_SET: LAST_ERROR_NUMBER: 0 LAST_ERROR_MESSAGE: LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00 TOTAL_MESSAGES_RECEIVED: 9 TOTAL_MESSAGES_SENT: 5 TOTAL_BYTES_RECEIVED: 1891 TOTAL_BYTES_SENT: 1065 LAST_MESSAGE_TIMESTAMP: 2014-09-23 09:20:26 MAX_MESSAGE_LENGTH: 358 MIN_MESSAGE_LENGTH: 51 VIEW_ID: 2 NUMBER_OF_NODES: 2

Page 26: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Only transactional engines are supported (currently only InnoDB).

All tables must have primary key

GTID must be enabled.

Only deterministic DDL is allowed.

Optimistic execution: transactions may abort on COMMIT.

Limitations

Page 27: MySQL Group Replication @osi days 2014

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Open Source India | Bangalore, India, 8th November, 2014. |

Read More About MySQL Group Replication● Read a feature preview of MySQL Group replication on Luis' blog:

http://mysqlhighavailability.com/mysql-group-replication-hello-world/

Read about how to get started with MySQL Group replication on Pedro's blog:http://mysqlhighavailability.com/getting-started-with-mysql-group-replication/

● Read about Transaction life cycle in MySQL Group replication on Nuno's blog:http://mysqlhighavailability.com/mysql-group-replication-transaction-life-cycle-explained/

● Read about Distributed recovery in MySQL Group Replication on Pedro's blog:http://mysqlhighavailability.com/distributed-recovery-behind-the-scenes/

● Read about Monitoring for MySQL Group Replication on Manish's blog:http://mysqlhighavailability.com/mysql-group-replication-monitoring/

● Read about Corosync and Group Communication details on Tiago's blog:http://mysqlhighavailability.com/group-communication-behind-the-scenes/http://mysqlhighavailability.com/mysql-group-replication-a-small-corosync-guide/

● Read about Testing of MySQL Group Replication on Manish's blog:http://mysqlhighavailability.com/mysql-group-replication-testing/

Page 28: MySQL Group Replication @osi days 2014