_UserForum_05-Repl_jp.pptx

Similar documents
MySQL レプリケーションの用途 スケーラビリティ Web で中心となる参照処理を分散してシステムとしての拡張性を向上 可用性 データの複製を持たせ マスターに障害が発生した場合は切り替え 集計処理やバックアップ オンラインでの処理から処理を分離することによって全体の性能を維持 ディザスタリカバリ

サンのオープンソースへの 取り組み

スライド 1

PowerPoint Presentation

MySQL 5.7 レプリケーション新機能 日本オラクル株式会社 MySQL Global Business Unit

PowerPoint Presentation

Introduction Purpose This training course describes the configuration and session features of the High-performance Embedded Workshop (HEW), a key tool

MySQL Replication and Scalability

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

How to Use the PowerPoint Template

PowerPoint Presentation

~~~~~~~~~~~~~~~~~~ wait Call CPU time 1, latch: library cache 7, latch: library cache lock 4, job scheduler co

fx-9860G Manager PLUS_J

RX600 & RX200シリーズ アプリケーションノート RX用仮想EEPROM

Oracle Solaris 仮想環境とプロビジョン環境の構築

はじめに

外部SQLソース入門

設定手順

untitled

Microsoft Word - Win-Outlook.docx

GPGPU

untitled

How to Use the PowerPoint Template

サンのオープンソースへの 取り組み

2

2

2

PowerPoint Presentation

2

1 138

Cisco ASA Firepower ASA Firepower

MySQL研修コース & 資格のご案内

H8000操作編

<Documents Title Here>

JEE 上の Adobe Experience Manager forms のインストールおよびデプロイ(WebLogic 版)

_04_Server57.pptx

PowerPoint Presentation

Actual ESS Adapterの使用について

