50

MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

  • Upload
    others

  • View
    22

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise
Page 2: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

MySQL Databaseのご紹介

Yoshiaki Yamasaki / 山﨑 由章 MySQL Senior Sales Consultant, Asia Pacific and Japan

Page 3: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

Safe Harbor Statement

以下の事項は、弊社の一般的な製品の方向性に関する概要を説明するものです。 また、情報提供を唯一の目的とするものであり、いかなる契約にも組み込むことはできません。以下の事項は、マテリアルやコード、機能を提供することをコミットメントするものではない為、購買決定を行う際の判断材料になさらないで下さい。 オラクル製品に関して記載されている機能の開発、リリースおよび時期については、 弊社の裁量により決定されます。

3

Page 4: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 4

The world's most popular open source database 世界で最も普及しているオープンソース データベース

Page 5: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

The world's most popular open source database

5

例) DB-Enginesによる調査結果

• http://db-engines.com/en/ranking

• データベースソフトウェアの普及度や人気を、インターネット上の求人情報や職務経歴上での経験、および検索エンジンやSNSでの情報量を元に、毎月を作成し公開

Page 6: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

Oracle Database & MySQL

• より多くのお客様の要件にお応えするために

• MySQLはWebにおけるデファクトスタンダード

• MySQLとOracleの両方を運用されるお客様にもより多くのメリット

6

Complementary 「補完関係」

Web and Cloud computing is not a "one size fits all" model

Page 7: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

MySQLの強み

•世界でもっとも普及している、オープンソースデータベース

• LAMPスタックの"M" – Webアプリケーションを開発する時のデファクトスタンダード

• マルチプラットフォーム対応 – Windows, Linux, Solaris

•高性能、軽量、高信頼 –特にOLTP系の処理が得意

•導入や運用の容易性 –ダウンロードからデータベース起動まで15分以内

–管理不要なシンプルさ

7

Page 8: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 8

MySQLの歴史

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 2015年10月21日 GA 新コストモデル オプティマイザ ロスレス レプリケーション マルチソース レプリケーション グループ レプリケーション 全文検索CJK対応/GIS (InnoDB) セキュリティ強化 データディクショナリ NoSQLオプション

・ 1995年:スウェーデンにてMySQL AB設立 ・(2005年:オラクルがInnobase Oyを買収) ・ 2008年:Sun MicrosystemsがMySQL ABを買収 ・ 2010年:オラクルがSun Microsystemsを買収

Page 9: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

Driving MySQL Innovation: 2010 - 2015

9

MySQL Enterprise Monitor 2.2

MySQL Cluster 7.1

MySQL Cluster Manager 1.0

MySQL Workbench 5.2

MySQL Database 5.5

MySQL Enterprise Backup 3.5

MySQL Enterprise Monitor 2.3

MySQL Cluster Manager 1.1

MySQL Enterprise Backup 3.7

Oracle Products Certifications

All GA! All GA! All GA!

Available Now! Partial List of Releases Delivered

MySQL Windows Installer

MySQL Enterprise Security

MySQL Enterprise Scalability

MySQL Enterprise Audit

MySQL Cluster 7.2

MySQL Cluster Manager 1.3

MySQL Utilities

MySQL Workbench 6.0

MySQL Windows Tools

MySQL Database 5.6

MySQL Cluster 7.3

MySQL Cluster Manager 1.3

MySQL Enterprise Monitor 3.0

MySQL Fabric

MySQL Workbench 6.3

MySQL Cluster 7.4

MySQL Enterprise Firewall

MySQL Enterprise Backup 4.0

MySQL Router

MySQL Database 5.7

日本語全文検索, JSONデータ型をサポート

Page 10: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

MySQL 5.7における パフォーマンスと拡張性の改良

10

Page 11: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 11

MySQL 5.6より3倍高速、MySQL 5.5より4倍高速

MySQL 5.7 Sysbench Benchmark: SQL による一意検索

