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

Similar documents
_UserForum_05-Repl_jp.pptx

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

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

スライド 1

PowerPoint Presentation

PowerPoint Presentation

MySQL Replication and Scalability

How to Use the PowerPoint Template

How to Use the PowerPoint Template

MySQL Cluster

スライド 1

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

データセンターの効率的な資源活用のためのデータ収集・照会システムの設計

スライド 1

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

PowerPoint Presentation

SRA OSS, Inc. のご紹介 1999 年より PostgreSQL サポートを中心に OSS ビジネスを開始 2005 年に現在の形に至る 主なビジネス PostgreSQL, Zabbix などの OSS のサポート コンサルティング 導入構築 PowerGres ファミリーの開発 販売

Microsoft PowerPoint - MySQL-backup.ppt

外部SQLソース入門

untitled

_04_Server57.pptx

PowerPoint Presentation

Safe Harbor Statement The following is intended to outline our general product direclon. It is intended for informalon purposes only, and may not be i

スライド 1

スライド 1

設定手順

_OBCI(MySQL).ppt

How to Use the PowerPoint Template

fx-9860G Manager PLUS_J

MySQL Cluster

How to Use the PowerPoint Template

Agenda Hadoop Sahara Kilo Q&A Copyright 2015 Mirantis, Inc. All rights reserved Page 2

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

アジェンダ はクラウド上でも十分使えます 1. の概要 とは の導入事例 で利用される構成 2. をクラウドで使う クラウドサービスの分類 Amazon Web Services による構成例 2

Oracle Change Management Pack, Oracle Diagnostics Pack, Oracle Tuning Packインストレーション・ガイド リリース2.2

untitled

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

PowerPoint Presentation

PowerPoint Presentation

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

はじめに

Table of Contents

HP OpenSource ブループリント

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

Agenda Scalability Availability CAP Theorem Scalability Availability Consistency BASE Transaction

GPGPU

ストラドプロシージャの呼び出し方

雲の中のWebアプリケーション監視術!~いまなら間に合うクラウド時代の性能監視入門~

Oracle Database 10g Release 2を使用したデータベース・パフォーマンス

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

【Cosminexus V9】クラウドサービスプラットフォーム Cosminexus

PowerPoint Presentation

スライド 1

test

April 2014 Flash-aware MySQL フラッシュが MySQL を変える Takeshi Hasegawa Senior Sales Engineer APAC Japan Fusion-io

Calpont InfiniDBマルチUM同期ガイド

How to Use the PowerPoint Template

MySQL5.5 MySQL

_55wSCS.ppt

Oracle Database 10gのOracle Data Guard

untitled

Oracle Real Application Clusters 10g Release 2: Microsoft SQL Server 2005との技術的比較

_02-4.ppt

Actual ESS Adapterの使用について

Sheepdog: 仮想化環境のためのクラスタストレージシステム

MySQL5.0データベース ログファイルおよびステータスの収集

Microsoft Azure Service Fabric によるレジリエントなマイクロサービスの構築

PowerPoint プレゼンテーション

FileMaker ODBC and JDBC Guide

untitled

PowerPoint Presentation

Web 環境におけるレイヤー別負荷の 2 違い DB サーバ AP サーバ 後ろのレイヤーほど負荷が高く ボトルネックになりやすい

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

nakayama15icm01_l7filter.pptx

Slide 1

PowerPoint -O80_REP.PDF

