20150920 中国地方db勉強会
TRANSCRIPT
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
MySQL Global Business Unit Yoshiaki Yamasaki / 山﨑 由章 MySQL Senior Sales Consultant, Asia Pacific and Japan
MySQL 開発最新動向
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
以下の事項は、弊社の一般的な製品の方向性に関する概要を説明するものです。 また、情報提供を唯一の目的とするものであり、いかなる契約にも組み込むことはできません。 以下の事項は、マテリアルやコード、機能を提供することをコミットメントするものではない為、購買決定を行う際の判断材料になさらないで下さい。 オラクル製品に関して記載されている機能の開発、リリースおよび時期については、 弊社の裁量により決定されます。
SAFE HARBOR STATEMENT
2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
A Year of Anniversaries!
20 Years:
10 Years:
5 Years:
MySQL Initial Release
Oracle stewardship of InnoDB
Oracle stewardship of MySQL
Thank You, MySQL Community, for 20 years of Contributions to MySQL!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
A Year of Anniversaries!
15年
日本MySQLユーザー会
ドメイン登録から
2015年10月30日に、東京で15周年イベントを計画中!!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 5
MySQL Mile Stone
4.0 全文検索/GIS (MyISAM) 複数テーブルUPDATE/DELETE 組み込みライブラリ型サーバ
Oracle MySQL Sun
3.23 MyISAM InnoDB レプリケーション
5.1 プラグガブル・ ストレージエンジン・ アーキテクチャ パーティショニング タスクスケジューラ
5.6 memcached API UNDO表領域 Global Transaction ID マルチスレッドスレーブ オンラインALTER TABLE トランスポータブル表領域
5.5 InnoDBがデフォルトに 準同期型レプリケーション PERFORMANCE_SCHEMA
1.0-3.22以前 ストレージエンジン (ISAM, HEAP) マルチスレッド Windows対応/64bit対応 日本語文字コード (SJIS/UJIS)
5.0 ストアドプロシージャ ストアドファンクション カーソル/トリガ/ビュー XAトランザクション INFORMATION_SCHEMA
4.1 Unicode対応 サブクエリ CSV, ARCHIVE ndbcluster
1995 2000 2005 2010 2015
5.7+ 新コストモデル オプティマイザ ロスレス レプリケーション マルチソース レプリケーション グループ レプリケーション 全文検索CJK対応/GIS (InnoDB) セキュリティ強化 データディクショナリ NoSQLオプション
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL YUM/APTレポジトリ
• MySQL 5.6 GA, 5.7 DMRなど最新のコミュニティ版を提供
• 以下のディストリビューションをサポート – Red Hat Enterprise Linux, Oracle Linux
– Fedora
– Debian, Ubuntu
• 下記サイトからレポジトリを追加し、パッケージマネージャにて 各種MySQLプログラムをインストール可能に – MySQL Yum Repository http://dev.mysql.com/downloads/repo/yum/
– MySQL APT Repository http://dev.mysql.com/downloads/repo/apt/
6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
GitHubへのMySQLソースコードの掲載
• MySQL開発チームのGit –各ディストリビューションにてより迅速、柔軟に
–優れたツールの利用が可能に
–幅広くいコミュニティとの交流
• GitHub for MySQL Community –コミュニティや関連プロジェクトへのより簡単かつ高速なソースコードの提供
–レポジトリ: https://github.com/mysql
–詳細: http://mysqlrelease.com
7
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
日本語マニュアルが公開されました!!
• MySQL Developer Zone(http://dev.mysql.com/)にてマニュアル類を公開しています
• 以下のドキュメントは2015年6月に日本語版が公開されました – MySQL 5.6 リファレンスマニュアル (含むMySQL Cluster 7.3-7.4マニュアル)
http://dev.mysql.com/doc/refman/5.6/ja/index.html
– MySQL Enterprise Monitor 3.0.18 マニュアル http://dev.mysql.com/doc/mysql-monitor/3.0/ja/index.html
– MySQL Enterprise Backup ユーザーズガイド (バージョン 3.11.1) http://dev.mysql.com/doc/mysql-enterprise-backup/3.11/ja/index.html
• 上記日本語版公開以降に英語版ドキュメントのみ修正されている内容も あるため、ドキュメント参照時は英語版ドキュメントも合わせてご参照下さい。 (URLの”ja”部分を”en”に変更すると、英語版ドキュメントが表示可能)
8
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Enterprise Edition
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
1万人規模の社員が利用する基幹業務システムでの利用 SCSK株式会社
10
アプリケーション
経費精算、勤怠管理や業務ワークフローシステムなど1万人規模の社員が利用する基幹システム。
MySQLを利用して個別に構築されていた業務システムを統合。
MySQL導入の効果
MySQL Enterprise Monitorによる包括的な監視と、Query Analizerでの高速かつ高度なクエリ性能分析によって、高品質なシステムを短期間で実現。
MySQL導入の理由
事前評価での技術面およびコスト面での優位性を確認。サポートサービスや管理ツールが包含されており、企業システムにも安心して導入可能。
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
世界最大規模のバイオメトリクス国民ID管理システム UIDAI: Unique Identification Authority of India
11
アプリケーション
インド固有識別番号庁 (UIDAI: Unique Identification Authority of India)が導入を進める、Aadhaarと呼ばれる国民ID番号。2014年1月に6億ID突破。政府機関だけではなく、金融機関や通信業者からも利用。
MySQL導入の効果
UIDマスタデータベースとしてシャード構成の商用版MySQLサーバにて安定稼働中。
MySQL導入の理由
ACIDなトランザクションに対応し、システムの成長に応じて段階的に拡張ができるスケールアウト構成が取りやすい点。
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
管理ツール 拡張機能 サポート
•拡張性 •高可用性 •セキュリティ •監査 •暗号化
•監視 •バックアップ •開発 •管理 •マイグレーション
•技術サポート •コンサルティングサポート •オラクル製品との 動作保証
MySQL Enterprise Edition のサービスカテゴリー
12
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Enterprise Edition
MySQL Enterprise Monitor 複数サーバの一括管理、クエリ性能分析
MySQL Enterprise Backup 高速なオンラインバックアップ、ポイントインタイムリカバリ
MySQL Enterprise Scalability Thread Poolプラグインによる性能拡張性の向上
MySQL Enterprise Authentication LDAPやWindows Active Directoryとの外部認証と統合管理
MySQL Enterprise Audit ユーザ処理の監査、Oracle DBと同じツールで管理可能
MySQL Enterprise Encryption 非対称暗号化(公開鍵暗号)の業界標準機能を提供
MySQL Enterprise Firewall SQLインジェクション対策
Oracle Enterprise Manager for MySQL Oracle Enterprise ManagerからMySQLを統合管理可能
Oracle Premier Support 24x7, インシデント無制限、コンサルティングサポート
13
MySQL Enterprise Edition管理ツールと拡張機能概要
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
“バーチャルなMySQL DBA” アシスタント
MySQL Enterprise Monitor
• 複数のMySQLサーバを一括監視可能なダッシュボード
• システム中のMySQLサーバやレプリケーション構成を自動的に検出し監視対象に追加
• ルールに基づく監視と警告
• 問題が発生する前に通知
• 問題のあるSQL文の検出、統計情報の分析が可能なQuery Analyzer
参照: MySQL Enterprise Monitor
14
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
クエリ解析機能 - MySQL Query Analyzer
• 全てのMySQLサーバの
全てのSQL文を一括監視
• vmstatなどのOSコマンドやMySQLの
SHOWコマンドの実行、
ログファイルの個別の監視は不要
• クエリの実行回数、エラー回数、
実行時間、転送データ量などを一覧表示
• チューニングのための解析作業を省力化
“With the MySQL Query Analyzer, we were able to identify and analyze problematic SQL code, and triple our database performance. More importantly, we were able to accomplish this in three days, rather than taking weeks.” Keith Souhrada Software Development Engineer Big Fish Games
15
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Enterprise Backup
•オンラインバックアップ/リカバリ
•クラウドストレージへバックアップ
•差分バックパック & ポイントインタイムリカバリ
MySQL Enterprise Security
•外部認証との統合 (PAM, Windows, LDAP, etc.)
•MySQL Enterprise Monitorでのセキュリティアドバイザ
MySQL Enterprise Encryption
•AES256による対称暗号
•公開鍵方式 / 非対称暗号
•暗号学的ハッシュによる電子署名、照合および妥当性確認
MySQL Enterprise Audit •接続、ログインおよびSQL実行の記録
•ポリシーベースのフィルタリングおよびログ切り替え
•オラクルの監査仕様に準拠したXMLベースの出力
MySQL Enterprise Editionによるデータ保護
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Enterprise Firewall • SQLインジェクション対策、リアルタイムで保護
– ホワイトリストモデル、実行されるクエリーを分析してホワイトリストと照合
• 学習してホワイトリストを自動作成
– ユーザー毎に、SQL実行パターンを記録して自動的にホワイトリストを作成
• 不審なアクセスをブロック
– ポリシーに違反するトランザクションを検知し、ブロック
• 透過的
– アプリケーションを変更する必要無し
17
NEW
Select *.* from employee where id=22
Select *.* from employee where id=22 or 1=1
Block & Log ✖
Allow & Log ✔
White List Applications
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Supportの特徴
18
• 「パフォーマンス・チューニング」や 「SQLチューニング」まで通常サポートの範囲内 • コンサルティングサポートが含まれており、「クエリ・レビュー」、「パフォーマンス・チューニング」、「レプリケーション・レビュー」、「パーティショニング・レビュー」などに対応可能
• 詳細はこちらを参照下さい http://www-jp.mysql.com/support/consultative.html
•ソースコードレベルでサポート可能 • ほとんどのサポートエンジニアがソースを読めるため、対応が早い
• 開発エンジニアとサポートエンジニアも密に連携している
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Supportの特徴
19
•物理サーバー単位課金 • CPU数、コア数に依存しない価格体系
•オラクルのライフタイムサポート • 詳細はこちらを参照下さい
http://www.oracle.com/jp/support/lifetime-support/index.html http://www-jp.mysql.com/support/
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Enterprise Edition & Cluster CGEの試使用
20
• Oracle Software Delivery Cloud http://edelivery.oracle.com/
• 製品パックを選択: “MySQL Database”
• 製品マニュアル http://dev.mysql.com/doc/index-enterprise.html
30日間トライアル
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 Release Candidate Available!
22
InnoDBの機能拡張: Online&Bulk load オペレーション高速化
レプリケーションの改善 (multi-source, multi-threaded slaves等)
新しいオプティマイザコストモデル: greater user control & better query performance
Performance Schema改善
MySQL SYS Schema改善
パフォーマンス & 拡張性 管理性
MySQL 5.6比2倍の速度
セキュリティの向上: より安全な初期化, セットアップ&管理
JSONのSupport
RC
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7 RCにおける主な改良点
• InnoDB: トランザクション処理性能、可用性、IO性能の向上
• Optimizer: より詳細なEXPLAIN、パーサ、SQL処理性能
• Lock: 単一コネクションで複数のユーザレベルロック、リファクタリング
• 機能拡張: Trigger, 32k and 64k pages, クエリ・リライト・プラグイン,生成列
• 全文検索: InnoDB 全文検索、中国語、日本語、韓国語対応
23
Available Now! dev.mysql.com/downloads/mysql/
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
0
100,000
200,000
300,000
400,000
500,000
600,000
700,000
8 16 32 64 128 256 512 1,024
Qu
eri
es
pe
r Se
con
d
Connections
MySQL 5.7: Sysbench Read Only (Point Select)
MySQL 5.7
MySQL 5.6
MySQL 5.5
MySQL 5.7: Sysbench Benchmark
Intel(R) Xeon(R) CPU E7-4860 x86_64 4 sockets x 10 cores-HT (80 CPU threads) 2.3 GHz, 512 GB RAM Oracle Linux 6.5
645,000 QPS
24
MySQL 5.6より2倍高速
MySQL 5.5より3倍高速
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7: InnoDB, NoSQL With Memcached MySQL 5.6より6倍以上高速
0
200,000
400,000
600,000
800,000
1,000,000
1,200,000
8 16 32 64 128 256 512 1,024
Qu
eri
es
pe
r Se
con
d
Connections
MySQL 5.7 vs 5.6 - InnoDB & Memcached
MySQL 5.7
MySQL 5.6
25
Intel(R) Xeon(R) CPU E7-4860 x86_64 4 sockets x 10 cores-HT (80 CPU threads) 2.3 GHz, 512 GB RAM Oracle Linux 6.5
1,000,000 QPS Thank you, Facebook
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7: 秒間接続数
MySQL 5.6より1.7倍高速
0
10,000
20,000
30,000
40,000
50,000
60,000
70,000
80,000
MySQL 5.5 MySQL 5.6 MySQL 5.7
Co
nn
ect
ion
s/Se
con
d
Connections Per Second
MySQL 5.5
MySQL 5.6
MySQL 5.7
26
Intel(R) Xeon(R) CPU E7-4860 x86_64 4 sockets x 10 cores-HT (80 CPU threads) 2.3 GHz, 512 GB RAM Oracle Linux 6.5
参照:Improving connect/disconnect performance
67,000 接続/秒 MySQL 5.5より2.5倍高速
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
オプティマイザ – 新コストモデル
• 新しいコストモデルによりストレージエンジンでの処理を改善 –より正確で動的なコスト見積もり
–キーの参照、テーブルスキャン、レンジスキャン、インデックススキャンなど
–コストベースの意思決定で、経験則のみに基づく判断を回避
• インデックスからレコードへの参照の見積もり改善
• コスト値はEXPLAINのJSON出力に含まれる
• 様々な追加要素にてコストを設定可能 –ディスクI/O処理性能
–メモリ処理性能
27
SQL文の実行性能を向上
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
オプティマイザ – その他
• INを用いた問いクエリ処理の最適化
• フルテキストクエリ処理の最適化
• より効率の良いソート処理
• SQL標準に準拠した”ONLY_FULL_GROUP_BY” SQLモード
28
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Avoid Creating Temporary Table for UNION ALL UNION ALLクエリ実行時、一時テーブルを不使用
SELECT * FROM T_UNION01 UNION ALL SELECT * FROM T_UNION02;
• 5.6: 常にすべてのUNIONの結果を一時テーブルで実現する。
• 5.7: ソート処理に使用されない限り、結果は一時テーブルを利用せずクライアントに直接送信されます
• 5.7: 最後の問合せブロックが終了するまで待つ必要が無い為、クライアントは最初の行を直ぐに受け取る事が可能
• 5.7: 少ないメモリとディスク消費量
参照:MySQL 5.7: only_full_group_by Improved
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
オプティマイザ – JSON EXPLAINへのコスト情報追加
• JSON EXPLAINを拡張 –出力可能なコスト情報を全て表示
– MySQL WorkbenchのVisual Explainにも表示
30
{ "query_block": { "select_id": 1, "cost_info": { "query_cost": "200.40" }, "table": { "table_name": "nicer_but_slower_film_list", "access_type": "ALL", "rows_examined_per_scan": 992, "rows_produced_per_join": 992, "filtered": 100, "cost_info": { "read_cost": "2.00", "eval_cost": "198.40", "prefix_cost": "200.40", "data_read_per_join": "852K" }, "used_columns": [ "FID", "title", "description", "category", "price", "length", "rating", "actors" ], ...
より具体的な値をベースに最適化を実施
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
クエリ・リライト・プラグイン
• クエリの書き換え (パースの前と後)
• パースした後での書き換えプラグイン
–アプリケーションを変更することなく問題のあるクエリを書き換え
–ヒントの追加
–JOIN順の変更
• ORマッパーやサードパーティ製のアプリなどが発行する 問題となり得るクエリなどに対応
31
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 32
クエリ・リライト・プラグイン – Sample View
Rewrite Rule
Rewrite Result
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
InnoDBの強化
• General Tablespace Support
• Native partitioning Support
• InnoDB Temporary Tables
• InnoDB New Compression
• Additional Support for 32K and 64K pages size
• Generated Column Support
33
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
InnoDBの強化
• 全文検索の日本語対応 – ngram
– Mecab
• GIS機能の再実装 – Boost.Geometryとの統合
– InnoDB Spatial Indexes
• JSON形式サポート –ネイティブJSON型
– JSON関数
34
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• 独自コードの置き換え –空間図形情報の計算
–空間図形情報の分析
• OGC(Open Geospatial Consortium)準拠 –パフォーマンスの向上
• Boost.Geometryによる効果 –エキスパートとの交流
–非常に活発なコミュニティ
• Boost.Geometryへのコントリビュートも
MySQL 5.7: GIS - Boost.Geometryとの統合
35
例)ALTER TABLE テーブル名 add SPATIAL index(列名);
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• R-tree based
–完全なトランザクション·サポート
–ファントムリードを防ぐロック
–最小範囲のレコードを含む • 小さく、コンパクト
–現在は二次元データのみサポート • 将来的に三次元データもサポート予定
– Historical spatial Index DDL構文をサポート
GIS - InnoDB Spatial Indexes
36
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON形式サポート
• ネイティブJSONデータ型 –効率的なデータ処理と保管に,ネイティブな内部バイナリ形式をサポート。
• 組み込みJSONファンクション
–効率よくドキュメントを保存,検索,更新,操作する事を可能にします。
• JSON コンパレーター –文書データを容易にSQLクエリと統合することが可能
• Generated Columnsを利用し、ドキュメントにインデックスを利用する事が可能。 –新しいアナライザーは自動的に,利用可能で最適な機能インデックスを利用します。
37
参照: 12.16.1 JSON Function Reference
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON関数
38
新しいデータ型としてJSON型をサポートしています。 JSON型は格納されるデータ形式が正しいかを 自動的にチェックするDocument Validationを持ち、 ドキュメントをバイナリ化して格納することで 参照性能の向上を図っています。
CREATE TABLE `T_JSON` ( `id` int(10) NOT NULL AUTO_INCREMENT, `body` json DEFAULT NULL, `WithTax` decimal(10,2) GENERATED ALWAYS AS (json_extract(body,'$.price')*1.08) VIRTUAL, PRIMARY KEY (`id`), KEY `idx_total_cost_v` (`WithTax`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4
JSON_APPEND() JSON_OBJECT() JSON_ARRAY_INSERT() JSON_CONTAINS() JSON_CONTAINS_PATH() JSON_EXTRACT() JSON_KEYS() JSON_SEARCH() more ….
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSONデータの検索 Generated Columnを利用した,高速なドキュメントのインデックス検索
39
Generated Columnにて作成した列に対して、 作成したインデックスを利用する事により、 JSONドキュメントの検索にインデックスを利用可能
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7におけるレプリケーションの強化
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7におけるレプリケーションの機能拡張
•マルチソースレプリケーション
•マルチスレッドスレーブ
•オンラインでGTIDモードへ移行可能
•レプリケーションフィルタを動的に設定可能
•グループレプリケーション [Labs]
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• 複数のマスターでの変更点を1台 のスレーブに集約 –全てのシャードのデータを集約
–より柔軟なレプリケーション構成
–バックアップ処理を集約
• 準同期レプリケーション&改良版 マルチスレッドスレーブ対応
• スレーブ側でのフィルタリングが可能
MySQL 5.7: Multi-Source Replication
Binlog
Master 1
Binlog
Master 2
…
…
Binlog
Master N
IO 1
Relay 1
Coordinator
W1 W2 … WX
IO 2
Relay 2
Coordinator
W1 W2 … WX
…
…
Coordinator
W1 W2 … WX
IO N
Relay N
Coordinator
W1 W2 … WX
Slave
42
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• シングルスレッドのスレーブと比較して 5倍 のスループット –アプリケーション側での変更不要
–バイナリログのグループコミットでの遅延を伴う操作不要
• GTID & クラッシュセーフスレーブ利用
• Sysbench OLTP test
– 1,000万行
– SSD / 48 core HT / 512 GB RAM
MySQL 5.7: スキーマ内マルチスレッドスレーブ
0
500
1000
1500
2000
2500
3000
3500
4000
4500
5000
0 4 16 25 50 100 200
Worker Threads
Slave Transactions per Second
Baseline
50 clients
100 clients
150 clients
200 clients
43
--slave-parallel-type 1. DATABASE : (Default) Use the db partitioned MTS (1 worker per database)
2. LOGICAL_CLOCK: Use logical clock based parallelization mode.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
44
GTIDモード(gtid_mode)レプリケーションへのオンライン移行
参照:Enabling Global Transaction Identifiers Without Downtime in MySQL 5.7.6
1. Disable all write operations. 2. Wait for all transactions to propagate from the master(s) to all slaves. 3. Stop all servers. 4. On each server, set gtid-mode=ON in the configuration file. 5. Start all servers. 6. Enable write operations.
It is still possible to use the old, offline procedure. The procedure is as follows:
Offline procedure Online procedure
詳細: 17.1.5.2 Enabling GTID Transactions Online 17.1.5.4 Verifying Replication of Anonymous Transactions
1 SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = WARN;
2 SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = ON;
3 SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
4 SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
5 SHOW STATUS LIKE 'ONGOING_ANONYMOUS_TRANSACTION_COUNT';
6 SET @@GLOBAL.GTID_MODE = ON;
7 On each server, add gtid-mode=ON to my.cnf.
8 STOP SLAVE ; CHANGE MASTER TO MASTER_AUTO_POSITION = 1; START SLAVE;
各サーバーで以下のコマンドを実行
MySQL Replicationの設定や運用を簡素化する為に、GTIDモードのレプリケーションを利用する方法がありますが、 既にGTIDモード以前のレプリケーションで運用されている場合は、稼働中の全てのサーバーを停止してからGTIDモードのレプリケーションへ 移行する必要がありました。しかし、稼働中のサービスを停止して切り替える事は難しいのが現実です。 MySQL 5.7.6 以降のMySQLにアップグレードする事で、オンラインのままMySQLのレプリケーションを切り替える事が出来るようになりました。
5.6.x Standard
Replication
5.7.6~ Standard
Replication
5.7.6 ~ GTID Mode Replication
① ②
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 45
MySQL Slave Replication Filters Dynamic
REPLICATE_DO_DB REPLICATE_IGNORE_DB REPLICATE_DO_TABLE REPLICATE_IGNORE_TABLE REPLICATE_WILD_DO_TABLE REPLICATE_WILD_IGNORE_TABLE REPLICATE_REWRITE_DB
MySQL-5.7.3の新しく導入された “CHANGE REPLICATION FILTER” コマンドを利用する事で、 ユーザーは*slave* 側のレプリケーションフィルターを動的に、サーバーの再起動せずに適用する事が可能です。
MySQL-5.7.3以前は、ユーザーはOptionファイル(my.cnf)か、コマンドラインパラメータを使用してフィルタリング ルールを設定することが出来ますが、いずれの場合もMySQLサーバはフィルタリングルールの変更を反映する 為に再起動する必要があります。
The following slave replication filters can be changed dynamically using this command.
mysql> STOP SLAVE SQL_THREAD; Query OK, 0 rows affected (0.05 sec) mysql> CHANGE REPLICATION FILTER REPLICATE_DO_DB=(db1); Query OK, 0 rows affected (0.00 sec)
例) フィルター設定手順
参照:MySQL-5.7.3- Making MySQL Slave Replication Filters Dynamic
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
• シェアード・ナッシング型”疑似”同期レプリケーション
• 更新はマルチ・マスタ型でどこでも可能
– 矛盾の検知と解決(トランザクションのロールバック
– “Optimistic State Machine” レプリケーション
• グループメンバーの管理と障害検知を自動化
– サーバのフェールオーバー不要
– 構成の拡張/縮小の柔軟性
– 単一障害点無し
– 自動再構成
• 既存構成との統合
– InnoDB
– GTIDベースのレプリケーション
– PERFORMANCE_SCHEMA
MySQL 5.7: グループレプリケーション
Application
MySQL Masters Replication
Plugin
API
MySQL Server
Group Comms (Corosync)
46
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
その他
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL SYS Schema
DB管理者、開発者や運用担当者を支援
• DB管理者や運用担当者の作業効率を改善
- サーバの稼働状況、ユーザやホストの状況、主要な稼働指標
- 性能問題の発見、分析および改善
• 状況をより簡単に把握し理解するための複数のビュー
- IO量の高いファイルや処理、ロック、コストの高いSQL文
- テーブル、インデックス、スキーマの統計
• 他のデータベースにおけるSYS類似機能:
- Oracle V$表 (動的パフォーマンスビュー)
- Microsoft SQL Server DMV (Dynamic Management Views)
48
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
SYS Schema補足情報
■The MySQL SYS Schema (Video Streaming)
トピック: 管理及びモニタリング, パフォーマンスとスケーラビリティ
プレゼンター: Mark Leith, Senior Software Development Manager, Oracle
http://www-jp.mysql.com/news-and-events/web-seminars/the-mysql-sys-schema/
49
■ The MySQL SYS Schemaドキュメント https://oracleus.activeevents.com/2014/connect/fileDownload/session/72527FD42DFF7B2148314B9E72BE7B6A/CON3751_Leith-mysql_sys_schema_oow_2014.pdf
GUI: http://www-jp.mysql.com/products/workbench/ SCRIPT: https://github.com/MarkLeith/mysql-sys
■ The MySQL SYS Schema設定
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
オンライン処理の拡張
50
• Resize the InnoDB Buffer Pool online – オンラインでのバッファーサイズのチューニング
– データベースの使用パターンの変化にリアルタイムで適応
• Separate UNDO tablespace – 自動オンラインUNDOログ切り捨て(MySQL 5.7.5~)
– UNDOログファイルサイズの増加を回避する事が可能
• Dynamic configuration – Making existing settings dynamically configurable
– As a design principle for new features & settings
– その他、幾つかのレプリケーションの設定変更等も
オンラインで変更可能になりました。
参照:14.4.8 Truncating Undo Logs That Reside in Undo Tablespaces
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL 5.7.7 セキュリティの強化
• mysql_install_dbコマンド非推奨
– mysqldの--initializeまたは--initialize-insecureオプションで初期化
• CREATE USER文とALTER USER文にオプション追加 – SSL, PASSWORD EXPIRE, ACCOUNT [LOCK | UNLOCK]
• mysql.userテーブルのPassword列がauthentication_stringに変更に
• SET PASSWORD文およびPASSWORD()関数が非推奨 – ALTER USER文での設定を推奨
• ENCRYPT, DES_ENCRYPT, DES_DECRYPT関数非推奨 AES推奨
ユーザ管理とセキュリティ
mysqld --initialize --user=mysql
mysql_install_db --user=mysql
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Security - Encryption, Passwords, Installation
• AES 256 Encryption (Default in MySQL 5.7 )
• パスワードローテーションポリシー
– インスタンス全体、ユーザー単位で設定可能
• Deployment: デフォルトで安全に無人インストールを行う事が可能
– インストール時にランダムなパスワードを設定/匿名のアカウントを削除
– テストアカウント, スキーマ(test), デモファイルは作成されなくなりました
52
[ Global Configuration ]
SET GLOBAL default_password_lifetime = 180;
[ Individual user accounts ]
ALTER USER joro@localhost PASSWORD EXPIRE INTERVAL 90 DAY;
ALTER USER joro@localhost PASSWORD EXPIRE DEFAULT;
ALTER USER joro@localhost PASSWORD EXPIRE NEVER;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Cluster
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Clusterとは?
• MySQLとは開発ツリーの異なる別製品
•共有ディスクを使わずに、アクティブ-アクティブのクラスタ構成が組める
•元々はSQLを使わないデータベースだったが、MySQLと統合されSQLも 使えるようになった(NoSQL(KVS)とSQLの両方が使えるデータベース)
向いているシステム • 高可用性が求められるシステム
• 同時多発的に大量のトランザクションが発生するシステム
• 読込み処理だけでなく、書込み処理に対しても拡張性が求められるシステム
54
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
1,000億ドル以上の取引を守るMySQL Cluster
55
アプリケーション
世界最大級のオンライン決済サービス。Paypalの口座間やクレジットカードでの送金や入金が可能。アクティブアカウント1億以上、20以上の通貨に対応し、203の国と地域で利用可能。年率30%の成長。
MySQL導入の効果
MySQL ClusterをAWSの5拠点に導入し、全世界で1/3秒未満のレイテンシを実現。リアルタイムでの不正検知が可能に。
MySQL導入の理由
“NoSQLの特徴である迅速な開発とSQLモデルの信頼性の両方のメリットを実装してるため”
Daniel Austin, Chief Architect,
PayPal
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Who’s Using MySQL Cluster?
56
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
参考情報:お勧め書籍
• MySQL Cluster構築・運用バイブル (http://gihyo.jp/book/にて、電子書籍版もあり) –弊社サポートエンジニアが執筆している書籍です
–著者:奥野 幹也 • ブログ:「漢のコンピュータ道」の著者です
http://nippondanji.blogspot.jp/
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Clusterの入門記事
• Think ITで連載中
• MySQL Clusterに触れるためのチュートリアルとなるように、
コマンド付きで解説しています
• 連載タイトル
– 99.999%の高可用性とSQL+NoSQLの柔軟性を併せ持つ「MySQL Cluster」運用ガイド
http://thinkit.co.jp/book/2015/07/01/6183