1,600,000 QPS

0

200,000

400,000

600,000

800,000

1,000,000

1,200,000

1,400,000

1,600,000

1,800,000

8 16 32 64 128 256 512 1,024

Qu

eri

es

pe

r Se

con

d

Connections

MySQL 5.7: Sysbench OLTP Read Only (SQL Point Selects)

MySQL 5.7

MySQL 5.6

MySQL 5.5

Intel(R) Xeon(R) CPU E7-8890 v3 4 sockets x 18 cores-HT (144 CPU threads) 2.5 Ghz, 512GB RAM Linux kernel 3.16

Page 12: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 12

MySQL 5.6より3倍高速

MySQL 5.7 Sysbench Benchmark: OLTP 読み取りのみ

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: Sysbench OLTP Read Only

MySQL 5.7

MySQL 5.6

MySQL 5.5

Intel(R) Xeon(R) CPU E7-8890 v3 4 sockets x 18 cores-HT (144 CPU threads) 2.5 Ghz, 512GB RAM Linux kernel 3.16

~ 1,000,000 QPS

Page 13: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 13

MySQL 5.6より1.5倍高速

MySQL 5.7 Sysbench Benchmark: OLTP 読み取り&書き込み

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 OLTP Read Write

MySQL 5.7

MySQL 5.6

MySQL 5.5

Intel(R) Xeon(R) CPU E7-8890 v3 4 sockets x 18 cores-HT (144 CPU threads) 2.5 Ghz, 512GB RAM Linux kernel 3.16

Page 14: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 14

SQL文の実行速度を向上、CPUとディスクスペースの削減

オプティマイザの改善

• オプティマイザとパーサーのリファクタ リング

– 可読性、保守性、安定性の向上

– 独立した解析、最適化、実行ステージ

– 機能追加時のリスク軽減

• New ヒントフレームワーク

– より容易な管理

– 新しいヒントの追加

• JSON EXPLAINの改善

• 実行中のスレッドに対するEXPLAIN

• 新しいコストベース・オプティマイザ

– 機能拡張が容易に

– チューニング可能

• mysql.server_cost 、mysql.engine_cost テーブルを使用してコストをチューニング

• 一時テーブルにInnoDBを使用

• ONLY_FULL_GROUP_BYモードの改善

• 多くの新しい最適化

• Generated Columns

Page 15: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

オプティマイザー・コストモデル : パフォーマンス改善

0

20

40

60

80

100

Q3 Q7 Q8 Q9 Q12

Exe

cuti

on

tim

e r

ela

tive

to

5.6

(%

)

22クエリ中5クエリは、オプティマイザの改善により大幅にパフォーマンス改善

MySQL 5.6

MySQL 5.7

15

DBT-3 (Size Factor 10, CPU bound)

※Q8は 5.6:約25秒 ⇒ 5.7:約3秒 まで短縮(データがキャッシュ上にあるテスト)

Page 16: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16

DBT-3 (Size Factor 10)

オプティマイザー・コストモデル : パフォーマンス改善

0

20

40

60

80

100

Q2 Q18

Exe

cuti

on

tim

e r

ela

tive

to

5.6

(%

)

CPU bound

5.6

5.7

22クエリ中2クエリは、オプティマイザの改善により著しくパフォーマンス改善

0

20

40

60

80

100

Q2 Q18

Exe

cuti

on

tim

e r

ela

tive

to

5.6

(%

)

Disk bound

5.6

5.7

※Q2は 5.6:約3分 ⇒ 5.7:1秒、Q18は 5.6:約20分 ⇒ 5.7:40秒 まで短縮(データがキャッシュ上にないテスト)

Page 17: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

JSON EXPLAINへのコスト情報追加

• JSON EXPLAINを拡張 –出力可能なコスト情報を全て表示

– MySQL WorkbenchのVisual Explainにも表示

17

より具体的な値をベースに最適化を実施 {

"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"

],