3 Powered by mod_perl, Apache & MySQL use Item; my $item = Item->new( id => 1, name => ' ', price => 1200,

untitled

Slide 1

CAC

2D/3D CAD データ管理導入手法実践セミナー Autodesk Vault 最新バージョン情報 Presenter Name 2013 年 4 月 2013 Autodesk

untitled


MySQL Cluster

Oracle Application Server 10g(9

PostgreSQL による クラスタ構成の可能性 SRA OSS, Inc. 日本支社 取締役支社長 石井達夫

RR-US470 (RQCA1588).indd

Windows Oracle -Web - Copyright Oracle Corporation Japan, All rights reserved.

スライド 1

untitled

PostgreSQL 9.4 評価検証報告 SRA OSS, Inc. 日本支社高塚遙 :55 ~ 16:30 PostgreSQL 9.4 最新情報セミナー Copyright 2014 SRA OSS, Inc. Japan All rights reserved. 1

RADIUS サーバを使用して NT のパスワード期限切れ機能をサポートするための Cisco VPN 3000 シリーズ コンセントレータの設定

mod_perl_jobworker

PowerPoint プレゼンテーション

データベースの近代化:シンプルなクロスプラットフォーム、最小のダウンタイムで実現するクラウド移行

意外と簡単!?

スライド 1

2 BIG-IP 800 LTM v HF2 V LTM L L L IP GUI VLAN.

IPSJ SIG Technical Report Vol.2014-EIP-63 No /2/21 1,a) Wi-Fi Probe Request MAC MAC Probe Request MAC A dynamic ads control based on tra

Table of Contents

Transcription:

MySQL ReplicaDon and MySQL Fabric Ryusuke Kajiyama / 梶山隆輔 MySQL Sales ConsulDng Senior Manager, Asia Pacific & Japan Copyright Copyright 2014, 2014, Oracle Oracle and/or and/or its its affiliates. affiliates. All Arll ights rights reserved. reserved.

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

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

MySQL レプリケーション Client Insert... binary log Sender thread Receiver thread relay log Applier Threads binary log A Insert... Network Insert... B Insert... Master Master info MySQL の標準機能 バイナリログの内容を転送する 標準では非同期型 設定で準同期を選択可能 スレーブでも参照処理可能 Relay Log Info Slave

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

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

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

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

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

Enhancements in MySQL 5.7

MySQL 5.6 GA 以降の改良点 5.7.2 DMR 5.7.3 DMR 5.7.4 DMR マスタでの送信とバイナリログ書き込みスレッドの並列実行 タイムスタンプベースでのマルチスレッドスレーブ パフォーマンススキーマでのレプリケーション関連性能統計情報 Lossless 準同期レプリケーション mysqlbinlog コマンドへの SSL オプション追加 スレーブでのフィルタリングの動的な変更 準同期レプリケーションにて複数のスレーブからの応答を待つ マスターの送信スレッド用バッファの改良 準同期レプリケーションのマスターでの ACK 受信専用スレッド SQL スレッドを動作させたままのマスター切り替え

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

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

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

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

準同期レプリケーション MySQL 5.6 MySQL 5.7 Lossless Master App commits Slave Master App commits Slave Wrigen to Binary log Wrigen 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

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

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

MySQL 5.6 GA 以降の改良点 MySQL 5.7.5 - Development Milestone Release, September 2014 More opdons to tune Binary Log Group Commit Improving performance of Master and more parallelism on Slaves Storing GTID into MySQL system table Not in log files

The Binary Log Group Commit MySQL 5.7.5 has more opdons to tweak the pipeline. binlog_group_commit_sync_delay To introduce an ardficial delay in the SYNC stage. binlog_group_commit_sync_no_delay_count To stop waidng if delay_count was reached.

The Binary Log Group Commit F L FLUSH QUEUE L F F SYNC QUEUE L F COMMIT QUEUE Group Commit Procedure l If the transacdon incoming rate is moderate. l If there are many small groups being fsync'ed. l TIPS: SET binlog_group_commit_sync_delay > 0 l ArDficially delays the leader thread on the SYNC stage, to increase the chance to group more flushes together before fsyncing. l By tuning BGC on the master, we get more parallelism on the slave.

Storing GTIDs In a Table GTIDs are saved into a mysql system table. CREATE TABLE gtid_executed( source_uuid CHAR(36) NOT NULL, interval_start BIGINT NOT NULL, interval_end BIGINT NOT NULL, PRIMARY KEY(source_uuid, interval_start) ); GTIDs are inserted into the table as transacdons commit. A compression thread runs periodically and compress the table into ranges. New global variable controls the period: executed_gdds_compression_period. mysql> SET GLOBAL executed_gtids_compression_period= N;

MySQL 5.7: MulD- Source ReplicaDon labs.mysql.com 複数のマスターでの変更点を 1 台のスレーブに集約 Master 1 Binlog Master 2 Binlog Master N Binlog 全てのシャードのデータを集約 より柔軟なレプリケーション構成 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 55

MySQL 5.7: スキーマ内マルチスレッドスレーブ labs.mysql.com シングルスレッドのスレーブと比較して 5 倍のスループット アプリケーション側での変更不要 バイナリログのグループコミットでの遅延を伴う操作不要 GTID & クラッシュセーフスレーブ利用 Sysbench OLTP test 1,000 万行 SSD / 48 core HT / 512 GB RAM 5000 4500 4000 3500 3000 2500 2000 1500 1000 500 0 Slave Transac-ons per Second Baseline 50 clients 100 clients 150 clients 200 clients 0 4 16 25 50 100 200 Worker Threads 56

MySQL 5.7: グループレプリケーション labs.mysql.com ApplicaDon MySQL Masters MySQL Server API ReplicaDon Plugin Group Comms (Corosync) シェアード ナッシング型 疑似 同期レプリケーション 更新はマルチ マスタ型でどこでも可能 矛盾の検知と解決 ( トランザクションのロールバック ) OpDmisDc State Machine レプリケーション グループメンバーの管理と障害検知を自動化 サーバのフェールオーバー不要 構成の拡張 / 縮小の柔軟性 単一障害点無し 自動再構成 既存構成との統合 InnoDB GTIDベースのレプリケーション PERFORMANCE_SCHEMA 57

MySQL Fabric for high availability and scalability with MySQL Replica-on

MySQL Fabric 1.5: 高可用性 & シャーディング GA ApplicaDon Connector ApplicaDon Connector SQL mappings MySQL Fabric OpenStack との統合 高可用性 サーバの監視 ; スレーブの自動昇格と透過的なレプリケーション切り替え シャーディングによる拡張性 アプリケーションがシャードのキーを提供 整数型 日付型 文字列型 レンジまたはハッシュ シャード再構成可能 Read- slaves Read- slaves Fabric 対応コネクタ利用 : Python, Java, PHP,.NET, C (labs) HA group HA group プロキシを使わないので低レイテンシ ボトルネック無し 59

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

MySQL Fabric ConfiguraDon Backing Store MySQL server Persistent storage for state Storage engine- agnosdc Protocol Address where node will be Currently only XML- RPC Logging Chagy: INFO (default) Moderate: WARNING URL for rotadng 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

High- Availability Group Concept Abstract Concept Set of servers Server agributes Connector Agributes ConnecDon informadon Mode: read- only, read- write,... Weight: distribute load Management Agributes State: state/role of the server State: Mode: Host: Primary Read- Write server- 1.example.com 63

Create HA 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 64

Create HA Groups and add Servers Promote one server to be primary mysqlfabric group promote my_group Tell failure detector to monitor group mysqlfabric group activate my_group 65

Benefits of Sharding Write scalability Can handle more writes Large data set Database too large Does not fit on single server Improved performance Smaller index size Smaller working set Improve performance (reads and writes) UID 10000-20000 UID 20001-40000 66

Sharding Architecture MySQL Fabric Node Connector Global Updates Global Group Replica-on Connector Applica-on Connector Shard Updates Shards 68

MySQL Fabric: Sharding Setup Set up some groups my_global for global updates my_group.n for the shards Add servers to the groups Create a shard mapping A distributed database Mapping keys to shards Give informadon on what tables are sharded Add shards 69

MySQL Fabric: Moving and SpliYng Shards Moving a shard (id=5) from exisdng group to another (my_group.8) mysqlfabric sharding move 5 my_group.8 Splixng a shard (id=5) into two parts with new half stored in group my_group.6 mysqlfabric sharding split 5 my_group.6 70

Connector API: Shard Specific Query Indicate tables to be used in query Property: tables Fabric will compute map Indicate read- only queries Property: mode Provide sharding key Property: key Fabric will compute shard Joins within the shard (or with global tables) supported conn.set_property(tables=["test.subscribers"], key=sub_no, mode=fabric.mode_readonly) cur = conn.cursor() cur.execute( "SELECT first_name, last_name FROM subscribers WHERE sub_no = %s", (sub_no) ) for row in cur: print row 71

Connector API: Global Update Set global scope Property: scope Query goes to global group conn.set_property(tables=[], scope='global') cur = conn.cursor() cur.execute("alter TABLE test.subscribers ADD nickname VARCHAR(64)") 72

MySQL Fabric: OpenStack との連携 クラウド環境での運用効率化 MySQL Fabric 高可用性 & シャーディング マシンと MySQL のプロビジョニング OpenStack Nova 対応予定 : Trove, AWS サーバのセットアップ スレーブの複製 レプリケーションの設定 73

Server Provisioning OpenStack Nova IntegraDon > mysqlfabric provider register my_stack \ my_user my_password \ http://8.21.28.222:5000/v2.0/ \ --tenant=my_user_role \ --provider_type=openstack " > mysqlfabric machine create my_stack \ --image id=8c92f0d9-79f1-4d95- b398-86bda7342a2d \ --flavor name=m1.small " > mysqlfabric machine list my_stack " " Fabric creates new machines, & MySQL Servers IniDally using OpenStack Nova Other frameworks on the way (OpenStack Trove, AWS, ) Server setup Clones slave Sets up replicadon Performs custom operadons 74

MySQL Fabric executor Events Event driven Events will trigger execudon of procedures Procedures can trigger events themselves Each step of a procedure is called a job Procedures Wrigen in Python Interacts with servers Write state changes into backing store Lock manager for conflict resoludon ConservaDve two- phase locking strategy Avoid deadlocks Backing Store Queue

MySQL Fabric Current LimitaDons RouDng is dependent on Fabric- aware connectors Currently Java (+ Hibernate), PHP (+ Doctrine), Python,.NET & C (labs) MySQL Fabric node is a single (non- redundant process) HA Maintained as connectors condnue to route using local caches Establishes asynchronous replicadon Manual steps to switch to semisynchronous Sharding not completely transparent to applicadon (must provide shard key column from applicadon schema) No cross- shard joins or other queries Management is through CLI, MySQL protocol or XML/RPC API No GUI 77

MySQL レプリケーション +MySQL Fabric の用途 スケーラビリティ 大規模な Web やクラウドで求められる参照更新処理の拡張性向上を実現 可用性 データの複製を持たせ マスターに障害が発生した場合は自動的に切り替え 集計処理やバックアップ オンラインでの処理から処理を分離することによって全体の性能を維持 クラウド対応 地理的冗長性のみでなく クラウドへの MySQL サーバ群の動的な展開