Innodb Cluster - Tutorial
Total Page:16
File Type:pdf, Size:1020Kb
1 / 34 InnoDB Cluster - Tutorial Kenny Gryp Principal MySQL Product Manager Miguel Araújo MySQL AdminAPI Tech Lead. Software Engineer 2 / 34 3 / 34 Safe Harbor The following is intended to outline our general product direction. It is intended for information purpose only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied up in making purchasing decisions. The development, release, timing and pricing of any features or functionality described for Oracle´s product may change and remains at the sole discretion of Oracle Corporation. Statement in this presentation relating to Oracle´s future plans, expectations, beliefs, intentions and ptospects are "forward- looking statements" and are subject to material risks and uncertainties. A detailed discussion of these factors and other risks that affect our business is contained in Oracle´s Securities and Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q under the heading "Risk Factors". These filings are available on the SEC ´s website or on Oracle´s website at http:// www.oracle.com/investor. All information in this presentation is current as of September 2019 and Oracle undertakes no duty to update any statement in light of new information or future events. Copyright @ 2019 Oracle and/or its affiliates. 4 / 34 MySQL InnoDB Cluster "A single product — MySQL — with high availability and scaling features baked in; providing an integrated end-to-end solution that is easy to use." Copyright @ 2019 Oracle and/or its affiliates. 4 / 34 MySQL InnoDB Cluster "A single product — MySQL — with high availability and scaling features baked in; providing an integrated end-to-end solution that is easy to use." Copyright @ 2019 Oracle and/or its affiliates. 4 / 34 MySQL InnoDB Cluster "A single product — MySQL — with high availability and scaling features baked in; providing an integrated end-to-end solution that is easy to use." Components: MySQL Group Replication MySQL Shell MySQL Router Copyright @ 2019 Oracle and/or its affiliates. 5 / 34 MySQL InnoDB Cluster - Goals One Product: MySQL All components developed together Integration of all components Full stack testing Copyright @ 2019 Oracle and/or its affiliates. 5 / 34 MySQL InnoDB Cluster - Goals One Product: MySQL Easy to Use All components developed together One client: MySQL Shell Integration of all components Integrated orchestration Full stack testing Homogenous servers Copyright @ 2019 Oracle and/or its affiliates. 5 / 34 MySQL InnoDB Cluster - Goals One Product: MySQL Easy to Use All components developed together One client: MySQL Shell Integration of all components Integrated orchestration Full stack testing Homogenous servers Flexible and Modern - X Protocol SQL and NoSQL together Protocol Buffers Asynchronous API Developer friendly Copyright @ 2019 Oracle and/or its affiliates. 6 / 34 MySQL Group Replication Copyright @ 2019 Oracle and/or its affiliates. 7 / 34 MySQL Group Replication Copyright @ 2019 Oracle and/or its affiliates. 7 / 34 MySQL Group Replication High Available Distributed MySQL DB Open Source Fault tolerance Automatic failover Active/Active update anywhere (limits apply) Automatic membership management Adding/removing members Network partitions, failures Conflict detection and resolution Prevents data loss Copyright @ 2019 Oracle and/or its affiliates. 8 / 34 MySQL Group Replication Implementation of Replicated Database State Machine Total Order - Writes XCOM - Paxos implementation 8.0+: Member provisioning using CLONE plugin. Configurable Consistency Guarantees eventual consistency 8.0+: per session & global read/write consistency Using MySQL replication framework by design binary logs relay logs GTIDs: Global Transaction IDs Generally Available since MySQL 5.7 Supported on all platforms: linux, windows, solaris, macosx, freebsd Copyright @ 2019 Oracle and/or its affiliates. 9 / 34 MySQL Group Replication - Use Cases Consistency: No Data Loss (RPO=0) in event of failure of (primary) member Split brain prevention (Quorum) Copyright @ 2019 Oracle and/or its affiliates. 9 / 34 MySQL Group Replication - Use Cases Consistency: No Data Loss (RPO=0) Highly Available: Automatic Failover in event of failure of (primary) member Primary members are automatically elected Split brain prevention (Quorum) Automatic Network Partition handling Copyright @ 2019 Oracle and/or its affiliates. 9 / 34 MySQL Group Replication - Use Cases Consistency: No Data Loss (RPO=0) Highly Available: Automatic Failover in event of failure of (primary) member Primary members are automatically elected Split brain prevention (Quorum) Automatic Network Partition handling Read Scaleout Add/Remove members as needed Replication Lag handling with Flow Control Configurable Consistency Levels Eventual Full Consistency -- no stale reads Copyright @ 2019 Oracle and/or its affiliates. 9 / 34 MySQL Group Replication - Use Cases Consistency: No Data Loss (RPO=0) Highly Available: Automatic Failover in event of failure of (primary) member Primary members are automatically elected Split brain prevention (Quorum) Automatic Network Partition handling Read Scaleout Active/Active environments Add/Remove members as needed Write to many members at the same time Replication Lag handling with Flow Control ordered writes within the group (XCOM) Configurable Consistency Levels guaranteed consistency Eventual Good write performance Full Consistency -- no stale reads due to Optimistic Locking (workload dependent) Copyright @ 2019 Oracle and/or its affiliates. 10 / 34 MySQL Shell Copyright @ 2019 Oracle and/or its affiliates. 10 / 34 MySQL Shell Database Administration Interface "MySQL Shell provides the developer and DBA with a single intuitive, flexible, and powerful interface for all MySQL related tasks!" Open Source Multi-Language: JavaScript, Python, and SQL Naturally scriptable Supports Document and Relational models Exposes full Development and Admin API Classic MySQL protocol and X protocol Copyright @ 2019 Oracle and/or its affiliates. 11 / 34 DEMO MySQL Shell Starting an application (sysbench) Create Cluster Copyright @ 2019 Oracle and/or its affiliates. 12 / 34 MySQL Router Copyright @ 2019 Oracle and/or its affiliates. 12 / 34 MySQL Router Transparent Access to Database Arch. "provide transparent routing between your application and back-end MySQL Servers" Transparent client connection routing Load balancing Application connection failover Stateless design offers easy HA client routing Router as part of the application stack Little to no configuration needed Native support for InnoDB clusters Understands Group Replication topology Utilizes metadata schema on each member Currently 2 TCP Ports: PRIMARY and NON-PRIMARY traffic Copyright @ 2019 Oracle and/or its affiliates. 13 / 34 DEMO Install & Use MySQL Router Router REST Interface Shell Extensions Copyright @ 2019 Oracle and/or its affiliates. 14 / 34 MySQL - Node Provisioning with CLONE added in MySQL 8.0.17 Provision members that have no data Takes Physical snapshot of data Using standard MySQL connection (3306) Built-in the MySQL Server Fully integrated in MySQL InnoDB Cluster https://mysqlhighavailability.com/mysql-innodb-cluster-automatic-node-provisioning https://mysqlhighavailability.com/a-breakthrough-in-usability-automatic-node-provisioning Copyright @ 2019 Oracle and/or its affiliates. 15 / 34 DEMO Add third node to the group Show CLONE Extended Status Copyright @ 2019 Oracle and/or its affiliates. 16 / 34 MySQL Group Replication - Communication Asynchronous Replication Copyright @ 2019 Oracle and/or its affiliates. 17 / 34 MySQL Group Replication - Communication Semi Synchronous Replication Copyright @ 2019 Oracle and/or its affiliates. 18 / 34 MySQL Group Replication - Communication Group Replication Copyright @ 2019 Oracle and/or its affiliates. 19 / 34 DEMO Stop the primary node Kill the primary node setInstanceOption & setOption switch primary member online Copyright @ 2019 Oracle and/or its affiliates. 20 / 34 MySQL Group Replication - Network Partitions Copyright @ 2019 Oracle and/or its affiliates. 20 / 34 MySQL Group Replication - Network Partitions Quorum based Network Partition Handling Prevents Split-Brain Ensure uneven amount of nodes view of <=50% of total members: Minority view of >50% of total members: Majority will accept reads/writes Copyright @ 2019 Oracle and/or its affiliates. 20 / 34 MySQL Group Replication - Network Partitions Quorum based Network Partition Handling In case of event of loss of majority: Prevents Split-Brain a minority partition can be forced ONLINE Ensure uneven amount of nodes Nodes in minority: view of <=50% of total members: Minority MySQL Router: moves away traffic view of >50% of total members: Majority Fencing: members become READ_ONLY or will accept reads/writes ABORT_SERVER Copyright @ 2019 Oracle and/or its affiliates. 21 / 34 MySQL Group Replication - Network Partitions Majority 1. wait 5 seconds, then suspect minority is gone 2. expel minority after group_replication_member_expel_timeout seconds (default 0, immediately) do not put the variable too high, between suspect and expel members cannot be added/removed no new leader can be elected Minority 1. wait 5 seconds before suspecting itself to lost connection to the majority 2. wait group_replication_unreachable_majority_timeout (default 0, forever) 3. when timeout: group_replication_autorejoin_tries (default 0 times) retries every 5 minutes 4. After group_replication_exit_state_action READ_ONLY: allow stale