...

Page 18: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

MySQL Workbench

•管理ツール

• SQLエディタ

• Performance Dashboard

• Visual Explain

• GIS Viewer

• ER図作成、フォワード/ リバースエンジニアリング、 など豊富な機能

18

データベースアーキテクト、開発者、DBA のための統合ビジュアルツール

商用版のみの機能: DBドキュメント出力、データモデルの検証、 MySQL Enterprise Backup GUI、MySQL Enterprise Audit GUI

Page 19: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

MySQL Workbench

•移行元 – Microsoft SQL Server, PostgreSQL,

Sybase ASE, Sybase SQL Anywhere, SQLite, Microsoft Access, MySQL, and more

• オブジェクトとデータの移行

• MySQLバージョンアップグレード (テスト環境用)

19

データベース・マイグレーション・ウィザード

Page 20: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

JSONデータ型の追加 JSON関数による管理面の強化と高速なドキュメント処理

20

Page 21: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

Why JSON support in MySQL?

• シリアルフォーマットの便利なオブジェクト

•効果的にJSONデータを処理する為

• JavaScriptアプリケーションのネイティブサポート

• リレーショナルデータとスキーマレスデータの シームレスな統合

•既存のデータベース・インフラストラクチャを 新しいアプリケーションでも活用

21

外部サイト/SNS

モバイル デバイス

コマース /ポータル

その他

(data JSON);

REST/JSON

柔軟なBtoB,BtoC連携 ドキュメントデータを高速処理

Page 22: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

JSONサポート

• ネイティブJSONデータ型 –データ処理と保管にネイティブな内部バイナリ形式サポート

– Insert時のJSON構文バリデーション機能

•組み込みJSON関数 –効率よくドキュメントを保存、検索、更新、操作する事を可能に

• JSONコンパレータ― –文書データを容易にSQLクエリと統合することが可能

• Generated Columnsを利用し、ドキュメントにインデックスを利用可能 – InnoDBは、Generated Columnsへのインデックス作成をサポート(stored&virtual)

–新しいアナライザーは自動的に、利用可能で最適なインデックスを利用

22

Page 23: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 23

206,000件のドキュメントに対して、インデックスを使わずに検索

JSON と TEXT データタイプの比較

# JSONデータ型でfetureカラムをSELECT

SELECT DISTINCT

feature->"$.type" as json_extract

FROM features;

+--------------+

| json_extract |

+--------------+

| "Feature" |

+--------------+

1 row in set (1.25 sec)

# TEXTデータ型でfetureカラムをSELECT

SELECT DISTINCT

feature->"$.type" as json_extract

FROM features;

+--------------+

| json_extract |

+--------------+

| "Feature" |

+--------------+

1 row in set (12.85 sec)

Page 24: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 24

ドキュメントに対するスキャンをインデックススキャンに変更

JSONデータ型と関数インデックスの使用

ALTER TABLE features ADD feature_type VARCHAR(30) AS (JSON_UNQUOTE(feature-

>'$.type'));

Query OK, 0 rows affected (0.01 sec)

Records: 0 Duplicates: 0 Warnings: 0

ALTER TABLE features ADD INDEX (feature_type);

Query OK, 0 rows affected (0.73 sec)

Records: 0 Duplicates: 0 Warnings: 0

SELECT DISTINCT feature_type FROM features;

+--------------+

| feature_type |

+--------------+

| "Feature" |

+--------------+

1 row in set (0.06 sec)

メタデータの変更のみのため高速、 テーブルへはアクセス不要

インデックス作成のみの場合、 行データにはアクセスしない

インデックス使用により、 1.25秒→0.06秒に短縮

Page 25: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

InnoDB全文検索の日本語サポート

25

Page 26: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

全文検索とは?

•文書内の要素を検索する –文字列を格納するデータ型が対象

– VARCHAR, TEXT, BLOB

•検索文字列 –単語の組み合わせ