…l…b…g…‘†[…N…v…“…O…›…~…fi…OfiÁŸ_

Microsoft Word - Meta70_Preferences.doc

C3印刷用.PDF

Make the Future Java FY13 PPT Template

untitled

HA8000シリーズ ユーザーズガイド ~BIOS編~ HA8000/RS110/TS10 2013年6月~モデル

Web Web Web Web Web, i

16.16%

MySQL Cluster

Windowsユーザーの為のOracle Database セキュリティ入門

Z7000操作編_本文.indb

MySQL5.5 MySQL

A : kerl kerl Erlang/OTP Erlang/OTP 2 2 Elixir/Phoenix URL 2 PDF A.2 Bash macos.bash_profile exp


untitled

スライド 1


Microsoft PowerPoint - MySQL-backup.ppt

L3 Japanese (90570) 2008


19_22_26R9000操作編ブック.indb

Elastic stack Jun Ohtani 1

Cisco Aironet 1130AG アクセス ポイント クイック スタート ガイド


pg_monz 監視アイテム一覧 :Template App PostgreSQL Template App PostgreSQL アプリケーション LLD アイテムトリガー監視タイプ更新間隔ヒストリトレンドデフォルト説明ステータス pg.get pgsql.get.pg.bgwriter Zabb

nakayama15icm01_l7filter.pptx


MOTIF XF 取扱説明書

クラウド時代のインフラ構成/変更管理とコンプライアンス管理

Express5800/R110a-1Hユーザーズガイド

_55wSCS.ppt

Slide 1

P3FY-A JP.PDF

elemmay09.pub

HA8000-bdシリーズ RAID設定ガイド HA8000-bd/BD10X2

LC304_manual.ai

FortiGate Ver.4.0MR3Patch14 Information 1

スライド 1

2

Oracle Enterprise Manager 10g R2 Grid Control: データベース管理の新機能

以下の事項は 弊社の一般的な製品の方向性に関する概要を説明するものです また 情報提供を唯一の目的とするものであり いかなる契約にも組み込むことはできません 以下の事項は マテリアルやコード 機能を提供することをコミットメント ( 確約 ) するものではないため 購買決定を行う際の判断材料になさらな

内蔵ハードディスクユニット-20GB (PG-HD2E4H) 内蔵ハードディスクユニット-40GB (PG-HD4E4H)取扱説明書 HARD DISK DRIVE 20GB(PG-HD2E4H) HARD DISK DRIVE 40GB(PG-HD4E4H) USER'S GUIDE

Vol. 48 No. 4 Apr LAN TCP/IP LAN TCP/IP 1 PC TCP/IP 1 PC User-mode Linux 12 Development of a System to Visualize Computer Network Behavior for L

Complex Lab – Operating Systems - Graphical Console

RR-US470 (RQCA1588).indd

Fig. 1 Schematic construction of a PWS vehicle Fig. 2 Main power circuit of an inverter system for two motors drive


スライド 1

Configuring_01

Agenda Scalability Availability CAP Theorem Scalability Availability Consistency BASE Transaction

Fortigate Ver.4.0MR3Patch12 Information 1

untitled

2 3

On the Wireless Beam of Short Electric Waves. (VII) (A New Electric Wave Projector.) By S. UDA, Member (Tohoku Imperial University.) Abstract. A new e

取扱説明書の読み替え一覧表

RAID RAID 0 RAID 1 RAID 5 RAID * ( -1) * ( /2) * RAID A. SATA B. BIOS SATA ( 1) C. RAID BIOS RAID D. SATA RAID/AHCI 2 SATA M.2 SSD ( 2) ( (

帯域を測ってみよう (適応型QoS/QoS連携/帯域検出機能)

Plan of Talk CAS CAS 2 CAS Single Sign On CAS CAS 2 CAS Aug. 19, 2005 NII p. 2/32

LAN LAN LAN LAN LAN LAN,, i

,,.,,., II,,,.,,.,.,,,.,,,.,, II i

How to read the marks and remarks used in this parts book. Section 1 : Explanation of Code Use In MRK Column OO : Interchangeable between the new part

Transcription:

1

MySQL Replication & MySQL Fabric MySQL Global Business Unit Sales Consulting Manager, JAPAC 梶山隆輔 / Ryusuke Kajiyama

以下の事項は 弊社の一般的な製品の方向性に関する概要を説明するものです また 情報提供を唯一の目的とするものであり いかなる契約にも組み込むことはできません 以下の事項は マテリアルやコード 機能を提供することをコミットメント ( 確約 ) するものではないため 購買決定を行う際の判断材料になさらないで下さい オラクル製品に関して記載されている機能の開発 リリースおよび時期については 弊社の裁量により決定されます Oracle と Java は Oracle Corporation 及びその子会社 関連会社の米国及びその他の国における登録商標です 文中の社名 商品名等は各社の商標または登録商標である場合があります 3

MySQL の高可用性構成 レプリケーション ( 標準機能 ) 非同期 & 準同期データレプリケーション アプリケーション / AP サーバ MySQL+DRBD Linux 用のノード間データコピー アプリケーション / AP サーバ 負荷分散 フェールオーバー MySQL Server 非同期複製 MySQL Server MySQL Server 同期複製 MySQL Server 3 rd ベンダ製 HA ソフト利用 共有ディスクにデータを格納 アプリケーション / AP サーバ MySQL Cluster シェアードナッシング型高性能クラスタ アプリケーション / AP サーバ フェールオーバー 負荷分散 MySQL Server 共有ディスク MySQL Server MySQL Cluster 双方向 同期複製 MySQL Cluster 4

MySQL の高可用性ソリューション MySQL 5.6 レプリケーション Oracle VM Template Solaris Cluster Windows Cluster DRBD 自動フェールオーバー データロス無し Semi-Sync MySQL Cluster サポート OS All Linux Solaris Windows Linux All クラスタモード Master + Slaves Active/ Passive Active/ Passive Active/ Passive Active/ Passive Multi- Master 共有ディスク不要必要必要必要不要不要 可用性デザイン 99.9% 99.99% 99.99% 99.95% 99.99% 99.999% 単一ベンダサポート 5

Background: Replication Components Client Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B Master info Relay Log Info 6

MySQL レプリケーションの構成パターン マスタ > スレーブ マスタ > マルチスレーブ マルチマスタ > スレーブ ( マルチソース ) マスタ > スレーブ > マルチスレーブ マスタ < > マスタ ( マルチマスタ ) 循環型 ( マルチマスタ ) 8

Program Agenda MySQL 5.6 での改良点 MySQL 5.7 での改良点 MySQL Fabric 9

MySQL 5.6 での改良点 10

MySQL 5.6: Replication 改善点 パフォーマンス マルチスレッドスレーブ バイナリログのグループコミット 行ベースレプリケーションの転送データ量の削減 フェールオーバー & リカバリ Global Transaction Identifiers レプリケーションフェールオーバー & 管理ユーティリティ スレーブ & バイナリログの耐障害性向上 データの正確性 レプリケーションチェックサム 開発 & 管理の簡素化 遅延レプリケーション リモートからのバイナリログのバックアップ ログへのメタデータの追加 11

MySQL 5.6: グローバルトランザクション ID 複数台のレプリケーション環境でも容易にトランザクションの追跡 / 比較が可能 トランザクションを一意に識別できる識別子をバイナリログに記録 フェイルオーバーのために 最も最新のスレーブを自動認識 多段構成のレプリケーションが容易に Master GTID=123456 GTID=123456 GTID=123456 GTID=123456 12

MySQL 5.6: バイナリログのグループコミット Session T1 T3 T2 T4 Binary Log 複数トランザクションの情報をまとめてバイナリログに記録 Sync_binlog=1 の場合のオーバーヘッドを削減 Master Database Group commit バイナリログコミット部分のソースをリファクタし よりメンテナンスしやすいコードに改善 14

Binary Log Group Commit Performance Binlog=1 Transactions per Second 9000 8000 7000 6000 5000 4000 3000 2000 1000 0 MySQL 5.6 vs. 5.5 - Read Write (Linux) 32 64 128 Connections 180% Performance Gain MySQL 5.6 MySQL 5.5 Oracle Linux 6 Intel(R) Xeon(R) E7540 x86_64 MySQL leveraging: - 48 of 96 available CPU threads - 2 GHz, 512GB RAM 15

MySQL 5.6: 行ベースレプリケーションの最適化 Primary Key Changed Columns 新しいオプション : binlog-row-image=minimal マスター / スレーブのスループットを向上 - バイナリログのサイズ削減 メモリ使用量削減 ネットワーク転送量削減 変更された行イメージだけを保持 16

クラッシュセーフなスレーブ Atomic CRASH! Before: Data Position Info Time Transaction Data: in tables Replication Info: in files スレーブクラッシュ時の自動的なリカバリ - ポジション情報とデータは一貫性がある 管理者の介入なしにレプリケーションを再開可能 - 最後にコミットしたイベントに自動的にロールバック Atomic Data MySQL 5.6 Position Info Time Transaction Data: in tables Replication Info: in tables データの損失や破損のリスクを排除 17

チェックサムの追加 バイナリログにチェックサムを記録可能 (CRC32) binlog-checksum オプションで有効 / 無効を制御 マスターは バイナリログにイベントを記録する時に CRC32を生成 複数個所で誤り検出可能 マスターとスレーブでの誤り検出は 個別に有効 / 無効の設定が可能 (master-verify-checksum option slave-sql-verify-checksum ) イベント毎に CRC を記録 Binary Log File 18

MySQL 5.7 での改良点 19

MySQL 5.6 GA 以降の改良点 MySQL 5.7.2 - Development Milestone Release, September 2013 Higher Master Throughput Sender, aka Dump, Thread Does Not Take the Binary Log Lock. Higher Slave Throughout Multi-Threaded (Slave) Timestamp based Applier (MTS). Better Monitoring of Replication Instrumentation for getting replication status through performance schema. Loss-less Semi-sync Replication. 20

Higher Master Throughput: Sender, aka Dump, Thread Enhancement Client Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B Master info Relay Log Info 21

Higher Master Throughput: Sender, aka Dump, Thread Enhancement Concurrent reads by the sender thread with ongoing writes from user threads. Sender thread does not block user sessions more than necessary. Higher throughput for both sender threads and user sessions. pre 5.7.2 Sender Thread Reads Binary Log User Thread Writes to Binary Log 5.7.2+ Sender Thread Reads Binary Log User Thread Writes to Binary Log Time 22

Higher Slave Throughput: Timestamp based Multi-threaded Applier Client Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B Master info Relay Log Info 23

Higher Slave Throughput: Timestamp based Multi-threaded Applier Leverage parallelization information obtained from the execution on the master. Transactions that prepare on the same version of the database, are assigned the same timestamp. Meanwhile, at the slave: Transactions with the same timestamp can be executed in parallel; Concurrent transactions commit independently, thus no waiting involved. 24

T1 T2 T3 Higher Slave Throughput: Timestamp based Multi-threaded Applier Concurrent Execution History on the Master Execution Prepare Commit timestamp++ Time Commit Prepare Parallel on the Slave. Not Executed in Parallel. 26

Higher Slave Throughput: Timestamp based Multi-threaded Applier Supports statement-based or row-based formats. Scheduling policy controlled through: mysql> SET slave_parallel_type= [logical_clock database] Logical_clock - means schedule based on the prepare timestamp database - the scheduling policy from 5.6 (concurrency control done per database). Work to improve slave scalability continues, does not stop here. 27

Better Replication Monitoring: P_S Replication Tables Client Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B Master info Relay Log Info 28

Better Replication Monitoring: P_S Replication Tables Access monitoring information through an SQL interface. Write stored functions or procedures with input from replication internals. Logically unrelated information into different places. Flexible and easier to extend and adapt as new feature get into the server. More user friendly names identifying the monitoring fields. 29

Loss-less Semi-sync Replication Client Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B Master info Relay Log Info 31

Loss-less Semi-sync Replication Master does not commit transaction until it receives an ACK from a slave. (as opposed to: Master does not release the session until it receives an ACK from the slave.) Therefore, concurrent transactions do not externalize changes while waiting for ACK. Should a master fail, then any transaction that it may have externalized is also persisted on a slave. User can choose between the original semisync behavior and the new one. mysql> SET rpl_semi_sync_master_wait_point= [AFTER_SYNC AFTER_COMMIT] 32

Lossless 準同期レプリケーション Master App commits Written to Binary log Send to slave(s) Commit to SE & externalized Ack Commit Slave Write to relay log Apply txn マスターは指定のスレーブがトランザクションを受信するまで以下の処理を待つ ストレージエンジンへのコミット 他のクライアントから変更へのアクセス アプリケーションへのコミットの応答 スレーブが変更点を反映させるまでは待たない 遅延を最小化 スレーブに安全にコピーされるまで他のトランザクションが新しいデータを変更できないように 33

準同期レプリケーション MySQL 5.6 MySQL 5.7 Lossless Master App commits Slave Master App commits Slave Written to Binary log Written to Binary log Commit to SE & externalized Send to slave(s) Send to slave(s) Write to relay log Commit to SE & externalized Write to relay log Ack Commit Apply txn Ack Commit Apply txn 34

Loss-less Semi-sync Replication T1: INSERT INTO t1 VALUES (1000) T2: SELECT * FROM t1; empty set T2 Master execute prepare binlog commit ACK T1 Slave relaylog Time 35

MySQL 5.6 GA 以降の改良点 MySQL 5.7.3 - Development Milestone Release, December 2013 Improved Security SSL options for mysqlbinlog Flexible Semisync Durability Configure master to wait for more than one semisync slave to ACK back. More Production Friendly Changing Replication Filters Dynamically. 36

SSL options for mysqlbinlog mysqlbinlog Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B --read-from-remote-server Master info Relay Log Info 37

SSL options for mysqlbinlog --ssl* options to mysqlbinlog Reading binary logs from remote servers through a secure channel. Supports all SSL options that other client tools support. mysql> GRANT USAGE ON *.* TO 'rpluser'@'localhost' REQUIRE SSL; shell> mysqlbinlog --read-from-remote-server ssl -u rpluser... 38

Dynamic Slave Replication Filters Client Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B Master info Relay Log Info 39

Dynamic Slave Replication Filters Change Slave's Replication Filters dynamically. No need to stop and restart slave for establishing new replication filtering rules. All slave filters are supported. Values can be input in various character sets. mysql> CHANGE REPLICATION FILTER REPLICATE_DO_DB= (db1, db2) 40

Semi-sync Replication Wait for Multiple ACKs Client Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B Master info Relay Log Info 41

Semi-sync Replication Wait for Multiple ACKs Master does not commit transaction until it receives N ACKs from N slaves. Dynamically settable: mysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= N Master Slave 1 Slave 2 T1: COMMIT relaylog ACK relaylog ACK T1: COMMIT succeeds mysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= 2 Time 42

MySQL 5.6 GA 以降の改良点 MySQL 5.7.4 - Development Milestone Release, April 2014 Performance Sender thread enhancements. Semisync ACK Receiver thread. Flexibility Redirect to new master without stopping applying transactions. 43

Semi-sync Replication ACK Receiver Thread Client ACK Receiver thread Receiver thread Applier Threads binary log relay log binary log A Network B Sender thread Master info Relay Log Info 44

Semi-sync Replication ACK Receiver Thread Consecutive transactions do not block each other while waiting for ACKs Transaction t1 and t2 are sent immediately to the slave by the sender thread ACKs are received only by a special thread Transaction t2 does not include t1 round trip in its semisync overall latency Thread starts when semisync is activated mysql> SET GLOBAL rpl_semi_master_enabled= ON Thread stops when semisync is deactivated mysql> SET GLOBAL rpl_semi_master_enabled= ON 45

Semi-sync Replication ACK Receiver Thread Throughput on Master 14000 12000 Ad hoc microbenchmark using mysqlslap QpS 10000 8000 6000 4000 2000 0 0.2 0.5 1 2 10 20 50 100 Network Delay (ms) MySQL 5.7.3 MySQL 5.7.4 100K queries, commit=100, iterations=3 1 semisync slave Network delay example: tc qdisc add dev lo root netem delay 100ms 10X larger latency show 50% less throughput in 5.7.3 under peak load. 10X larger latency show 0% less throughput in 5.7.4 under peak load. 46

More Sender Thread Enhancements Client Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B Master info Relay Log Info 47

More Sender Thread Enhancement Send buffer is not allocated and freed every time an event is sent. When sender threads require larger send buffer buffer grows as needed. When buffer is larger than needed buffer shrinks dynamically. Together with the sender thread enhancements released on MySQL 5.7.2: increase master scalability; reduces resource consumption (CPU); Master, with dump threads attached, copes better with peak loads. 48

More Sender Thread Enhancements 16000 14000 Master's Throughput Ad hoc microbenchmark using mysqlslap QpS 12000 10000 8000 6000 4000 2000 0 0 1 5 10 20 30 40 50 100 Number of Slaves MySQL 5.6.16 MySQL 5.7.4 1M queries, concurrency=200, commit=1 N slaves attached (fake slaves using remote mysqlbinlogs) 48 cores HT / 512 GB RAM / HDD Small number of slaves: no difference between 5.6 and 5.7. Larger number of slaves: 5.7 is able to sustain the same throughput. 49

Redirect to new Master without interrupting the Applier Client Sender thread Receiver thread Applier Threads binary log relay log binary log A Network B Master info Relay Log Info 50

Redirect to new Master without interrupting the Applier More onlineness during fail-over: mysql> STOP SLAVE IO_TRHEAD; mysql> CHANGE MASTER TO MASTER_HOST='master2', ; Mysql> START SLAVE IO_THREAD; Stopping, changing master and restarting the receiver thread is all done while the applier thread is running. 53

マルチソースレプリケーション Master 1 Binlog Master 2 Binlog Master N Binlog 複数のマスターでの変更点を 1 台のスレーブに集約 IO 1 IO 2 IO N 全ての シャード のデータを単一のビューで分析 Relay 1 Relay 2 Relay N バックアップ用にデータを集約 Coordinator W1 W2 WX Coordinator W1 W2 WX Coordinator W1 W2 WX Coordinator W1 W2 WX 準同期レプリケーションおよびマルチスレッドスレーブに対応 マスターごとにフィルタと制御可能となる予定 Slave アプリケーションはマスタごとに個別にアクセス 54

Multi-Threaded Slave (MTS) 開発の履歴 Per-Database MTS release (labs) Binlog Group Commit (BGC) in 5.6.6 BGC tuning options. MTS enhancers (labs) 2010 2011 2012 2013 2014 Per-Database MTS on 5.6.3 MySQL 5.6 GA. Per-Transaction MTS in 5.7.2! 55

Multi-Threaded Slave (MTS) By tuning BGC on the master, we get more parallelism on the slave: binlog-group-commit-delay binlog-group-commit-count Tuning means more transactions preparing together (no magic formula highly dependent on hardware and workload). Still working on improving it and on the analysis of experimental results. TPS 4500 4000 3500 3000 2500 2000 1500 1000 500 Transactions Per Second 0 0 4 12 28 48 Number of Slave Worker Threads no commit delay small commit delay large commit delay 6X slave throughput large commit delay 3X slave throughput small commit delay 56

MySQL Fabric 57

MySQL Utilities 運用管理に関する Python スクリプト データベース管理 MySQL Utilities データベース運用 レプリケーション管理 設定管理 58

MySQL Fabric Application Connector mappings An extensible and easy-touse framework for managing a farm of MySQL servers supporting high-availability and sharding SQL MySQL Fabric Read-slaves Master group Read-slaves Master group 59

MySQL Utilities - Fabric Application Connector mappings SQL Read-slaves Read-slaves MySQL Fabric シャーディング による拡張性 コネクタ Python Java PHP アプリケーションでの分割キー Range または Hash シャード再構成も可能 シャード全体の更新も可能 MySQL Utilities 1.4.0 として提供 Master group Master group 60

High-Level Components Application Connector Connector Fabric-aware Connectors Python, PHP, and Java Enhanced Connector API MySQL Fabric Node Manage information about farm Provide status information Execute procedures MySQL Servers Organized in High-Availability Groups Handling application data MySQL Fabric Node High Availability Group Connector 61

MySQL Fabric Configuration Backing Store MySQL server Persistent storage for state Storage engine-agnostic Protocol Address where node will be Currently only XML-RPC Logging Chatty: INFO (default) Moderate: WARNING URL for rotating log [storage] address = localhost:3306 user = fabric password = database = fabric [servers] user = fabric password = [protocol.xmlrpc] address = localhost:32274 threads = 5 disable_authentication = yes [logging] level = INFO url = file:///var/log/fabric.log 62

MySQL Fabric: Basic Commands and Help Command Structure mysqlfabric group command... Getting help mysqlfabric help mysqlfabric help commands mysqlfabric help manage mysqlfabric help manage setup MySQL Utilities Documentation: http://dev.mysql.com/doc/mysql-utilities/1.4/en/index.html MySQL Fabric Documentation: http://dev.mysql.com/doc/mysql-utilities/1.4/en/fabric.html 63

Setting up and Tearing down MySQL Fabric Create and populate the necessary tables in backing store mysqlfabric manage setup Remove the tables from backing store mysqlfabric manage teardown Connects to the database server in storage section Ensure that you have the necessary users and privileges 64

Starting and Stopping MySQL Fabric Start MySQL Fabric node in foreground print log to terminal mysqlfabric manage start Start MySQL Fabric node in background print log to file mysqlfabric manage start --daemonize Stop MySQL Fabric node mysqlfabric manage stop 65

Create Groups and add Servers Define a group mysqlfabric group create my_group Add servers to group mysqlfabric group add my_group server1.example.com mysqlfabric group add my_group server2.example.com 66

Activate High-Availability Group Promote one server to be primary mysqlfabric group promote my_group Tell built-in failure detector to monitor group mysqlfabric group activate my_group 67

Distributed Failure Detector New in MySQL Fabric 1.4.2 Connector Connectors report errors Report that an error was noticed Failover based on statistics report_error(server, source, error) Report failure A server is known to have failed Failover occurs immediately report_fault(server, source, error) report_error report_fault 68

Fabric-aware Connector Fabric-aware Connectors Connector/J Connector/Python Connector/PHP Fabric-aware Frameworks Doctrine Hibernate In this presentation: Connector/Python Connector API Extensions Support Transactions Support full SQL Decision logic in connector Reducing network load Load Balancing Read-Write Split Distribute transactions 69

Fabric-aware Connector API Establish a virtual connection Real server connection established lazily Provide connection information for the Fabric node Connector will fetch information about servers import mysql.connector conn = mysql.connector.connect( fabric={"host": "fabric.example.com"}, user='mats', password='xyzzy', database="employees" ) 70

Enable Connector/Python Error Reporting New in Connector/Python 1.2.1 Connectors can report errors to Fabric node Enable using report_error Defaults to False Require MySQL Fabric 1.4.2 import mysql.connector conn = mysql.connector.connect( fabric={"host": "fabric.example.com"}, user='mats', password='xyzzy', database="employees", report_error=true, ) 71

Connector API: Executing a Transaction Provide group name Property: group Fabric will compute candidate servers Provide transaction mode Property: mode Fabric will pick server in right mode Same as before conn.set_property(group='my_group', mode=mode_readwrite) cur = conn.cursor() cur.execute("insert INTO employees VALUES (%s,%s,%s)", (emp_no, first_name, last_name)) cur.execute("insert INTO titles(emp_no,title,from_date)" VALUES (%s,%s,curdate())", (emp_no, 'Intern')); conn.commit() 72

MySQL Fabric: Set up Shard Mapping Define shard mapping mysqlfabric sharding \ create_definition hash my_global Add tables that should be sharded mysqlfabric sharding add_table 1 \ employees.employees emp_no mysqlfabric sharding add_table 1 \ employees.salaries emp_no Tables not added are considered global Will return a shard map identifier Shard map identifier 73

MySQL Fabric: Add Shards Add shards to shard mapping mysqlfabric sharding add_shard 1 \ my_group.1,...,my_group.n --state=enabled Shard map identifier 74

MySQL Fabric: Moving and Splitting Shards Moving a shard from one group to another Shard ID mysqlfabric sharding move 5 my_group.5 Splitting a shard into two pieces (hash) mysqlfabric sharding split 5 my_group.6 75

Connector API: Shard Specific Query Provide tables in query Property: tables Fabric will compute map Provide sharding key Property: key Fabric will compute shard conn.set_property(tables=['employees.employees', 'employees.titles'], key=emp_no) cur = conn.cursor() cur.execute("insert INTO employees VALUES (%s,%s,%s)", (emp_no, first_name, last_name)) cur.execute("insert INTO titles(emp_no, title, from_date)" " VALUES (%s, %s, CURDATE())", (emp_no, 'Intern')); conn.commit() 76

Connector API: Global Update Provide tables in query Property: tables Fabric will compute map (Not necessary) Set global scope Property: scope Query goes to global group conn.set_property(tables=['employees.titles'], scope='global') cur = conn.cursor() cur.execute("alter TABLE employees.titles ADD nickname VARCHAR(64)") 77

What do we have now? MySQL Farm Management High-Availability Sharding High-Availability Group Concept Slave promotion Sharding Range and hash sharding Shard move and shard split Connector APIs Transaction properties Virtual connections Enhanced Connectors Connector/Python Connector/PHP Connector/J Command-line Interface XML-RPC Interfaces Distributed failure detector Connectors report failures Custom failure detectors Credentials RFC 2617 SSL support 78

Thoughts for the Future Connector multi-cast Scatter-gather UNION of result sets More complex operations? Extension interfaces Improve extension support Improve procedures support Command-line interface Improving usability Focus on ease-of-use More protocols MySQL-RPC Protocol? More frameworks? More connectors? C/C++? Fabric-unaware connectors? More HA group types DRBD MySQL Cluster 79

Thoughts for the Future Transparent Sharding Single-query transactions? Speculative execution? Cross-shard join? Multiple shard mappings Independent tables Multi-way shard split Efficient initial sharding Better use of resources High-availability executor Node failure stop execution Replicated State Machine Paxos? Raft? Continue execution on other Fabric node Session Consistency We have a distributed database It should look like a single database 80

81

82

83