MySQL Replication Evolution From Simple to Group Replication ConFoo Montreal & Vancouver 2017 Dave Stokes -- MySQL Community Manager [email protected]@stoker slideshare.net/davidmstokes Elephantanddolphin.blogspot.com & opensourcedba.wordpress.com 1
56
Embed
ConFoo MySQL Replication Evolution : From Simple to Group Replication
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
MySQL Replication EvolutionFrom Simple to Group ReplicationConFoo Montreal & Vancouver 2017Dave Stokes -- MySQL Community Manager
MySQL InnoDB cluster is a collection of products that work together to provide
a high availability solution. A group of MySQL servers can be configured to
create a cluster using MySQL Shell. The cluster of servers has a single master,
called the primary, which acts as the read-write master. Multiple secondary
servers are replicas of the master. A minimum of three servers are required to
create a high availability cluster. A client application is connected to the
primary via MySQL Router. If the primary fails, a secondary is automatically
promoted to the role of primary, and MySQL Router routes requests to the new
primary.
Components
MySQL Shell 1.0.8 or higher. Includes the AdminAPI, which enables you to create and administer an
InnoDB cluster, using either JavaScript or Python scripting. MySQL Shell also requires Python 2.7 and
above to run cluster provisioning scripts.
MySQL Router 2.1.2 or higher. Caches the metadata of the InnoDB cluster and performs high availability
routing to the MySQL Server instances which make up the cluster. If the primary instance becomes
unavailable, MySQL Router automatically routes client requests to a promoted secondary (the new
primary).
MySQL Server 5.7.17 or higher. This provides the Group Replication mechanism to allow data to be
replicated from the primary to the secondaries in the cluster.
39
40
41
MySQL Router
Connection routing is the ability to permit the
redirection of connections sent to the router to an
available MySQL server. Connection routing is
simply the redirection of the MySQL packets in their
entirety without inspection.
This means you can set up your application to
connect to the router and should the current MySQL
server fail, retry the connection and the router will
select a new MySQL server to redirect the
connection.
So check you return codes, retry on failure
Configuration
[routing:simple_redirect]
bind_port = 7002
mode = read-write
destinations =
localhost:3306,localhost:3307,localhost:3308
42
Group Replication
MySQL Group Replication provides distributed state machine replication with
strong coordination between servers. Servers coordinate themselves
automatically when they are part of the same group. The group can operate in a
single-primary mode with automatic primary election, where only one server
accepts updates at a time. Alternatively, for more advanced users the group
can be deployed in multi-primary mode, where all servers can accept updates,
even if they are issued concurrently. This power comes at the expense of
applications having to work around the limitations imposed by such
deployments.43
Group Replication
There is a built-in group membership service that keeps the view of the group
consistent and available for all servers at any given point in time. Servers can
leave and join the group and the view is updated accordingly. Sometimes
servers can leave the group unexpectedly, in which case the failure detection
mechanism detects this and notifies the group that the view has changed. This
is all automatic.
44
Group Replication
For a transaction to commit, the majority of the group have to agree on the
order of a given transaction in the global sequence of transactions. Deciding to
commit or abort a transaction is done by each server individually, but all
servers make the same decision. If there is a network partition, resulting in a
split where members are unable to reach agreement, then the system does not
progress until this issue is resolved. Hence there is also a built-in, automatic,
split-brain protection mechanism.
45
Group Replication
All of this is powered by the provided group communication protocols. These
provide a failure detection mechanism, a group membership service, and safe
and completely ordered message delivery. All these properties are key to
creating a system which ensures that data is consistently replicated across the
group of servers. At the very core of this technology lies an implementation of
the Paxos algorithm. It acts as the group communication systems engine.
46
Group Replication
All read-write (RW) transactions commit only after they have been approved by the group. Read-only (RO) transactions need no coordination within the group and thus commit immediately. For any RW transaction the group needs to decide whether it commits or not, thus the commit operation is not a unilateral decision from the originating server. When a transaction is ready to commit at the originating server, the server atomically broadcasts the write values (rows changed) and the correspondent write set (unique identifiers of the rows that were updated). Then a global total order is established for that transaction. Ultimately, this means that all servers receive the same set of transactions in the same order. As a consequence, all servers apply the same set of changes in the same order, therefore they remain consistent within the group. 47