–フレーズ: “検索する文字列”

–ワイルドカード: *

–ブール全文検索演算子: +, -, ~

–関連重み付け文字: <, >

26

Page 27: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

27

全文検索インデックス無しでの検索

Page 28: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

28

全文検索インデックス有りでの検索

Page 29: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

全文検索の用途例

• コンテンツ管理 –情報に対する説明などのメタデータ

–検索結果により有用な情報を提供

•検索サービス –特定の用語やトークンを含むドキュメントを検索

–現在の表示に最も類似したドキュメントを検索

–ユーザが最も興味のあるデータを検索

29

Page 30: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

全文検索インデックス

• トークンと文章の関係を表現した転置インデックス

30

This movie is about a boy going to war.

This movie is about a

girl starting an auto-

shop.

This movie is about

flowers.

a about an are as at be by com de en for from

how i in is it la of

on or that the this to

was what when where

who will with und

the www

Min Token Size

Max Token Size

Document 1

Document 2

Document 3

Stop Words Token Size

Full Text / Inverted Index

ID TOKEN DOCUMENT

1 movie 1,2,3

2 boy 1

3 girl 2

4 going 1

5 starting 2

6 war 1

7 auto-shop 2

8 flowers 3

Token Filters Documents

Tokenizer

Tokenizer

Indexer

Indexer

Page 31: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

MySQL 5.7での強化点

• N-gramによる中国語、 韓国語、日本語サポート – N文字区切りでトークンを検出

31

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE ORDER BY doc_id, position LIMIT 10; +--------+--------------+-------------+-----------+--------+----------+ | WORD | FIRST_DOC_ID | LAST_DOC_ID | DOC_COUNT | DOC_ID | POSITION | +--------+--------------+-------------+-----------+--------+----------+ | ロー | 1 | 15 | 2 | 1 | 0 | | ール | 1 | 16 | 3 | 1 | 3 | | ルと | 1 | 1 | 1 | 1 | 6 | | とグ | 1 | 1 | 1 | 1 | 9 | | グル | 1 | 7 | 2 | 1 | 12 | | ルー | 1 | 16 | 3 | 1 | 15 | | ープ | 1 | 7 | 2 | 1 | 18 | | プベ | 1 | 1 | 1 | 1 | 21 | | 環境 | 1 | 1 | 1 | 1 | 21 | | ベー | 1 | 7 | 4 | 1 | 24 | +--------+--------------+-------------+-----------+--------+----------+ 10 rows in set (0.01 sec)c

Page 32: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

MySQL 5.7での強化点

• MeCabによる日本語サポート – Mecab(オープンソースの日本語辞書)を使ってトークンを検出

32

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE ORDER BY doc_id, position LIMIT 10; +--------------------+--------------+-------------+-----------+--------+----------+ | WORD | FIRST_DOC_ID | LAST_DOC_ID | DOC_COUNT | DOC_ID | POSITION | +--------------------+--------------+-------------+-----------+--------+----------+ | ロール | 1 | 1 | 1 | 1 | 0 | | グループ | 1 | 7 | 2 | 1 | 12 | | 環境 | 1 | 1 | 1 | 1 | 21 | | ベース | 1 | 7 | 2 | 1 | 24 | | アクセス | 1 | 1 | 1 | 1 | 36 | | コントロール | 1 | 1 | 1 | 1 | 48 | | により | 1 | 1 | 1 | 1 | 66 | | mysql | 1 | 16 | 12 | 1 | 78 | | dba | 1 | 16 | 4 | 1 | 83 | | きめ細か | 1 | 1 | 1 | 1 | 91 | +--------------------+--------------+-------------+-----------+--------+----------+ 10 rows in set (0.00 sec)

Page 33: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

GISサポートの改善

33

Page 34: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

GIS機能の改善

• Boost.Geometryと統合し、独自コードを置き換え

– 空間図形情報の計算、空間図形情報の分析

