Weitere ähnliche Inhalte
Ähnlich wie MySQL最新情報 ※2016年12月 (20)
MySQL最新情報 ※2016年12月
- 1. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
MySQL最新情報
updated 2016/12/16
Yoshiaki Yamasaki / 山﨑 由章
MySQL Senior Sales Consultant, Asia Pacific and Japan
- 2. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Safe Harbor Statement
以下の事項は、弊社の一般的な製品の方向性に関する概要を説明するものです。
また、情報提供を唯一の目的とするものであり、いかなる契約にも組み込むことはでき
ません。以下の事項は、マテリアルやコード、機能を提供することをコミットメントするも
のではない為、購買決定を行う際の判断材料になさらないで下さい。
オラクル製品に関して記載されている機能の開発、リリースおよび時期については、
弊社の裁量により決定されます。
2
- 3. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
アジェンダ
3
Oracle MySQL Cloud Service
MySQL Cluster 7.5 GA
MySQL 8.0 DMR 新機能
MySQL Group Replication GA、MySQL InnoDB Cluster
1
2
3
4
- 4. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
アジェンダ
4
Oracle MySQL Cloud Service
MySQL Cluster 7.5 GA
MySQL 8.0 DMR 新機能
MySQL Group Replication GA、MySQL InnoDB Cluster
1
2
3
4
- 5. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 5
Oracle MySQLクラウドサービスによる
TCOの最適化
- 6. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Oracle MySQLクラウドサービス
6
The World’s Most Popular Open Source Database in the Oracle Cloud
Oracle MySQL Cloud Service は、
迅速,安全且つコスト効率良く
MySQLをデプロイする事が可能。
- 7. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
• シンプル
– わずか数回のクリックで,素早くMySQLデータ
ベース・インスタンスが利用可能。
• 自動化
– データベース管理を自動化するツールで簡単
にMySQLを管理する事が可能。
• 統合
– 迅速な開発と展開の為に、Oracleクラウド
サービスとの統合
• エンタープライズ対応
– パフォーマンス、セキュリティ&アップタイム用
のOracleの実証済みのMySQLエンタープライ
ズ・エディションを標準提供。
7
MySQL Cloud Service: 価値提案
+
MySQL Enterprise Edition
- 8. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 8
STEP1)
“インスタンスの作成”をクリック
- 9. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 9
STEP2)
ホスト名を入力しカタログからサーバー
タイプを選択し作成。必要に応じて
Object Storage, MySQL Enterprise Monitor
の設定を入力し完了。
作成時間: 約10分
- 10. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 10
STEP3)
Public IPが設定されているので、アサインされた
IPに対して鍵認証でログインする事が可能。
SSHを利用した接続 Workbench経由でのSSH接続
- 11. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 11
mysql> select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE,LOAD_OPTION from PLUGINS
-> where PLUGIN_TYPE <> 'INFORMATION SCHEMA';
+-----------------------+---------------+-------------------+----------------------+
| PLUGIN_NAME | PLUGIN_STATUS | PLUGIN_TYPE | LOAD_OPTION |
+-----------------------+---------------+-------------------+----------------------+
| binlog | ACTIVE | STORAGE ENGINE | FORCE |
| mysql_native_password | ACTIVE | AUTHENTICATION | FORCE |
| sha256_password | ACTIVE | AUTHENTICATION | FORCE |
| InnoDB | ACTIVE | STORAGE ENGINE | FORCE |
| PERFORMANCE_SCHEMA | ACTIVE | STORAGE ENGINE | FORCE |
| MRG_MYISAM | ACTIVE | STORAGE ENGINE | FORCE |
| MyISAM | ACTIVE | STORAGE ENGINE | FORCE |
| MEMORY | ACTIVE | STORAGE ENGINE | FORCE |
| CSV | ACTIVE | STORAGE ENGINE | FORCE |
| BLACKHOLE | DISABLED | STORAGE ENGINE | OFF |
| partition | ACTIVE | STORAGE ENGINE | ON |
| FEDERATED | DISABLED | STORAGE ENGINE | OFF |
| ARCHIVE | DISABLED | STORAGE ENGINE | OFF |
| ngram | ACTIVE | FTPARSER | ON |
| audit_log | ACTIVE | AUDIT | FORCE_PLUS_PERMANENT |
| thread_pool | ACTIVE | DAEMON | ON |
| authentication_pam | ACTIVE | AUTHENTICATION | ON |
| auth_socket | ACTIVE | AUTHENTICATION | ON |
| validate_password | ACTIVE | VALIDATE PASSWORD | ON |
+-----------------------+---------------+-------------------+----------------------+
MySQL Enterprise版のバイナリーが
インストール済みの為、Enterprise版の
機能が利用する事が可能。
- 12. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 12
MySQL Enterprise Backupも実装されていて、
Dashboardからバックアップジョブ設定、
Point In Timeリカバリー含めて管理可能。
- 13. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 13
MySQL Enterprise Monitorも利用可能
MySQLの設定、パフォーマンス、クエリー等
を一元管理する事が可能です。
- 14. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 14
Dashboardから、MySQLのパッチ適用、
適用前の事前検証と適用後のロールバッ
クを実施する事が可能
※適用前にMEBでバックアップが自動取得されます。
- 15. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 15
最高レベルのセキュリティ スケーラビリティと可用性
MySQLエキスパート
テクニカルサポート
Oracleクラウド環境へ統合
ハイブリッドにデプロイ可能
クラウド& オンプレミス TCOの削減
- 16. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
• ビジネスの俊敏性を向上:
イノベーションにリソースを集中し、迅速に最新の
アプリケーションを提供。
• 確実なセキュリティ,パフォーマンス,稼働時間:
ソースレベルから、最も包括的なMySQL Cloud
プラットホームを利用する事が可能。
• TCO(総所有コスト)を削減:
稼働時間を向上させながら、インフラストラクチャ
及びデータベース管理操作コストを節約可能。
16
MySQL Cloud Service: ビジネス上のメリット
REST APIを利用して、自動化する事も可能です。
http://docs.oracle.com/cloud/latest/stcomputecs/STCSA/QuickStart.html
※ MySQL ServiceのRESTマニュアルは現在、準備中です。
- 17. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 17
MySQL Cloud Service Pricing
詳細: https://cloud.oracle.com/en_US/mysql/pricing
1 OCPU = 2 vCPU
[root@japacsc01-mysql-1 opc]# cat /proc/cpuinfo | grep processor
processor : 0
processor : 1
[root@japacsc01-mysql-1 opc]#
課金方法は2つオプション
- Metered (実際に利用した分のみのコスト負担)
- No-Metered (月単位での固定課金)
- 18. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
詳細情報 @ cloud.oracle.com/mysql
Sign up today for a free trial @
https://cloud.oracle.com/mysql
18
- 19. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
アジェンダ
19
Oracle MySQL Cloud Service
MySQL Cluster 7.5 GA
MySQL 8.0 DMR 新機能
MySQL Group Replication GA、MySQL InnoDB Cluster
1
2
3
4
- 20. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Clusterとは?
• MySQLとは開発ツリーの異なる別製品
• 共有ディスクを使わずに、アクティブ-アクティブのクラスタ構成が組める
インメモリデータベース (一部のデータはディスクに格納することも可能)
• 元々はSQLを使わないデータベースだったが、MySQLと統合されSQLも
使えるようになった(NoSQL(KVS)とSQLの両方が使えるデータベース)
– MySQL Clusterの基礎となる技術は、通信機器ベンダのエリクソンで携帯通信網の
加入者データベース向けに開発されたEricsson Network DataBase(NDB)と呼ばれ
ていた技術
20
- 21. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Clusterが向いているシステム
• 高可用性が求められるシステム
– 携帯電話の通信インフラを支えるために開発された技術がベース
– 単一障害点が無い構成
– 障害発生時に、アプリケーションは処理をリトライすれば存続したノードで処理を継続
• 同時多発的に大量のトランザクションが発生するシステム
– サーバー台数を増加することで負荷分散可能
• 参照処理だけでなく、更新処理に対しても拡張性が求められるシステム
– 自動的にデータをシャーディングし、更新処理についても負荷分散可能
21
- 22. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 22
MySQL Clusterの特徴
• 永続性を持つインメモリテーブル + ディスクテーブル
• 低レイテンシ
リアルタイム
• 自動シャーディング、マルチマスタ
• ACIDトランザクション、OLTPとリアルタイム分析
参照更新性能の
高い拡張性
• シェアードナッシング、単一障害点無し
• 自動復旧、オンラインメンテナンス
99.999% の可用性
• キー・バリュー型+複雑なリレーショナルな処理
• SQL + Memcached + Node.js + JavaScript + Java + HTTP/REST & C++
SQL + NoSQL
• オープンソース+商用版運用支援ツール
• 特殊なハードウェア不要、管理監視ツール群、サポート
低コスト
- 23. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 23
導入事例: 携帯電話ネットワーク
HLR / HSS
課金, 認証, VLR
認証, 追跡接続
サービス, 課金
位置情報
の更新
プリペイ&
ポストペイ課金
MySQL Cluster in Action: http://bit.ly/oRI5tF
• 大量の書き込みトランザクション
• 3ms未満のデータベースレスポンス
• 停止時間 & トランザクション消失 = ビジネスの損失
- 24. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 24
導入事例: 航空機管制システム
• 米国海軍航空母艦
• 包括的航空機運用管制システム
• メンテナンス記録
• 燃料搭載量管理
• 気象状況
• 飛行甲板管理
• システム要件
• 単一障害点無し
• 完全な冗長性
• 小さなフットプリント &
過酷な利用環境での利用
• 4台のMySQL Clusterノード LinuxおよびWindows
MySQL User Conference Session: http://bit.ly/ogeid3
- 25. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 25
導入事例: PayPal
PAYPAL OVERVIEW
• Processed $145bn in transactions (CY2012)
• 前年比成長率22%、1億23百万アカウント、190マーケット
課題/機会
• グローバル単位での不正検知システム構築
• ユーザセッション、トランザクション追跡のリアルタイム処理
DATABASEに求められた要件
• 100TB のデータ & 1億ユーザ に対応可能
• ACID 準拠のトランザクション
• 書込まれたデータを1秒以内に全世界のどこからでも確認可能
• ユーザのトランザクション履歴をリアルタイムで分析可能
• クラウド環境における、高い性能拡張性と99.999%の高可用性
CUSTOMER PERSPECTIVE
“You can achieve high performance and availability without
giving up relational models and read consistency."
Daniel Austin, Chief Architect, PayPal
結果
• 設計目標より3倍速いパフォーマンス
• 40TB のデータをCluster間で同期
• 5つのAWS リージョンにMySQL Clusterを構築
• Self-healinghttp://www.mysql.com/customers/view/?id=1223
課題解決策
• MySQL Cluster 7.2 with Geo-Replication
• AWS
- 26. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 26
遠隔地レプリケーション
遠隔地
レプリケーション
• データセンター間でクラスタを
完全に複製
• DR & データの局所性
パッシブ・リソースなし
• アクティブ / アクティブ
レプリケーションの簡素化
• グローバルにスケーラブルで
冗長性をもつサービスの運用
がよりシンプルに
- 27. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 27
MySQL Serverも組み合わせた複合型の構成
同期型
レプリケーション
Cluster 1 Cluster 2
InnoDB InnoDB InnoDB
非同期型
レプリケーション
• クラスタのノードグループ間では同期型
レプリケーションで、冗長性を確保
• 地理的に離れたクラスタ間で、双方向
の非同期型レプリケーションを行い、
地理的冗長性を確保
• (MySQL Clusterではない)通常のMySQL
サーバへ非同期型のレプリケーション
を行い、レポート生成や課金処理など
のアプリケーションを実行
• NoSQL経由の処理もレプリケーション
可能
- 28. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 28
導入事例:Playful Play
企業概要
Playful Playは、ラテンアメリカでNo.1のFacebookゲームを作
成しています。(8のチャボ(メキシコのテレビコメディーシリー
ズ)をモチーフとしたゲーム)
アプリケーション
Playful Playは、パブリッククラウド上でMySQL Cluster CGEを
動かし、以下を実現しました。
・ 45% パフォーマンス向上
・ 99.999% の高可用性
・ DBAのコストを80% 削減
・ 24×7 のサポート
MySQL Cluster CGEを選択する理由
「MySQL Clusterによって、私たちはゲームの急速な成長を
維持することが出来ました。ラテンアメリカでNo.1のFacebook
のゲームであることには大きな責任が伴いますが、我々の
継続的な成長はMySQL Cluster CGEとOracle社からのサポ
ートに依存しています。」 Ricardo Rocha, CEO, Playful Play
- 29. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL ServerとMySQL Clusterの違い
• MySQL Clusterを構成する要素の1つがMySQL Server
– NoSQLのデータストアのフロントにMySQL Serverがあり、MySQL Server経由で
SQLでも処理が出来るイメージ
(MySQL Cluster 7.5に同梱されているMySQL Serverは5.7)
– MySQL Clusterは3種類のノードから1つのデータベースが構成される
• 複数台での構成が前提
• MySQL ClusterはMySQL ServerのNDBストレージエンジンとして実装されて
いる
– InnoDBとは異なるため、データの保持方法、インデックスの仕組み、トランザクション
の実装方法、などは全て異なる
• MySQL Clusterでは、データは自動的にシャーディング&冗長化される
29
- 30. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 30
MySQL Clusterアーキテクチャ
データノード
ノード・グループ1
F1
F3
F3
F1
ノード1ノード2
ノード・グールプ 2
F2
F4
F4
F2
ノード3ノード4
アプリケーションノード
管理ノード管理ノード
RESTJPA
- 31. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Clusterを構成する3種類のノード
• データノード
– データ、インデックスを管理し、トランザクションを制御するノード
– MySQL Clusterの中核となるノード
• アプリケーションノード(SQLノード)
– アプリケーションとデータノードをつなぐインターフェースとなるノード
– SQLで処理する場合は、MySQL Serverが稼働する
• 管理ノード
– MySQL Cluster全体を管理するノード
– 各ノードの設定管理、クラスタ全体の起動/停止、オンラインバックアップ、など
31
- 32. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
レプリカの数に関する補足
• レプリカの数は2016年11月時点で公式にサポートされているのは
1 or 2のみ
– 1はレプリカを持たないため、通常は2で使用する
⇒データ・ノードの台数は、2の倍数になる
– 設定上は1~4の間で設定でき、2より大きく設定して本番稼働している
システムも存在する
32
※参考マニュアル
MySQL 5.7 Reference Manual:19.3.3.6 Defining MySQL Cluster Data Nodes:NoOfReplicas
http://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-ndbd-definition.html#ndbparam-ndbd-noofreplicas
MySQL 5.6 リファレンスマニュアル:18.3.2.6 MySQL Cluster データノードの定義:NoOfReplicas
https://dev.mysql.com/doc/refman/5.6/ja/mysql-cluster-ndbd-definition.html#ndbparam-ndbd-noofreplicas
- 33. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Clusterの拡張性
• アプリケーション・ノード、データノード共に、台数を増やして負荷分散
出来る
• データは自動的にシャーディングされため、書込み処理に対しても
拡張性が出せる
– 書込み処理が1台のサーバーに集中しない
33
- 34. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 34
MySQL Clusterの拡張性 : 分間12億件の更新処理性能
0
5
10
15
20
25
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
MillionsofUPDATEsperSecond
MySQL Cluster Data Nodes
• MySQL Cluster 7.2
• NoSQL C++ API,
flexaSynch benchmark
• 30 x Intel E5-2600 Intel
Servers, 2 socket, 64GB
• ACIDトランザクション、
同期レプリケーション
• ほぼリニアに性能向上
http://www.mysql.com/why-mysql/white-papers/mysql-cluster-benchmarks-1-billion-writes-per-minute/
- 35. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Clusterの高可用性
• 単一障害点が無いため、アプリケーションは処理をリトライすれば
存続したノードで処理を継続可能
• 障害が発生したデータノードを復旧した時も、クラスタ参加時に自動的に
データを同期してクラスタに参加
• バックアップ、アップグレード、ノード追加等の各種メンテナンス処理も
オンラインで実行可能
35
- 36. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 36
MySQL Cluster 7.5
• Node Sizes of 128TB
• Read Optimized Tables
• Global Tables
パフォーマンス・
キャパシティ
• MySQL 5.7
• JSON Data Type
• Generated Columns
• Records-Per-Key
Optimization
SQLの改善
• Improved Reporting
• Improved Logging
• Improved Visibility
• Improved Debugging
• Improved Restore
管理の強化
GA
https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster.html
https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-what-is-new.html
MySQL Cluster NDB 7.5.4 (2016-10-18)
- 37. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 37
MySQL Cluster 7.5: 機能改善点
Supportability
Performance
Availability
Quality
Capacity
– ndbinfoの拡張により、細かい設定をより詳しく確認可能に
– オプティマイザの改善
– エラーメッセージをより具体的に分かり易く改善
– ロック・レポートの改善
– バックアップ&リストアの高速化
– ndb_binlog_indexをACID対応ストレージエンジンに変換
– スレッドの優先順位づけによる詳細なチューニングも可能
– 固定列フラグメントサイズが16GB以上をサポート(最大128TB)
– テーブル参照性能の向上 (ndb_read_backup, READ_BACKUP)
– MySQL5.7ベースとなり, JSONデータ型を利用可能に
– その他、多数の改善
GA
- 38. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 38
JSONデータ型やGenerated Columnに対応
MySQL5.7で実装された機能が利用可能
mysql> select @@version;
+----------------------------------+
| @@version |
+----------------------------------+
| 5.7.13-ndb-7.5.3-cluster-gpl-log |
+----------------------------------+
1 row in set (0.00 sec)
mysql> show create table JSON75¥G
*************************** 1. row ***************************
Table: JSON75
Create Table: CREATE TABLE JSON75 (
user_id varchar(32) GENERATED ALWAYS AS (json_unquote(json_extract(`doc`,'$.user_id'))) STORED NOT NULL,
doc json DEFAULT NULL,
last_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4
mysql> select * from JSON75 where user_id = 1;
+---------+-----------------------------------------+---------------------+
| user_id | doc | last_update |
+---------+-----------------------------------------+---------------------+
| 1 | {“name”: “ユーザーA”, “user_id”: 1} | 2016-09-30 21:45:47 |
+---------+-----------------------------------------+---------------------+
- 39. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
• バックアップからの読み取りは、
どのコピーからもデータの読み取り
を可能にします。
• 7.4までは、全ての参照処理は、
プライマリーフラグメントのみ参照。
39
Reading from backup (ndb_read_backup, READ_BACKUP)
Node Group
Data Node 1 Data Node 2
セカンダリのセグメントからも
データを参照可能
- 40. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Fully replicated (FULLY_REPLICATED)
• Fully replicatedは、対象テーブルに対して、どのデータノードにおいても、
ローカルでデータの読み書きが出来るようになります。
• 静的データに最適で、より高速なJOIN処理を実現可能。
40
Node Group
Data Node 1 Data Node 2
Node Group
Data Node 3 Data Node 4
- 41. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
参考) COMMETによるテーブルのオプション設定と確認
41
mysql> show create table T_NDB01¥G
************************ 1. row ************************
Table: T_NDB01
Create Table: CREATE TABLE `T_NDB01` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`comment` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ndbcluster AUTO_INCREMENT=11
DEFAULT CHARSET=utf8mb4 COMMENT='NDB_TABLE=READ_BACKUP=1
PARTITION_BALANCE=FOR_RA_BY_LDM'
mysql> show create table T_NDB02¥G
************************ 1. row ************************
Table: T_NDB02
Create Table: CREATE TABLE `T_NDB02` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`comment` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ndbcluster AUTO_INCREMENT=11
DEFAULT CHARSET=utf8mb4 COMMENT='FULLY_REPLICATED=1
NDB_TABLE=READ_BACKUP=1 PARTITION_BALANCE=FOR_RP_BY_NODE'
参照: https://dev.mysql.com/doc/refman/5.7/en/create-table-ndb-table-comment-options.html
mysql> SELECT TABLE_NAME, TABLE_SCHEMA, TABLE_COMMENT
-> FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME like "T_NDB0_";
+------------+--------------+-----------------------------------------------------------------------------+
| TABLE_NAME | TABLE_SCHEMA | TABLE_COMMENT |
+------------+--------------+-----------------------------------------------------------------------------+
| T_NDB00 | TEST_DB | |
| T_NDB01 | TEST_DB | NDB_TABLE=READ_BACKUP=1 PARTITION_BALANCE=FOR_RA_BY_LDM |
| T_NDB02 | TEST_DB | FULLY_REPLICATED=1 NDB_TABLE=READ_BACKUP=1 PARTITION_BALANCE=FOR_RP_BY_NODE |
+------------+--------------+-----------------------------------------------------------------------------+
- 42. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
アジェンダ
42
Oracle MySQL Cloud Service
MySQL Cluster 7.5 GA
MySQL 8.0 DMR 新機能
MySQL Group Replication RC、MySQL InnoDB Cluster
1
2
3
4
- 43. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL 8.0
43
DMR
- 44. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL 5.7 – 全面的な改良
• Replication
• InnoDB
• Optimizer
• Security
• Performance Schema
• GIS
• Triggers
• Partitioning
• New! SYS Schema
• New! JSON
• Performance
44
- 45. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 45
The MySQL 5.7 Story (cont.)
Mobile Schemaless
Database
Improved
MySQL
- 46. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL 8.0 DMR(開発途上版)
• 2016年9月12日リリース!
• フィードバック募集中
• バグ報告や機能追加要望はこちらから
– MySQL Bugs
https://bugs.mysql.com/
46
- 47. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 47
MySQL 8.0
UTF-8
• New! 最新のUnicode 9.0をサポート
• 国ごとの照合順序に対応中
– アクセント、濁音、破裂音の区別
– 大文字小文字の区別
• UCA DUCETをベース
(デフォルトUnicode照合基本テーブル)
• デフォルトキャラクターセットとしてのUTF8MB4
– MySQL 5.7の時からプロジェクト開始
– 性能影響を減らすための数々の改善
- 48. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 48
MySQL 8.0
JSON対応の拡張
• MySQL Document Store
• MySQL Shellを使ってMySQLを管理
– ワンストップDevOpsツール
– 好みの言語を選択可能:SQL、JavaScript、Python、・・・
- 49. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 49
New! 不可視索引(Invisible Indexes)
• オプティマイザーから見えない索引
– 索引の無効化とは異なる
– データ更新時に不可視索引は更新される
• 2つのユースケース:
– 仮削除(ゴミ箱)
– 索引採用のテスト
Feature Request
from DBAs
- 50. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 50
使用例
ユースケース1:索引の仮削除(ゴミ箱)
• 索引の仮削除
ALTER TABLE Country ALTER INDEX c INVISIBLE;
• 索引の復旧
ALTER TABLE Country ALTER INDEX c VISIBLE;
• 索引の削除
ALTER TABLE Country DROP INDEX c;
- 51. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
ユースケース2:索引採用のテスト
• 新しい索引作成は、既存の実行計画を変化させる可能性があるため
リスクを伴う
• 不可視索引は索引採用のテスト容易にする
– 準備段階で不可視索引を作成し、必要に応じて一時的に有効化しながら
索引の有効性を確認する
– 上手く動くことが確認出来てから索引を永続的に有効化する
– 現時点では、クエリー単位で不可視索引を有効化する機能は無いが、
ユーザーからの要望が多く集まれば機能追加を検討している(※次ページ参照)
ALTER TABLE Country ADD INDEX c (Continent) INVISIBLE;
# after some time
ALTER TABLE Country ALTER INDEX c VISIBLE;
51
- 52. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
クエリー単位で不可視索引を有効化する機能について
• 機能追加要望をBug#83066で登録済みです
• Bug #83066
– Feature Request : Use Invisible Indexes Specific Query
– http://bugs.mysql.com/bug.php?id=83066
• 機能追加を希望する方は、“Affects me”をクリックして下さい!
52
- 53. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 53
不可視索引の確認方法
SELECT * FROM information_schema.statistics WHERE is_visible='NO';
*************************** 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: world
TABLE_NAME: Country
NON_UNIQUE: 1
INDEX_SCHEMA: world
INDEX_NAME: c
SEQ_IN_INDEX: 1
COLUMN_NAME: Continent
COLLATION: A
CARDINALITY: 7
SUB_PART: NULL
PACKED: NULL
NULLABLE:
INDEX_TYPE: BTREE
COMMENT: disabled
INDEX_COMMENT:
IS_VISIBLE: NO
- 54. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
仮削除の候補選定に役立つsys.schema_unused_indexes
• sys.schema_unused_indexesから、使用していないインデックスを確認可能
– DB起動後にアクセスがあったテーブルに付けられているインデックスが対象
– 再起動後の稼働期間が十分でない場合は、この情報を確認後、 不可視索引を
使って安全にインデックスを削除可能
54
- 55. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 55
仮削除の候補選定に役立つsys.schema_unused_indexes
mysql> SELECT * FROM sys.schema_unused_indexes;
Empty set (0.00 sec)
mysql> use world;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> SELECT * FROM sys.schema_unused_indexes;
+---------------+-----------------+-------------+
| object_schema | object_name | index_name |
+---------------+-----------------+-------------+
| world | City | CountryCode |
| world | CountryLanguage | CountryCode |
+---------------+-----------------+-------------+
2 rows in set (0.00 sec)
- 56. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 56
仮削除の候補選定に役立つsys.schema_unused_indexes
mysql> SELECT count(*) FROM world.City WHERE CountryCode='JPN';
+----------+
| count(*) |
+----------+
| 248 |
+----------+
1 row in set (0.00 sec)
mysql> SELECT * FROM sys.schema_unused_indexes;
+---------------+-----------------+-------------+
| object_schema | object_name | index_name |
+---------------+-----------------+-------------+
| world | CountryLanguage | CountryCode |
+---------------+-----------------+-------------+
1 row in set (0.00 sec)
- 57. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
New! ロール(権限をまとめて付与/剥奪)
• ロール作成/削除、ロールへの権限付与
• ユーザー/ロールに対してロールの付与
• デフォルトロールを定義、
特定のホストのみロールを使用可能
• ROLES_GRAPHML()関数でロールを可視化
57
- 58. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 58
New! パフォーマンス・スキーマ・インデックス
• パフォーマンス・スキーマのテーブルへより
効率的なアクセスが可能に
• 93個のテーブルに対して全部で115個のインデックスを作成
(ハッシュ・インデックス)
• 追加のオーバーヘッドはほとんど無い
– 物理的なインデックスのメンテナンスは必要ない
– オプティマイザーにより良い実行計画を選択させる
Feature Request
from DBAs
- 59. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 59
パフォーマンスの比較
0 5 10 15 20 25 30 35 40
Query Time MySQL 8.0
MySQL 5.7
30倍以上
高速!
SELECT * FROM sys.session
1000 active sessions
Time in Seconds (Lower is better)
- 60. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 60
100 schemas times 50 tables (5000 tables)
インフォメーション・スキーマのパフォーマンス改善
0 0.5 1 1.5 2 2.5 3 3.5 4
Count All Schemas
Schema aggregate size stats
All Dynamic Table Info
All Static Table Info
Auto Increments Near Limit
Count All Columns
Count All Indexes
MySQL 8.0
MySQL 5.7
秒数 (低い方が良い結果)
既に7/10のクエリーが
高速化できている
- 61. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
30x
Faster
SELECT TABLE_SCHEMA,
TABLE_NAME, TABLE_TYPE,
ENGINE, ROW_FORMAT
FROM information_schema.tables
WHERE TABLE_SCHEMA LIKE 'db%';
61
Test Performed with 100 schemas, each with 50 tables.
- 62. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
New! エラーを確認できるテーブル追加(パフォーマンス・スキーマ)
Aggregation Table Name
By Account events_errors_summary_by_account_by_error
By Host events_errors_summary_by_host_by_error
By Thread events_errors_summary_by_thread_by_error
By User events_errors_summary_by_user_by_error
Global events_errors_summary_global_by_error
62
- 63. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 63
SELECT * FROM test.no_table;
ERROR 1146 (42S02): Table 'test.no_table' doesn't exist
SELECT * FROM performance_schema.events_errors_summary_global_by_error
WHERE sum_error_handled > 0 OR SUM_ERROR_RAISED > 0¥G
*************************** 1. row ***************************
ERROR_NUMBER: 1146
ERROR_NAME: ER_NO_SUCH_TABLE
SQL_STATE: 42S02
SUM_ERROR_RAISED: 1
SUM_ERROR_HANDLED: 0
FIRST_SEEN: 2016-09-11 20:52:42
LAST_SEEN: 2016-09-11 20:52:42
1 row in set (0.00 sec)
- 64. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
New! 設定変更の永続化
• 以下の構文でシステム変数の変更を永続化可能
– SET PERSIST
sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION';
• システム変数変更のためにファイルシステムへのアクセス不要
• read_only=ON⇒OFFへの移行時など、再起動がしばらくできない場合
などに便利
– my.cnfの修正を忘れるリスクの回避
– my.cnfの書き間違いにより再起動に失敗するリスクの回避
• システム変数がどこで設定されたかを確認出来る情報も追加
(performance_schema.variables_info)
64
Cloud Friendly
- 65. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 65
New! 設定変更の永続化
mysql> SELECT * FROM performance_schema.variables_info WHERE variable_source != 'COMPILED';
+--------------------+-----------------+---------------+-----------+------------+
| VARIABLE_NAME | VARIABLE_SOURCE | VARIABLE_PATH | MIN_VALUE | MAX_VALUE |
+--------------------+-----------------+---------------+-----------+------------+
| basedir | GLOBAL | /etc/my.cnf | 0 | 0 |
| datadir | GLOBAL | /etc/my.cnf | 0 | 0 |
| foreign_key_checks | DYNAMIC | | 0 | 0 |
| log_error | GLOBAL | /etc/my.cnf | 0 | 0 |
| server_id | GLOBAL | /etc/my.cnf | 0 | 4294967295 |
+--------------------+-----------------+---------------+-----------+------------+
5 rows in set (0.00 sec)
mysql> SHOW GLOBAL VARIABLES LIKE 'sort_buffer_size';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| sort_buffer_size | 262144 |
+------------------+--------+
1 row in set (0.00 sec)
mysql> SET PERSIST sort_buffer_size=1*1024*1024;
Query OK, 0 rows affected (0.00 sec)
- 66. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 66
New! 設定変更の永続化
mysql> SHOW GLOBAL VARIABLES LIKE 'sort_buffer_size';
+------------------+---------+
| Variable_name | Value |
+------------------+---------+
| sort_buffer_size | 1048576 |
+------------------+---------+
1 row in set (0.00 sec)
mysql> SELECT * FROM performance_schema.variables_info WHERE variable_source != 'COMPILED';
+--------------------+-----------------+---------------+-----------+----------------------+
| VARIABLE_NAME | VARIABLE_SOURCE | VARIABLE_PATH | MIN_VALUE | MAX_VALUE |
+--------------------+-----------------+---------------+-----------+----------------------+
| basedir | GLOBAL | /etc/my.cnf | 0 | 0 |
| datadir | GLOBAL | /etc/my.cnf | 0 | 0 |
| foreign_key_checks | DYNAMIC | | 0 | 0 |
| log_error | GLOBAL | /etc/my.cnf | 0 | 0 |
| server_id | GLOBAL | /etc/my.cnf | 0 | 4294967295 |
| sort_buffer_size | DYNAMIC | | 32768 | 18446744073709551615 |
+--------------------+-----------------+---------------+-----------+----------------------+
6 rows in set (0.00 sec)
- 67. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 67
New! 設定変更の永続化
mysql> shutdown;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[1]+ 終了 mysqld
[root@yyamasaki mysql]# mysqld &
[1] 2500
[root@yyamasaki mysql]# mysql -u root -p
Enter password:
<<中略>>
mysql> SELECT * FROM performance_schema.variables_info WHERE variable_source != 'COMPILED';
+--------------------+-----------------+---------------------------------------+ <<後略>>
| VARIABLE_NAME | VARIABLE_SOURCE | VARIABLE_PATH | <<後略>>
+--------------------+-----------------+---------------------------------------+ <<後略>>
| basedir | GLOBAL | /etc/my.cnf | <<後略>>
| datadir | GLOBAL | /etc/my.cnf | <<後略>>
| foreign_key_checks | DYNAMIC | | <<後略>>
| log_error | GLOBAL | /etc/my.cnf | <<後略>>
| server_id | GLOBAL | /etc/my.cnf | <<後略>>
| sort_buffer_size | PERSISTED | /usr/local/mysql/data/mysqld-auto.cnf | <<後略>>
+--------------------+-----------------+---------------------------------------+ <<後略>>
6 rows in set (0.00 sec)
- 68. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 68
New! 設定変更の永続化
mysql> exit
Bye
[root@yyamasaki mysql]# more /usr/local/mysql/data/mysqld-auto.cnf
{ "mysql_server": {"sort_buffer_size": "1048576" } }
[root@yyamasaki mysql]#
- 69. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 69
New! トランザクショナルなデータディレクトリ
• 信頼性の向上
• InnoDBを使ってデータディレクトリを実現
– No FRM files
– No DB.OPT files
– No TRG files
– No TRN files
– No PAR files
• MySQL 8.0のデフォルトインストールでは、MyISAMテーブルを含まない
- 70. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 70
Additional Benefits
トランザクショナルなデータディレクトリ
• クロスプラットフォームでの相互運用性を向上
– ファイルシステムに依存しない
• アトミックなDDL
– レプリケーションの向上
– クラッシュセーフでない特殊なケースを排除
• MDL for Foreign Keys
• 柔軟なメタデータAPI
– 新機能の追加を容易に
- 71. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Data Dictionary before MySQL 8.0
71
Data Dictionary
Files
FRM TRG OPT
System Tables (mysql.)
user procevents
InnoDB System Tables
MyISAM
File system
InnoDB
SQL
- 72. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Transactional Data Dictionary in MySQL 8.0
72
Data Dictionary
InnoDB
SQL
DD TableDD TableDD Table
- 73. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 73
Common Table Expressions(WITH句)
• WITH句
• 再帰的なクエリの記述
• 複雑なSQLの簡素化
WITH t1 AS (SELECT * FROM tblA WHERE a=‘b’)
SELECT * FROM t1;
Labs
Feature Request
from Developers
- 74. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 74
再帰的CTE(Recursive CTE)
• 再帰的CTEはサブクエリーでCTE自身を参照する
• “seed”のSELECTが1回実行され、初期のデータセットが作成される。
その後、完全な結果セットが得られるまで”recursive”のSELECTが繰
り返し実行される
• 階層構造の参照に便利(親、子、部分、下位部品)
• Oracle DatabaseのCONNECT BY句に近い機能
WITH RECURSIVE cte AS
( SELECT ... FROM table_name /* "seed" SELECT */
UNION ALL
SELECT ... FROM cte, table_name) /* "recursive" SELECT */
SELECT ... FROM cte;/
- 75. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 75
再帰的CTEのシンプルな例
Print 1 to 10 :
WITH RECURSIVE qn AS
( SELECT 1 AS a
UNION ALL
SELECT 1+a FROM qn WHERE a<10
)
SELECT * FROM qn;
1
2
3
4
5
6
7
8
9
10
- 76. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 76
For B+tree indexes
降順索引(Descending Indexes)Labs
CREATE TABLE t1 (
a INT,
b INT,
INDEX a_b (a DESC, b ASC)
);
• In 5.7: 索引は昇順で作成される。降順でSELECTした時は索引を後ろ向きにスキャンする
• In 8.0: 索引を降順でも作成可能。降順でSELECTした時は索引を前向きにスキャンする
利点:
• 高速(索引は後ろ向きよりも前向きにスキャンしたほうが高速)
• ファイルソートを避けるために索引を使用できるケースの拡大
- 77. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
• New! Doxygenを使ったソースコードのド
キュメント化
• New! プラグイン・インターフェース
• GIS Supportの拡張
• Query Hints Supportの拡張
• Scan Query Performanceの向上
• BLOB Storageの改善
• Memcached Interfaceの改善
• オプティマイザの改善
• コストモデルの改善
• スケーラビリティの向上
• パーサーのリファクタリング
• 一時テーブルの改善
• C++11とツールチェーンの向上
• レプリケーション・アプライヤー・スレッドの
進捗レポート
• gtid_executedに値が入っていても、
GTID_PURGEDを設定可能
77
他にも多くの点を改良
- 78. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
アジェンダ
78
Oracle MySQL Cloud Service
MySQL Cluster 7.5
MySQL 8.0 新機能
MySQL Group Replication GA、MySQL InnoDB Cluster
1
2
3
4
- 79. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
マルチマスター
MySQL グループ・レプリケーション
1
79
M MM
GA
- 80. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Group Replication
• マルチマスターレプリケーション用プラグイン
• MySQL5.7.17以降で利用可能な仮想同期レプリケーション
• Active/Active構成でどのノードからでも更新可能
• 分散型フォールトトレランス
• 自動的にサーバーのフェイルオーバーを行う
• 自動的にレプリケーションを再構成
• 自動的に競合検出&解消
• MySQLがサポートする全てのプラットフォームに対応
– Linux, Windows, Solaris, OSX, FreeBSD
80
App Servers with
MySQL Router
MySQL Group Replication
MySQL Shell
Setup, Manage,
Orchestrate
GA
- 81. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
マルチマスター、どこでも更新可能!
• 異なるサーバー上での2つのトランザクションは、同じデータを更新可能
• 競合が検出された場合、自動的に対処される
– 先にコミットしたトランザクションが優先される
81
M M M M M
UPDATE t1 SET a=4 WHERE a=2UPDATE t1 SET a=3 WHERE a=1
- 82. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
マルチマスター、どこでも更新可能!
• 異なるサーバー上での2つのトランザクションは、同じデータを更新可能
• 競合が検出された場合、自動的に対処される
– 先にコミットしたトランザクションが優先される
82
M M M M M
UPDATE t1 SET a=4 WHERE a=2UPDATE t1 SET a=3 WHERE a=1
OKOK
- 83. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
マルチマスター、どこでも更新可能!
• 異なるサーバー上での2つのトランザクションは、同じデータを更新可能
• 競合が検出された場合、自動的に対処される
– 先にコミットしたトランザクションが優先される
83
M M M M M
UPDATE t1 SET a=2 WHERE a=1UPDATE t1 SET a=3 WHERE a=1
- 84. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
マルチマスター、どこでも更新可能!
• 異なるサーバー上での2つのトランザクションは、同じデータを更新可能
• 競合が検出された場合、自動的に対処される
– 先にコミットしたトランザクションが優先される
84
M M M M M
UPDATE t1 SET a=2 WHERE a=1
OKERROR 1180 (HY000): Got error 149 during COMMIT
UPDATE t1 SET a=3 WHERE a=1
- 85. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
自動分散型サーバー復旧
マルチマスター
MySQL グループ・レプリケーション
1
2
85
- 86. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
自動分散型サーバー復旧
• サーバーがグループに参加すると自動的に他のサーバーと同期する
86
M M M M M N
グループに参加
- 87. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
自動分散型サーバー復旧
• サーバーがグループに参加すると自動的に他のサーバーと同期する
87
M M M M M N
オンライン
リカバリー
- 88. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
自動分散型サーバー復旧
• サーバーがグループに参加すると自動的に他のサーバーと同期する
88
M M M M M N
オンライン
- 89. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
自動分散型サーバー復旧
• サーバーがグループから外れると、他のサーバーは自動的に検知する
89
M M M M M M
メンテナンスや
システムクラッシュが発生
各メンバーシップの設定は
タイムスタンプ(view_id)によって識別される
view_id: 4
- 90. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
自動分散型サーバー復旧
• サーバーがグループから外れると、他のサーバーは自動的に検知する
90
M M M M M
- 91. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
自動分散型サーバー復旧
• サーバーが再びグループに参加すると、自動的に他のサーバーと同期する
91
M M M M M M
view_id: 5
リカバリー → オンライン
- 92. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Full GTIDサポート
自動分散型サーバー復旧
マルチマスター
MySQL グループ・レプリケーション
1
2
3
92
- 93. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Full GTIDサポート
• 全グループメンバーは同じUUID、グループ名を持つ
93
M M M M M
INSERT y;
Will have GTID: group_name:2
INSERT x;
Will have GTID: group_name:1
mysql> SET GLOBAL group_replication_group_name= "00000000-1111-2222-3333-123456789ABC";
- 94. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Full GTIDサポート
• グループ外のサーバーからグループにレプリケート可能
• グローバル識別子は維持
94
M M M M M
競合も検出される
- 95. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Full GTIDサポート
• グループからグループ外のサーバーにレプリケート可能
• グローバル識別子は維持
95
M M M M M
- 96. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Full GTIDサポート
自動分散型サーバー復旧
マルチマスター
MySQL グループ・レプリケーション
1
2
3
96
4 Single Primary Mode
- 97. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Single Primary Mode
• シングルメンバーが書き込み可能なマスター(PRIMARY)として動作して、
他のグループメンバーはホットスタンバイ(SECONDARY)として動作します。
– リーダー選択メカニズムにて、どのメンバーがPRIMARYとして動作すべきか、
判断して自動的にグループ内でコーディネートします。
• この新しいコンフィギュレーションモード導入の背後にある主な動機は、グループレプリ
ケーションユーザーに対して、ユーザーが使い慣れている非同期レプリケーションに
近い、シングルマスターレプリケーションの環境を選択出来るようにする為
97
+---------------------------------------+-------+
| Variable_name | Value |
+---------------------------------------+-------+
| group_replication_single_primary_mode | ON |
+---------------------------------------+-------+
+----------------------------------------------------+-------+
| Variable_name | Value |
+----------------------------------------------------+-------+
| group_replication_enforce_update_everywhere_checks | OFF |
+----------------------------------------------------+-------+
[1]: http://mysqlhighavailability.com/mysql-group-replication-for-mysql-5-7-15/
- 98. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
M S
S
S
S
M
更新処理 参照処理
参照処理
更新処理
参照増加?
スレーブ
追加!
98
参照性能のスケールアウト
補足: レプリケーションの用途
- 99. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 99
C
B
A
C
B
A障害発生
C
B
A
Bが新しい
マスターに昇格
障害発生 構成変更
冗長性: マスターがクラッシュした場合, スレーブをマスターに昇格
補足: レプリケーションの用途
- 100. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Single Primary Mode
• 自動的なリーダー選択メカニズム
– Secondaryノードは参照のみ可能 (書き込んだ場合: ERROR 1290)
100
S S S S P S
Primary
ERROR 1290 (HY000): The MySQL server is running with the --super-read-only option so it cannot execute this statement
- 101. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
[1]: http://mysqlhighavailability.com/mysql-group-replication-for-mysql-5-7-15/
Single Primary Mode
• 自動的なリーダー選択メカニズム
101
S S S P S
Primary
- 102. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
[1]: http://mysqlhighavailability.com/mysql-group-replication-for-mysql-5-7-15/
Single Primary Mode
• 現在のプライマリサーバーのメンバーIDは、次のSQL文を実行することに
よって確認する事が出来ます。
102
mysql> SELECT * FROM performance_schema.replication_group_members;
+-------------------------+------------------------------------+-------------+-----------+------------+
|CHANNEL_NAME |MEMBER_ID |MEMBER_HOST |MEMBER_PORT|MEMBER_STATE|
+-------------------------+------------------------------------+-------------+-----------+------------+
|group_replication_applier|919a7d77-9ff3-11e6-acb8-080027d65c57|replications | 3310|ONLINE |
|group_replication_applier|9c8e6f77-9ff3-11e6-b1d1-080027d65c57|replications | 3320|ONLINE |
|group_replication_applier|ac0ec52b-9ff3-11e6-b801-080027d65c57|replications | 3330|ONLINE |
+-------------------------+------------------------------------+-------------+-----------+------------+
mysql> SELECT * FROM performance_schema.global_status WHERE
VARIABLE_NAME='group_replication_primary_member';
+----------------------------------+--------------------------------------+
| VARIABLE_NAME | VARIABLE_VALUE |
+----------------------------------+--------------------------------------+
| group_replication_primary_member | 919a7d77-9ff3-11e6-acb8-080027d65c57 |
+----------------------------------+--------------------------------------+
- 103. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL InnoDB Cluster
103
- 104. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL InnoDB Clusterとは?
• 以下のコンポーネントを組み合わせから構成される
MySQLの高可用性フレームワーク
– MySQL Group Replication
– MySQL Router
– MySQL Shell
104
- 105. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 105
Scale-Out
High Performance
Ease-of-Use
Built-in HA
Out-of-Box Solution
Everything Integrated
MySQL
InnoDB
cluster
MySQL Labs :: MySQL InnoDB Cluster 5.7.15 Preview
http://labs.mysql.com/
- 106. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 106
Ease-of-Use • 15分でインストール, HA ,スケールアウト設定が可能
• MySQLユーザーの為のシングルインターフェイス
• 簡単にセットアップ, スケールアウト, 管理 & モニタリング
• 優れた品質
MySQL
Out-of-Box Solution • 統合ソリューション vs. 個別のコンポーネント
• 設計& 開発済み環境を同時に提供
• 検証済み環境を同時に提供
• 管理及び監視環境を同時に提供
Scale-Out • ワールドクラスの性能を維持
• 自動フェイルオーバー含め信頼性のあるHAをサーバー側で提供
• 参照処理の拡張:レプリケーション
• 書き込み処理の拡張:シャーディング
- 107. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL InnoDB Cluster: Architecture – Step 1
M
M M
MySQL Connector
Application
MySQL Router
MySQL Connector
Application
MySQL Router
MySQL Shell
HA
Group Replication
107
- 108. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
S1 S2 S3 S4 S…
M
M M
MySQL Connector
Application
MySQL Router
MySQL Connector
Application
MySQL Router
MySQL Shell
HA
MySQL InnoDB Cluster: Architecture – Step 2
Group Replication
Read-Only Slaves
108
- 109. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
S1 S2 S3 S4 S…
M
M M
MySQL Connector
Application
MySQL Router
MySQL Connector
Application
MySQL Router
MySQL Shell
HA
ReplicaSet1
S1 S2 S3 S4 S…
M
M M
MySQL Connector
Application
MySQL Router
HA
ReplicaSet2
ReplicaSet3
MySQL Connector
Application
MySQL Router
MySQL InnoDB Cluster: Architecture – Step 3
S1 S2 S3 S4
M
M M
HA
109
- 110. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Connector
Application
MySQL Router
MySQL Connector
Application
MySQL Router
MySQL Shell
MySQL Connector
Application
MySQL Router
MySQL Connector
Application
MySQL Router
MySQL InnoDB Cluster: High Level Architecture
MySQL
InnoDB
cluster
MySQL Enterprise Monitor
…
mysql-js> cluster.status()
{
"clusterName": “NewAppCluster",
"defaultReplicaSet": {
"status": "Cluster tolerant to up to ONE failure.",
"topology": {
“hanode1:3306": {
"address": “hanode1:3306",
"status": "ONLINE",
"role": "HA",
"mode": "R/W",
110
- 111. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 111
参考) MySQL InnoDB Cluster: The End Goal
M
App
M M
MySQL Shell and Orchestration Tooling
MApp
M M
Simple Shard Mapping,
State and Extra
Metadata
Control, Coordinate,
Provision
...
Monitoring (MEM)
MySQL Router Group Replication – Shard 1
Group Replication – Shard N
MySQL Router
- 112. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 112
単一製品: MySQL
• 全てのコンポーネントを同時に開発
• 全てのコンポーネントを同時に検証
• 一つのパッケージとして提供
近代的な柔軟性
• C++ 11 (ISO標準 ISO/IEC 14882:2011)
• Protocol Buffers
• 開発フレンドリー
MySQL InnoDB Cluster: ゴール
容易な利用
• シングルクライアント: MySQL Shell
• 容易なパッケージング
• 同種のサーバー群
スケールアウト
• シャード・クラスター
• Nレプリカセットのフェデレーテッド構成
• 各レプリカセットによるシャードの管理
デモ: https://www.youtube.com/watch?v=JWy7ZLXxtZ4
- 113. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Shell
113
すべての運用管理タスクのための、統一された単一クライアント
App Servers with
MySQL Router
MySQL Group Replication
MySQL Shell
Setup, Manage,
Orchestrate
• 多言語対応: JavaScript, Python, and SQL
• ドキュメントとリレーショナルモデルの両方をサポート
• 開発と管理用に完全なAPIを提供
”MySQL Shell provides the developer and DBA with a single intuitive,
flexible, and powerfull interface for all MySQL related tasks!”
DMR
[root@misc01 admin]# mysqlsh --help | egrep -i "Start in"
--sql Start in SQL mode using a node session.
--sqlc Start in SQL mode using a classic session.
--js Start in JavaScript mode.
--py Start in Python mode.
[root@misc01 admin]#
MySQL Shell DMR (2016-04)
- 114. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Shell: 管理用API
• mysql-js> dba.help()
• グローバル変数 ‘dba’がMySQLの管理用APIに
アクセスする為に使用可能
• DBA管理オペレーション
– Manage MySQL InnoDB clusters
• クラスター作成
• MySQLインスタンスの構築
• クラスターの状況を確認可能
• MySQLインスタンスの開始・停止
• MySQLインスタンスの検証 …
データベース管理者向けインターフェース
App Servers with
MySQL Router
MySQL Group Replication
MySQL Shell
Setup, Manage,
Orchestrate
DMR
+labs
MySQL Shell DMR (2016-09)
114
- 115. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 115
mysql-js> dba.help()
The global variable 'dba' is used to access the MySQL AdminAPI functionality
and perform DBA operations.It is used for managing MySQL InnoDB clusters.
The following properties are currently supported.
- verbose Enables verbose mode on the Dba operations.
The following functions are currently supported.
- createCluster Creates a MySQL InnoDB cluster.
- deleteLocalInstance Deletes an existing MySQL Server instance on localhost.
- deployLocalInstance Creates a new MySQL Server instance on localhost.
- dropMetadataSchema Drops the Metadata Schema.
- getCluster Retrieves a cluster from the Metadata Store.
- help Provides help about this class and it's members
- killLocalInstance Kills a running MySQL Server instance on localhost.
- resetSession Sets the session object to be used on the Dba operations.
- startLocalInstance Starts an existing MySQL Server instance on localhost.
- stopLocalInstance Stops a running MySQL Server instance on localhost.
- validateInstance Validates an instance for usage in Group Replication.
For more help on a specific function use dba.help('<functionName>')
e.g. dba.help('deployLocalInstance')
- 116. Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
MySQL Shellの機能拡張
116
shell> mysqlsh
mysql-js> dba.deployLocalInstance(3306)
mysql-js> dba.deployRemoteInstance(‘192.168.1.2:3306’)
mysql-js> dba.deployRemoteInstance(‘192.168.1.3:3306’)
MySQL Shell – Deploy MySQL Instances
shell> mysqlsh --uri root@localhost:3306
mysql-js> cluster = dba.createCluster(‘NewAppCluster')
mysql-js> cluster.addInstance('root@192.168.1.2:3306')
mysql-js> cluster.addInstance('root@192.168.1.3:3306')
MySQL Shell – Create InnoDB Cluster
MySQL Shell – Add MySQL Router
shell> mysqlrouter --bootstrap localhost:3306
shell> mysqlrouter &
shell> mysqlsh --uri root@localhost:6442
shell> mysqlsh --uri root@localhost:3306
mysql-js> cluster = dba.getCluster()
mysql-js> cluster.status()
MySQL Shell – Check Status
MySQL Shell
Setup, Manage,
Orchestrate
ノードの追加, Group Replication設定, Router連携機能を実装
https://www.youtube.com/watch?v=JWy7ZLXxtZ4
DMR
+labs