Location via proxy:
[ UP ]
[Report a bug]
[Manage cookies]
No cookies
No scripts
No ads
No referrer
Show this form
Search
Submit Search
第九回中国地方DB勉強会 in 米子 MySQL 5.7+
•
3 likes
•
3,207 views
R
Ryusuke Kajiyama
第九回中国地方DB勉強会 in 米子の資料です
Read less
Read more
1 of 65
Download now
Download to read offline
More Related Content
第九回中国地方DB勉強会 in 米子 MySQL 5.7+
1.
Copyright © 2015,
Oracle and/or its affiliates. All rights reserved. | Ryusuke Kajiyama / 梶山隆輔 / @RKajiyama MySQL Sales ConsulIng Senior Manager, Asia Pacific & Japan The State of the Dolphin
2.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | 以下の事項は、弊社の⼀一般的な製品の⽅方向性に関する概要を説明するものです。 また、情報提供を唯⼀一の⽬目的とするものであり、いかなる契約にも組み込むことはできません。 以下の事項は、マテリアルやコード、機能を提供することをコミットメントするものではない為 、購買決定を⾏行行う際の判断材料料になさらないで下さい。 オラクル製品に関して記載されている機能の開発、リリースおよび時期については、 弊社の裁量量により決定されます。 SAFE HARBOR STATEMENT 5
3.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | The world's most popular open source database 世界で最も普及しているオープンソース データベース
4.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | A Year of Anniversaries! 20 Years: MySQL 10 Years: Oracle stewardship of InnoDB 5 Years: Oracle stewardship of MySQL Thank You, MySQL Community, for 20 years of ContribuIons to MySQL!
5.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | Key announcements in Jan-‐Apr 2015 MySQL Cluster 7.4 GA • 200 Million NoSQL Reads/ Sec • 2.5M SQL Ops/Sec • 50% Faster Reads • 40% Faster Mixed • 5X Faster Maintenance Ops MySQL Enterprise Firewall • Real Time ProtecIon • Blocks SQL InjecIon Acacks • Block Suspicious Traffic • Learns White List • Transparent MySQL 5.7 RC • 2 X Faster than MySQL 5.6 • New OpImizer Cost Model • ReplicaIon Improvements • InnoDB FTS CJK Support 8
6.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | 9
7.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • MySQL製品のシンプルで便利なインス トール&アップグレード方法を提供 • 下記のディストリビューション向け – Oracle, Red Hat, CentOS – Fedora – Ubuntu, Debian • まもなく提供開始予定 – SUSE – 構成済みコンテナ – 利用者の多いDevOpsデプロイツールのサ ポート • 下記の最新リリースを含む – MySQL Database – MySQL Workbench – MySQL Connector/ODBC – MySQL Connector/Python – MySQL Connector/NET – MySQL UIliIes 10 MySQLコミュニティレポジトリ: Yum, APT, NuGET
8.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | GitHubへのMySQLソースコードの掲載 • MySQL開発チームのGit – 各ディストリビューションにてより迅速、柔軟に – 優れたツールの利用が可能に – 幅広くいコミュニティとの交流 • GitHub for MySQL Community – コミュニティや関連プロジェクトへのより簡単かつ高速なソースコードの提供 – ベータ版のレポジトリ: hcps://github.com/mysql – 詳細: hcp://mysqlrelease.com 11
9.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.6 リファレンスマニュアル日本語版 hAp://dev.mysql.com/doc/refman/5.6/ja/index.html 12
10.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Enterprise EdiIon 13
11.
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 EncrypNon • AES256による対称暗号 • 公開鍵方式 / 非対称暗号 • 暗号学的ハッシュによる電子署 名、照合および妥当性確認 MySQL Enterprise Audit • 接続、ログインおよびSQL実行 の記録 • ポリシーベースのフィルタリン グおよびログ切り替え • オラクルの監査仕様に準拠し たXMLベースの出力 MySQL Enterprise EdiIonによるデータ保護
12.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Enterprise Firewall • SQL InjecIon ProtecIon with PosiIve Security Model • Out of policy database transacIons detected and blocked • Logging & Analysis Select *.* from employee where id=22! Select *.* from employee where id=22 or 1=1! Block & Log ✖ Allow & Log ✔ White List ApplicaNons
13.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Enterprise Firewall Details • Firewall operaIon is turned on at a per user level • Per User States are – RECORDING – PROTECTING – OFF
14.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | What happens when SQL is blocked? • The client applicaIon gets an ERROR mysql> SELECT first_name, last_name FROM customer WHERE customer_id = 1 OR TRUE; ERROR 1045 (28000): Statement was blocked by Firewall mysql> SHOW DATABASES; ERROR 1045 (28000): Statement was blocked by Firewall mysql> TRUNCATE TABLE mysql.user; ERROR 1045 (28000): Statement was blocked by Firewall • Reported to the Error Log • Increment Counter
15.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Cluster 7.4 GA 18
16.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Cluster: SQL and NoSQL Hybrid APIs MySQL Cluster Data Nodes Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps JPA Cluster JPA PHP Perl Python Ruby JDBC Cluster J JS Apache Memcached MySQL JNI Node.JS mod_nd b ndb_eng NDB API (C++)
17.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Cluster 7.4 GA • 200 Million NoSQL Reads/Sec • 2.5M SQL Ops/Sec • 50% Faster Reads • 40% Faster Mixed Performance • AcIve-‐AcIve Geographic Redundancy • Conflict DetecIon/ ResoluIon AcIve-‐AcIve • 5X Faster Maintenance Ops • Detailed ReporIng Management 9th April 2015 Copyright 2015, oracle and/or its affiliates. All rights reserved 20
18.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • Memory opImized tables – Durable – Mix with disk-‐based tables • Massively concurrent OLTP • Distributed Joins for analyIcs • Parallel table scans for non-‐indexed searches • MySQL Cluster 7.4 FlexAsych – 200M NoSQL Reads/Second 9th April 2015 21 MySQL Cluster 7.4 NoSQL Performance 200 Million NoSQL Reads/Second Copyright 2015, oracle and/or its affiliates. All rights reserved !"!!!! !50,000,000!! !100,000,000!! !150,000,000!! !200,000,000!! !250,000,000!! 2! 4! 6! 8! 10! 12! 14! 16! 18! 20! 22! 24! 26! 28! 30! 32! Reads&per&second& Data&Nodes& FlexAsync&Reads&
19.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • Memory opImized tables – Durable – Mix with disk-‐based tables • Massively concurrent OLTP • Distributed Joins for analyIcs • Parallel table scans for non-‐indexed searches • MySQL Cluster 7.4 DBT2 BM – 2.5M SQL Statements/Second 9th April 2015 22 MySQL Cluster 7.4 SQL Performance 2.5M SQL Statements/Second Copyright 2015, oracle and/or its affiliates. All rights reserved !"!!!! !500,000!! !1,000,000!! !1,500,000!! !2,000,000!! !2,500,000!! !3,000,000!! 2! 4! 6! 8! 10! 12! 14! 16! SQL$Statements/sec$ Data$Nodes$ DBT2$SQL$Statements$per$Second$
20.
Copyright © 2015,
Oracle and/or its affiliates. All rights reserved. | MySQL 製品ロードマップ
21.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | 24 4.0 全文検索/GIS (MyISAM) 複数テーブルUPDATE/DELETE 組み込みライブラリ型サーバ Oracle MySQL Sun 3.23 MyISAM InnoDB レプリケーション 5.1 プラグガブル・ ストレージエンジン・ アーキテクチャ パーティショニング タスクスケジューラ 5.6 memcached API UNDO表領域 Global TransacIon 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オプション
22.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • 性能 – ミューテックスの分割 – 参照専用トランザクション – SSDへの最適化 – UNDO表領域 – サブクエリ高速化 – JSON EXPLAIN – Memcached API • 可用性 – Global TransacIon ID – 自動フェールオーバー – マルチスレッド・スレーブ – Binlog グループ・コミット – 行ベース・レプリケーショ ン最適化 – クラッシュセーフ・ スレーブ – チェックサム 25 • 運用効率 – オンラインALTER TABLE – バッファプールのダンプ およびインポート – トランスポータブル 表領域 – セキュリティ強化 • パスワードポリシー • SHA256 • パスワード失効 MySQL5.6での機能拡張
23.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 RC 26
24.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 Release Candidate Available! 27 InnoDBの機能拡張: Online&Bulk load オペレーション高速化 レプリケーションの改善 (mulI-‐source, mulI-‐threaded slaves等) 新しいオプティマイザコストモデル: greater user control & becer query performance Performance Schema改善 MySQL SYS Schema改善 パフォーマンス & 拡張性 管理性 MySQL 5.6比2倍の速度 セキュリティの向上: より安全な初期化, セットアップ&管理 NEW! JSONのSupport (now in labs) RC And many more new features and enhancements... hcp://mysqlserverteam.com/the-‐mysql-‐5-‐7-‐7-‐release-‐candidate-‐is-‐available/
25.
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 Queries per Second ConnecNons 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 2x Faster than MySQL 5.6 3x Faster than MySQL 5.5 645,000 QPS 28
26.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7: オプティマイザ – 新コストモデル SQL文の実行性能を向上 • 新しいコストモデルによりストレージエンジンでの処理を改善 – より正確で動的なコスト見積もり – キーの参照、テーブルスキャン、レンジスキャン、インデックススキャンなど • 様々な追加要素にてコストを設定可能 – ディスクI/O処理性能 – メモリ処理性能 • インデックスからレコードへの参照の見積もり改善 • コストの値はEXPLAINのJSON出力に含まれる 29 labs.mysql.com
27.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7: OpImizer -‐ 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" ], ...
28.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | InnoDB -‐ General Tablespace Support 31 A general tablespace is a shared tablespace, similar to the system tablespace. It can hold mulIple tables, and supports all table row formats. General tablespaces can also be created in a locaIon relaIve to or independent of the data directory. [USER01]> CREATE TABLESPACE U_TABLESPACE01 ADD DATAFILE '/home/mysql/user_tablespace01.ibd' Engine=InnoDB; Query OK, 0 rows affected (0.01 sec) [USER01]> CREATE TABLESPACE U_TABLESPACE02_8K ADD DATAFILE '/home/mysql/user_tablespace02_8k.ibd' FILE_BLOCK_SIZE = 8192 Engine=InnoDB; Query OK, 0 rows affected (0.01 sec) [USER01]> CREATE TABLE `T_USER01` ( > `id` int(11) NOT NULL AUTO_INCREMENT, `text` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) > ) TABLESPACE = U_TABLESPACE01 ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=u•8mb4; Query OK, 0 rows affected (0.01 sec) [USER01]> CREATE TABLE `T_USER02_8K` ( > `id` int(11) NOT NULL AUTO_INCREMENT, `text` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) >) TABLESPACE = U_TABLESPACE02_8K ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=u•8mb4 > ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE =8; Query OK, 0 rows affected (0.00 sec) 参照:13.1.15 CREATE TABLESPACE Syntax
29.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | InnoDB -‐ Temporary Tables • 一時テーブル専用の表領域を新規追加 – CREATE/DROPのパフォーマンスを改善 – DDLによる変更が短縮され,一部ディスクI/Oも削減 • DMLオペレーションの最適化 – No REDO logging, no change buffering, less locking • 内部的な新たなテンポラリーテーブル – ACID/MVCCに対応した専用の一時テーブル – 軽量且つ超高速で、中間のクエリの実行操作に最適 32 参照:14.11 InnoDB Startup OpNons and System Variables
30.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | クエリ・リライト・プラグイン • クエリの書き換え (パースの前と後) • パースした後での書き換えプラグイン – アプリケーションを変更することなく問題のあるクエリを書き換 え – ヒントの追加 – JOIN順の変更 • ORマッパーやサードパーティ製のアプリなどが発行する 問題となり得るクエリなどに対応 33
31.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | Generated Column Support 35 CREATE TABLE T_Generated_Column ( > pid int(10) unsigned NOT NULL AUTO_INCREMENT, > pname varchar(1024) DEFAULT NULL, > price decimal(10,2),qty int(10), > total decimal(10,2) GENERATED ALWAYS AS (price * qty) STORED, > PRIMARY KEY (pid) > ) ENGINE=InnoDB DEFAULT CHARSET=u•8mb4; Query OK, 0 rows affected (0.02 sec) 式から生成される列(2種類) -‐ VIRTUAL(default) : SELECT時に計算。データ保存されず,インデックスの作成不可 -‐ STORED: INSERT/UPDATE時に計算。データは保存され,インデックス作成可能 Useful for: -‐ FuncIonal index: create a stored column, add a secondary index -‐ Materialized cache for complex condiIons -‐ Simplify query expression <type> [ GENERATED ALWAYS ] AS ( <expression> ) [ VIRTUAL|STORED ] [ UNIQUE [KEY] ] [ [PRIMARY] KEY ] [ NOT NULL ] [ COMMENT <text> ]
32.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | Generated Column Support 36 Generated Columnに対してIndex作成が可能なので、 Where句はindexを利用し最適なコストでデータを抽出可能 参照: Generated Columns in MySQL 5.7.5
33.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | InnoDB -‐ Full Text Search (FTS) -‐ ngram 37 InnoDB Full Text Search (FTS) にて 中国語, 韓国語,日本語をサポート N-‐gram support for Chinese and Korean, addiIonal MeCab support for Japanese CREATE TABLE `N_DEMO` ( `FTS_N_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `Itle` varchar(100) DEFAULT NULL, PRIMARY KEY (`FTS_N_ID`), FULLTEXT KEY `ngram_idx` (`Itle`) /*!50100 WITH PARSER `ngram` */ ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=u•8mb4;
34.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | InnoDB -‐ Full Text Search (FTS) -‐ mecab 38 InnoDB Full Text Search (FTS) にて 中国語, 韓国語,日本語をサポート N-‐gram support for Chinese and Korean, addiIonal MeCab support for Japanese CREATE TABLE `M_DEMO` ( `FTS_M_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `Itle` varchar(100) DEFAULT NULL, PRIMARY KEY (`FTS_M_ID`), FULLTEXT KEY `mecab_idx` (`Itle`) /*!50100 WITH PARSER `mecab` */ ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=u•8mb4;
35.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7 RCにおける運用サポート機能 • Performance Schema: 性能統計情報のさらなる追加 • オンライン処理においての機能拡張 • SYSLOGをLinux/Windows共にネイティブサーポート • GIS機能をInnoDBの空間インデックスとBoost.Geometryの統合でサポート • Security強化として,簡単で安全な初期設定と管理をサポート 39 • ReplicaNon for becer scalability and availability • Fabric for high availability and sharding
36.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL SYS Schema DB管理者、開発者や運用担当者を支援 • DB管理者や運用担当者の作業効率を改善 -‐ サーバの稼働状況、ユーザやホストの状況、主要な稼働指標 -‐ 性能問題の発見、分析および改善 • 状況をより簡単に把握し理解するための複数のビュ ー -‐ IO量の高いファイルや処理、ロック、コストの高いSQL文 -‐ テーブル、インデックス、スキーマの統計 • 他のデータベースにおけるSYS類似機能: -‐ Oracle V$表 (動的パフォーマンスビュー) -‐ Microsoƒ SQL Server DMV (Dynamic Management Views) 40
37.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | オンライン処理の拡張 41 • Resize the InnoDB Buffer Pool online – オンラインでのバッファーサイズのチューニング – データベースの使用パターンの変化にリアルタイムで適応 • Separate UNDO tablespace – 自動オンラインUNDOログ切り捨て(MySQL 5.7.5∼) – UNDOログファイルサイズの増加を回避する事が可能 • Dynamic configuraNon – Making exisIng se„ngs dynamically configurable – As a design principle for new features & se„ngs – その他、幾つかのレプリケーションの設定変更等も オンラインで変更可能になりました。 参照:14.4.8 TruncaIng Undo Logs That Reside in Undo Tablespaces
38.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • 独自コードの置き換え – 空間図形情報の計算 – 空間図形情報の分析 • OGC(Open GeospaIal ConsorIum)準拠 – パフォーマンスの向上 • Boost.Geometryによる効果 – エキスパートとの交流 – 非常に活発なコミュニティ • Boost.Geometryへのコントリビュートも MySQL 5.7: GIS -‐ Boost.Geometryとの統合 43 例)ALTER TABLE テーブル名 add SPATIAL index(列名);
39.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7.7 セキュリティの強化 • mysql_install_dbコマンド非推奨 – mysqldの-‐-‐iniIalizeまたは-‐-‐iniIalize-‐insecureオプションで初期化 • CREATE USER文とALTER USER文にオプション追加 – SSL, PASSWORD EXPIRE, ACCOUNT [LOCK | UNLOCK] • mysql.userテーブルのPassword列がauthenIcaIon_stringに変更に • SET PASSWORD文およびPASSWORD()関数が非推奨 – ALTER USER文での設定を推奨 • ENCRYPT, DES_ENCRYPT, DES_DECRYPT関数非推奨 AES推奨 ユーザ管理とセキュリティ mysqld -‐-‐iniIalize -‐-‐user=mysql mysql_install_db -‐-‐user=mysql
40.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | Security -‐ EncrypNon, Passwords, InstallaNon • AES 256 EncrypIon (Default in MySQL 5.7 ) • パスワードローテーションポリシー – インスタンス全体、ユーザー単位で設定可能 • Deployment: デフォルトで安全に無人インストールを行う事が可能 – インストール時にランダムなパスワードを設定/匿名のアカウントを削除 – テストアカウント, スキーマ(test), デモファイルは作成されなくなりました 45 [ Global ConfiguraNon ] SET GLOBAL default_password_lifeIme = 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;
41.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7におけるレプリケーションの機能拡張 • MulI-‐Source ReplicaIon • Performance enhancement of MulI-‐Thread Slave • gId_mode is now dynamic • Making MySQL Slave ReplicaIon Filters Dynamic • Preparing implementaIon of Group ReplicaIon [Labs]
42.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • 複数のマスターでの変更点を1台 のスレーブに集約 – 全てのシャードのデータを集約 – より柔軟なレプリケーション構成 – バックアップ処理を集約 • 準同期レプリケーション&改良 版 マルチスレッドスレーブ対応 • スレーブ側でのフィルタリング が可能 MySQL 5.7: MulI-‐Source ReplicaIon 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 47
43.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | 48 MySQL 5.7: MulI-‐Source ReplicaIon 参照: 17.1.4.1 MySQL MulN-‐Source ReplicaNon Overview マルチソースレプリケーションには、競合 検知や 解消する仕組みは組み込まれていないので、 それぞれの送信元のデータが競合しないよ うに アプリケーションの設計を行う必要があり ます。 例) -‐ データベース分割 -‐ テーブルのシャーディング 各チャネルごとにレプリケーショ ンを構成
44.
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 TransacNons per Second Baseline 50 clients 100 clients 150 clients 200 clients 51 -‐-‐slave-‐parallel-‐type 1. DATABASE : (Default) Use the db parIIoned MTS (1 worker per database) 2. LOGICAL_CLOCK: Use logical clock based parallelizaIon mode.
45.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | 52 マルチスレッドスレーブセットアップ手順 ON MASTER: 1. start master with -‐-‐binlog-‐max-‐flush-‐queue-‐Ime=0 ON SLAVE: 1.a. Start slave server with -‐-‐slave-‐parallel-‐type=LOGICAL_CLOCK -‐-‐slave-‐parallel-‐workers=N 又は 1.b Start the slave server normally. Change the MTS opIons dynamically using the following mysql: STOP SLAVE: -‐-‐if the slave is running mysql: SET GLOBAL SLAVE_PARALLEL_TYPE='LOGICAL_CLOCK'; mysql: SET GLOBAL SLAVE_PARALLEL_WORKER=N; mysql: START SLAVE: ※Default 値は0 ※Default 値はDATABASE ※Default 値は0
46.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | 54 GTIDモード(gId_mode)レプリケーションへのオンライン移行 参照:Enabling Global TransacNon IdenNfiers Without DownNme in MySQL 5.7.6 1. Disable all write operaIons. 2. Wait for all transacIons to propagate from the master(s) to all slaves. 3. Stop all servers. 4. On each server, set gId-‐mode=ON in the configuraIon file. 5. Start all servers. 6. Enable write operaIons. It is sIll possible to use the old, offline procedure. The procedure is as follows: Offline procedure Online procedure 詳細: 17.1.5.2 Enabling GTID TransacIons Online 17.1.5.4 Verifying ReplicaIon of Anonymous TransacIons 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 gId-‐mode=ON to my.cnf. 8 STOP SLAVE ; CHANGE MASTER TO MASTER_AUTO_POSITION = 1; START SLAVE; 各サーバーで以下のコマンドを実行 MySQL ReplicaIonの設定や運用を簡素化する為に、GTIDモードのレプリケーションを利用する方法がありますが、既にGTID モード以前のレプリケーションで運用されている場合は、稼働中の全てのサーバーを停止してからGTIDモードのレプリケー ションへ移行する必要がありました。しかし、稼働中のサービスを停止して切り替える事は難しいのが現実です。 MySQL 5.7.6 以降のMySQLにアップグレードする事で、オンラインのままMySQLのレプリケーションを切り替える事が出来るよ うになりました。 5.6.x Standard ReplicaIon 5.7.6~ Standard ReplicaIon 5.7.6 ~ GTID Mode ReplicaIon ① ②
47.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Fabric 1.5: 高可用性 & シャーディング • OpenStack との統合 • 高可用性 – サーバの監視; スレーブの自動昇格と透過 的なレプリケーション切り替え • シャーディングによる拡張性 – アプリケーションがシャードのキーを提供 • 整数型、日付型、文字列型 – レンジまたはハッシュ – シャード再構成可能 • Fabric対応コネクタ利用: Python, Java, PHP, .NET, C (labs) – プロキシを使わないので低レイテンシ、 ボトルネック無し MySQL Fabric Connector ApplicaIon Read-‐slaves mappings SQL HA group Read-‐slaves HA group Connector ApplicaIon 55 GA
48.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | 56 MySQL Slave ReplicaIon 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以前は、ユーザーはOpIonファイル(my.cnf)か、コマンドラインパラメータを使用 してフィルタリングルールを設定することが出来ますが、いずれの場合もMySQLサーバはフィ ルタリングルールの変更を反映する為に再起動する必要があります。 The following slave replicaIon 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 ReplicaNon Filters Dynamic
49.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Labs 57
50.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Labs • 先進的な機能や実験的な仕様のをいち早く公開 – コミュニティからのフィードバックをいただく • 将来的にはMySQLサーバやMySQL Cluster本体への統合を期待 – MySQL 5.6 memcached API – MySQL Cluster 7.2 memcached API – MySQL 5.6 Performance Schema – MySQL 5.6 Intra-‐schema MulI Thread Slave – MySQL 5.6 Online Alter Table – MySQL 5.7 MulI Source ReplicaIon – MySQL 5.7 New OpImizer Cost Model 58
51.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • シェアード・ナッシング型”疑似”同期レプリケーション • 更新はマルチ・マスタ型でどこでも可能 – 矛盾の検知と解決(トランザクションのロールバック – “OpImisIc State Machine” レプリケーション • グループメンバーの管理と障害検知を自動化 – サーバのフェールオーバー不要 – 構成の拡張/縮小の柔軟性 – 単一障害点無し – 自動再構成 • 既存構成との統合 – InnoDB – GTIDベースのレプリケーション – PERFORMANCE_SCHEMA MySQL 5.7: グループレプリケーション ApplicaIon MySQL Masters ReplicaIon Plugin API MySQL Server Group Comms (Corosync) 59 labs.mysql.com
52.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | Early Access Feature (EAF): Data DicIonary Replacing the FRMs • A single repository for database object metadata – InnoDB tables replace .frm, .trg, .trn, .par files • Atomic & crash-‐safe operaIons today – TransacIonal in the future • Makes adding new features much easier • Eliminates complexity, resolves bugs • Improves performance • Leverages InnoDB strengths 60
53.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | HTTP Plugin for MySQL • MySQLサーバへのHTTP(S)エンドポイントを提供するプラグイン • 結果をUTF8でエンコードされたJSONフォーマットにシリアライズ • 3種類のユーザエンドポイント – SQL – CRUD -‐ Key-‐Value – JSON -‐ Document • For more details; hcp://www.slideshare.net/nixnutz/hcp-‐plugin-‐for-‐mysql-‐39598656 61
54.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | HTTP Plugin for MySQL The SQL endpoint and JSON 62 shell> curl --user basic_auth_user:basic_auth_passwd --url "http://127.0.0.1:8080/sql/db/SELECT+1” [ { "meta":[ {"type":8,"catalog":"def","database":"","table":"”, "org_table":"","column":"1","org_column":"","charset":63, "length":1,"flags":129,"decimals":0} ], "data":[ ["1"] ], "status":[{"server_status":2,"warning_count":0}] } ]
55.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | HTTP Plugin for MySQL -‐ IniIal version • HTTP Basic AuthenIcaIon for SSL and Non-‐SSL • No query cache support • No commercial thread pool plugin support • Not all MySQL pluggable auth methods supported • Unlimited: all SQL statements • Unlimited: everything the server returns 63 shell> curl --user basic_auth_user:basic_auth_passwd --url "http://.../sql/db/SELECT+col_float+FROM+sql_types"
56.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL Binlog Events Formerly known as Binlog API • C++ library for reading Binary log • Can read binary log from server or from file – One transport for each kind of source – Currently have file and mysql transport • Decode binary log events – Contain code to decode the events • Event Driven API 64
57.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7: JSON • OpImized for read intensive workload • NaIve JSON data types – NaIve internal binary format for efficient processing & storage • Built-‐in JSON funcIons – Allowing you to efficiently store, search, update, and manipulate Documents • JSON Comparator – Allows for easy integraIon of Document data within your SQL queries • Indexing of Documents using Generated Columns – InnoDB supports indexes on both stored and virtual Generated Columns – New expression analyzer automaIcally uses the best “funcIonal” index available 6/6/15 Copyright © 2015, Oracle and/or its affiliates. All rights reserved 65
58.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7: JSON 66 mysql> CREATE TABLE employees (data JSON); Query OK, 0 rows affected (0,01 sec) mysql> INSERT INTO employees VALUES ('{"id": 1, "name": "Jane"}'); Query OK, 1 row affected (0,00 sec) mysql> INSERT INTO employees VALUES ('{"id": 2, "name": "Joe"}'); Query OK, 1 row affected (0,00 sec) mysql> select * from employees; +---------------------------+ | data | +---------------------------+ | {"id": 1, "name": "Jane"} | | {"id": 2, "name": "Joe"} | +---------------------------+ 2 rows in set (0,00 sec)
59.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | MySQL 5.7: JSON • Document ValidaIon – on insert only • Efficient Access 67 mysql> INSERT INTO employees VALUES ('some random text'); ERROR 3130 (22032): Invalid JSON text: "Expect a value here." at position 0 in value (or column) 'some random text'. mysql> select jsn_extract(data, '$.name') from employees; +-----------------------------+ | jsn_extract(data, '$.name') | +-----------------------------+ | "Jane" | | "Joe" | +-----------------------------+ 2 rows in set (0,00 sec)
60.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • jsn_array() – Build a JSON array from list of expressions • jsn_object() – Builds JSON objects from a variable length list of key/value pairs • jsn_insert() – Adds 'missing' data to JSON documents • jsn_remove() – Removes acributes from exisIng JSON documents • jsn_set() – Sets acributes within JSON documents • jsn_replace() – Replaces (but doesn't add) acributes within JSON documents • jsn_append() – Adds a value to the end of an array • jsn_merge() – Merges two arrays • jsn_extract() – Returns a value nested inside of a JSON document 6/6/15 68 JSON FuncIons for CreaIng & ManipulaIng JSON Documents Copyright © 2015, Oracle and/or its affiliates. All rights reserved
61.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • jsn_search() – Search for values within JSON documents and return their locaIons • jsn_contains() – Checks for a specific element and value • jsn_contains_path() – Determine if a specific element is present in a document in a specific posiIon • jsn_valid() – Check if document is a valid JSON document • jsn_type() – Find the type of a value within a document • jsn_keys() – Returns arrays of the key names for the JSON documents • jsn_length() – Number of elements in JSON document • jsn_depth() – Level of nesIng in JSON document • jsn_unquote() – Helps move from JSON to other MySQL types • jsn_quote() – Helps move from other MySQL types to JSON 6/6/15 69 Query and Search JSON FuncIons Copyright © 2015, Oracle and/or its affiliates. All rights reserved
62.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | Generated Columns • Virtual Generated Column – Generated on the fly when the column is read – Can be indexed • Stored Generated Column – Generated when the referenced column is wricen to – Can be indexed mysql> ALTER TABLE employees ADD name VARCHAR(100) GENERATED ALWAYS AS(jsn_extract(info, '$.name')) VIRTUAL; mysql> ALTER TABLE employees ADD INDEX(name); hcp://mysqlserverteam.com/ 70 Digging into your Documents labs.mysql.com 6/6/15 Copyright © 2015, Oracle and/or its affiliates. All rights reserved
63.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | • Save memory/storage and simplify applicaIon – Joins between Documents • Normalize data where it makes sense – Foreign Keys between Documents – Update mulIple Documents in a single atomic transacIon • Leverage all of your data – Read/write Document and relaIonal data in a single query/transacIon • 20 years of product maturity 6/6/15 71 So Just Another Document Store? Copyright © 2015, Oracle and/or its affiliates. All rights reserved
64.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | 5.6 MySQL Server – GA InnoDBの改良やオプティマイザの刷新による性能&拡張性向上 レプリケーションの可用性向上 & NoSQLインタフェース追加 MySQL Cluster -‐ GA 秒間2億件のNoSQL処理、秒間200万件のSQL処理 リカバリや再起動時間の短縮 7.4 5.7 MySQL Server – RC リファクタリング & 各機能のプラグイン化による性能と信頼性の向上 JSONやGroup ReplicaNonなどクラウド環境での要件への対応
65.
Copyright © 2015
Oracle and/or its affiliates. All rights reserved. | The world's most popular open source database 世界で最も普及しているオープンソース データベース
Download