– OGC準拠

–パフォーマンスの向上

• Boost.Geometryコミュニティとの交流 –非常に活発なコミュニティ

– Boost.Geometryへのコントリビューも

• MySQL Workbenchに搭載された Spatialビューアー、Geometryビューアーで geometry型のデータを容易に確認可能

34

Page 35: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

InnoDBでの空間インデックス

• R-tree based

–トランザクションサポート

–レコードは最小のbounding box (境界線)を含む

–現時点では2Dデータのみをサポート • 3Dデータのサポートも計画中

35

Page 36: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

追加機能

• GeoHash

–経度、緯度の情報を短い文字列で表現

–経度、緯度の情報を素早く検索

–精度を落とすことで近くのエリアが検索可能

• GeoJSON

• ST_Distance_Sphere()、 ST_MakeEnvelope() などの 便利な関数の提供

36

{

"type": "Feature",

"geometry": {

"type": "Point",

"coordinates": [125.6, 10.1]

},

"properties": {

"name": "Dinagat Islands"

}

}

GeoJSON Example

Page 37: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

MySQL 5.7における 運用・管理面の強化

37

Page 38: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

メモリ統計情報

• 統計情報の収集

– メモリの利用タイプ別 (キャッシュ、内部バッファ…)memory_summary_* テーブル

– スレッド/アカウント/ユーザ/ホスト毎のメモリ処理

• 含まれる属性情報

– メモリ利用量(バイト)

– 処理数

– 最大/最小

SQL文統計情報

• ストアドプロシージャ

• ストアドファンクション

• プリペアードステートメント

• トランザクション

38

追加情報

• レプリケーションスレーブ情報

• MDLロック統計情報

• スレッドごとのユーザ変数

• Server stage tracking

• 長時間実行されている SQL文

容易に使用可能

• メモリフットプリントと オーバーヘッドの削減

Performance Schemaの強化

Page 39: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

SYS スキーマを標準搭載

• DB管理者や運用担当者の作業効率を改善

– サーバの稼働状況、ユーザやホストの状況を監視

– 性能問題の発見、分析および改善

• 状況をより簡単に把握し理解するための複数のビュー

– IO量の高いファイルや処理、ロック、コストの高いSQL文

– テーブル、インデックス、スキーマの統計

• 他のデータベースにおけるSYS類似機能:

– Oracle V$表 (動的パフォーマンスビュー)

– Microsoft SQL Server DMV (Dynamic Management Views)

39

DB管理者、開発者や運用担当者を支援

Page 40: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

• AES 256 Encryption(Default in MySQL 5.7)

• パスワードローテーションポリシー

– インスタンス全体、ユーザー単位で設定可能

• Deployment: デフォルトで安全に無人 インストール可能

– インストール時にランダムなパスワードを設定

– 匿名ユーザーを削除

– testスキーマ、デモファイルは作成されない

• インスタンスの容易な初期化と セットアップ : mysqld --initialize

• New detection and support for systemd

• SSL

– デフォルトで有効

– 既存の鍵と証明書を自動検知

– 必要に応じ鍵と証明書を自動生成

– 証明書作成新ツール : mysql_ssl_rsa_setup

– 新オプション"--require_secure_transport"を 利用する事でセキュアでない通信を防ぐ事が可能

– mysqlbinlogツールのSSLサポート追加

• Proxy Userサポートの拡張 (Roleに類似)

– Proxyユーザー認証プラグインを標準搭載

– 複数ユーザーが1つの権限セットを共有可能

40

セキュリティ向上

Page 41: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

MySQL 5.7における レプリケーション、高可用性機能の強化

41

Page 42: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

• GTID の改善

– オンラインでのGTID有効化

– スレーブでのバイナリログ出力無しの構成可能

• 準同期レプリケーションの改善

– "Lossless"準同期

– 複数のスレーブからのACKを待つことも可能

• マルチソース・レプリケーション

– 1台のスレーブに複数マスターからの更新を統合

• レプリケーションフィルタを動的に変更可能

• 8-10倍のスレーブのスループット向上

– スレーブのボトルネックを排除、8スレッドで マスターと同等のスループット

– コミット順序を維持するオプション

– 自動的なスレーブでのトランザクション再試行

42

レプリケーションの改善と拡張

0%

50%

100%

150%

200%

250%

1 8 24 48

SlaveThreads

Slavethroughputvs.96ThreadMaster

Page 43: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

• マルチソース・レプリケーション

– 複数のマスターでの変更点を1台のスレーブに集約

• 全てのシャードのデータを集約

• より柔軟なレプリケーション構成

• バックアップ処理を集約

– 準同期レプリケーションとマルチスレッド スレーブと互換性あり

• スレーブを監視するためのパフォーマンス・スキーマ・テーブル

• オンラインオペレーションの向上

– レプリケーションフィルタ、スイッチマスター

43

レプリケーションの改善と拡張(続き)

Slave

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

Page 44: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

MySQL Router GA 接続とトランザクションのルーティング

44

Page 45: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

New! MySQL Router GA

•開発の背景 – MySQL Fabricを透過的に利用したい

• Connectorの変更不要 (Python, Java, PHP, .NET)

• Fabric対応Connectorがない言語からの利用(Ruby, Perl, C等)

–グループレプリケーション利用時の競合削減

•特徴 –参照&更新および参照のみの処理を配信

• どのサーバがマスターかを事前に知る必要がない

• 新しいマスターへの透過的なフェールオーバー

• 接続の転送とシンプルなロードバランス

• 高性能・プラグインアーキテクチャ

• 簡単なセットアップ、設定、実装

45

M

Router

App

S S

Fabric

M M M

Page 46: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 46

高可用性構成とシャードによる拡張性

補足) MySQL Fabric 1.5概要

• 高可用性構成

– サーバ群を監視し、マスタへの自動昇格

– アプリケーションに影響を最小限に抑えるフェールオーバー

• シャードによるスケールアウトも可能

– アプリケーションはシャードキーを提供

– Range または Hash

– シャード管理ツール

– グローバルアップデート & テーブル

• 接続オプション

– Fabric対応Connectors

– MySQL Router

• OpenStackのサーバプロビジョニング

– Nova および Neutron APIをサポート

MySQL Fabric

Router

Application

Read-slaves

SQL

HA group

Read-slaves

HA group

Connector

Application

Page 47: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 47

補足) MySQL グループ・レプリケーション

• シェアード・ナッシング型”疑似”同期レプリケーション

• 更新はマルチ・マスタ型でどこでも可能

– 矛盾の検知と解決(トランザクションのロールバック

– "Optimistic State Machine" レプリケーション

• グループメンバーの管理と障害検知を自動化

– サーバのフェールオーバー不要

– 構成の拡張/縮小の柔軟性

– 単一障害点無し

– 自動再構成

• 既存構成との統合

– InnoDB

– GTIDベースのレプリケーション

– PERFORMANCE_SCHEMA

Application

MySQL Nodes Replication

Plugin

API

MySQL Server

Group Comms

Page 48: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 48

更なる高可用性と拡張性をサポート

MySQLの拡張性向上・組み合わせ多用化 (HA + Sharding)

Global Data Shard 1 Shard 2

MySQL Fabric controller cluster

SQL Queries

Server/Shard State & Mapping

Global Group HA Group

Coordination and Control

HA Group

Group Replication cluster

Group Replication cluster

Group Replication cluster

MySQL Router

Page 49: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 49

Page 50: MySQL Databaseのご紹介 - tokushima-oss.org€¦ · 9 MySQL Enterprise Monitor 2.2 MySQL Cluster 7.1 MySQL Cluster Manager 1.0 MySQL Workbench 5.2 MySQL Database 5.5 MySQL Enterprise