[java küche rdb 最前線 2015] mysql 5.7技術アップデート
TRANSCRIPT
Copyright*©*201 ,*Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL&5.7&&& &
Ryusuke*Kajiyama*/* */*@RKajiyama*MySQL*Sales*ConsulIng*Senior*Manager,*Asia*Pacific*&*Japan*
The&State&of&the&Dolphin
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
JA�8c��g9�6a>�YV�;KI�?�"eH$ZB�"���������QLS]$f6�D>��"����!���"^E��M�P�������%��JA�8c��/,3&4�)�.�FT$S]�"��$)0+-15-�"������`�d[@=$7�O�NW_U��� ���A�����'2(4YV�? �Rb�#��"FT�C:�33�*���<G�������g9�X\��!@=�#����
SAFE*HARBOR*STATEMENT*
2*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
The*world's*most*popular*open*source*database**
3
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
20*MySQL 20 *
15*MySQL 15
10*Innobase 10
5*5
*A*Year*of*Anniversaries!
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
The*world's*most*popular*open*source*database*
*
DB8Engines.com&
h^p://db`engines.com/en/*
SNS
Copyright*©*201 *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*
*
*
12*
MySQL :*Yum,*APT,*NuGET*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
GitHub MySQL &• MySQL Git*
– *– *– *
• GitHub*for*MySQL*Community*– *– h^ps://github.com/mysql*– :*h^p://mysqlrelease.com*
13*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.6*h>p://dev.mysql.com/doc/refman/5.6/ja/index.html
14
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
1 SCSK
16
1
MySQL
MySQL MySQL Enterprise Monitor
Query Analizer
MySQL
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
IDUIDAI:&Unique&IdenNficaNon&Authority&of&India
17
*(UIDAI:*
Unique*IdenIficaIon*Authority*of*India Aadhaar
ID 2015 89 ID
*
MySQL UID
MySQL
MySQL ACID
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
** *
• *• *• *• *• *
• *• *• *• • *
• *• *
• **
MySQL*Enterprise*EdiIon*
18*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
“����MySQL DBA”##������#
MySQL*Enterprise*Monitor • MySQL
*• MySQL *
**
• *• &• SQL
Query*Analyzer*
Copyright*©*201 *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
Copyright*©*201 *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*
21*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*Support *
• &SQL &
– &
&
– &h>p://www8jp.mysql.com/support/consultaNve.html&
• &– &
– &
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*Support *
• &– CPU &
• &– &h>p://www.oracle.com/jp/support/lifeNme8support/index.html&h>p://www8jp.mysql.com/support/&
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
Oracle*Enterprise*Manager*for*MySQL*Web &
• 70% MySQL *– Web *– ** **
24*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*Enterprise*EdiIon*&*Cluster*CGE *
30 &• Oracle&SoXware&Delivery&Cloud&h^p://edelivery.oracle.com/**
*• *“MySQL*Database”*
*• *h^p://dev.mysql.com/doc/index`enterprise.html*
**
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
1,000 MySQL*Cluster
27
Paypal
1 2020330%
MySQL MySQL Cluster AWS 5
1/3
MySQL “NoSQLSQL
” Daniel Austin, Chief Architect, PayPal
h>p://www8jp.mysql.com/customers/view/?id=1223
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
:* *• *• *
• *• *• *• *
• *• *• *• *&*
*
• 4 MySQL*Cluster *LinuxWindows*
MySQL*User*Conference*Session:*h^p://bit.ly/ogeid3*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*Cluster:*SQL*and*NoSQL*Hybrid*APIsAcNve8AcNve&RDBMS && NoSQL&
29
MySQL*Cluster*Data*Nodes*
Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps Apps
JPA
Cluster*JPA
PHP Perl Python Ruby JDBC Cluster*J JS Memcached
MySQL JNI Node.JS ndb_eng
NDB*API*(C++)
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*Cluster*7.4*–*
NoSQL:*20 / & *FlexAsych*(C++*NDB*API)
SQL:*250 / & *DBT2*BM
31
!"!!!!
!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!
Read
s&per&se
cond
&
Data&Nodes&
FlexAsync&Reads&
!"!!!!
!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$Statem
ents/sec$
Data$Nodes$
DBT2$SQL$Statements$per$Second$
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|* 33
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.083.22 &*(ISAM,*HEAP)
Windows /64bit **(SJIS/UJIS)
5.0&*
/ / *XAINFORMATION_SCHEMA*
4.1&Unicode *
*CSV,*ARCHIVE*ndbcluster*
1995 2000 2005 2010 2015
5.7+&*
**
*CJK /GIS*(InnoDB)*
**
NoSQL ***
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
• MySQL*5.0*(2005)*– *– *– *– *– *– XA *– INFORMATION_SCHEMA*
• MySQL*5.1*(2008)*– *
*– *– *
*– *–
34
• MySQL*5.5*(2010)*– InnoDB *– *
*– *
*– PERFORMANCE_SCHEMA
MySQL
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
• *– *– *– SSD *– UNDO *– *– JSON*EXPLAIN*– Memcached*API*
• – Global*TransacIon*ID*– *– *– Binlog* *–
*– *
*–
35
• *– ALTER*TABLE*– *
*– *
*– *
• *• SHA256*• *
MySQL*5.6
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.6:*InnoDB*–*ALTER&TABLE
• ADD/DROP*INDEX*• ADD/DROP*COLUMN*• ADD/DROP*FOREIGN*KEY*• RENAME*COLUMN,*TABLE*• CREATE*PRIMARY*KEY*• ALTER*ROW_FORMAT,*KEY_BLOCK_SIZE*• ALTER*COLUMN*NULLABLE,*NOT_NULLABLE*•
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.6:*InnoDB
• *• / *• ID
&
:*mysql> SET innodb_buffer_pool_dump_at_shutdown=ON;
:*mysql> SET innodb_buffer_pool_load_at_startup=ON;*
! * *! * SaaS *
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
CREATE TABLE t(c1 INT) engine=InnoDB; FLUSH TABLE t FOR EXPORT; -- quiesce the table and create the meta data file $innodb_data_home_dir/test/t.cfg UNLOCK TABLES;
CREATE TABLE t(c1 INT) engine=InnoDB; -- if it doesn't already exist ALTER TABLE t DISCARD TABLESPACE; -- The user must stop all updates on the tables, prior to the IMPORT ALTER TABLE t IMPORT TABLESPACE;
MySQL*5.6:*InnoDB
• MySQL *– Export*
– Import
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.6:*InnoDBRDBMS NoSQL
• Memcached*API *– Memcached *– SQL
• NotOnlySQL *– *– JOIN FK SQL
• *– mysqld Memcached
*– InnoDB*API memcached*
*
InnoDB&Storage&Engine&
MySQL&Server& Memcached&plugin&
ApplicaNon&SQL&&
(MySQL&Client)&
NoSQL&&(Memcached&&&Protocol)&
mysqld&
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
InnoDB*memcached*Plugin• The*mapping*is*done*through*specifying*corresponding*column*values*in*containers*table:*
mysql> desc containers; +------------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------------+--------------+------+-----+---------+-------+ | name | varchar(50) | NO | PRI | NULL | | | db_schema | varchar(250) | NO | | NULL | | | db_table | varchar(250) | NO | | NULL | | | key_columns | varchar(250) | NO | | NULL | | | value_columns | varchar(250) | YES | | NULL | | | flags | varchar(250) | NO | | 0 | | | cas_column | varchar(250) | YES | | NULL | | | expire_time_column | varchar(250) | YES | | NULL | | | unique_idx_name_on_key | varchar(250) | NO | | NULL | | +------------------------+--------------+------+-----+---------+-------+ 9 rows in set (0.02 sec)
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.7*Release*Candidate*2*Available!*
42*
InnoDB :* *Online&Bulk*load* *
**(mulI`source,*mulI`threaded*slaves )*
:*greater*user*control*&*be^er*query*performance*
Performance*Schema *
MySQL*SYS*Schema *
&&& & &
MySQL*5.6 2 *
:**,* & *
NEW!*JSON Support*(now*in*labs)*
RC2*
And*many*more*new*features*and*enhancements...*h^p://mysqlserverteam.com/the`mysql`5`7`7`release`candidate`is`available/*#
Copyright*©*201 *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&
Que
ries&p
er&Secon
d&
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&
43*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
InnoDB* *Thank*you,*SanDisk*Fusion`io*
• *– *– IO *– *
OS (NVMFS) *• IO **
– MySQL *– *– SSD *
• InnoDB UNDO *
44*
RC2*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.7:* *–* &SQL
• *– * *– * *
• *– I/O *– *
• *• EXPLAIN JSON **
45*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.7:*OpImizer*`*JSON*EXPLAIN *• JSON*EXPLAIN *
– *– MySQL*Workbench Visual*Explain *
{ "query_block": { "select_id": 1, "cost_info": { "query_cost": "200.40" }, "table": { "table_name": "nicer_but_slower_film_list", "access_type": "ALL", "rows_examined_per_scan": 992, "rows_produced_per_join": 992, "filtered": 100, "cost_info": { "read_cost": "2.00", "eval_cost": "198.40", "prefix_cost": "200.40", "data_read_per_join": "852K" }, "used_columns": [ "FID", "title", "description", "category", "price", "length", "rating", "actors" ], ...
Copyright*©*201 *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 *– *
48*
14.11&InnoDB&Startup&OpNons&and&System&Variables&
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
InnoDB*`*NaIve*parIIoning*SupportInnoDB *
•
•
49
Handler**(ha_innopart)*
Encapsulate*all*parIIoning*in*one*single&handler
InnoDB&NaNve&ParNNoning&–&Early&Access&
main*handler&(ha_parIIon)
ParIIon*1*handler&
ha_innobase
ParIIon*2*handler&
ha_innobase
ParIIon*N*handler&
ha_innobase………
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
&• *( )**• *
– **
– *– JOIN *
• OR **
50*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
InnoDB*`*Full*Text*Search*(FTS)
• N`gram *– *
• mecab *–
51
CREATE TABLE `N_DEMO`( `FTS_N_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(100) DEFAULT NULL, PRIMARY KEY (`FTS_N_ID`), FULLTEXT KEY `ngram_idx` (`title`) /*!50100 WITH PARSER `ngram` */ ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
CREATE TABLE `M_DEMO` ( `FTS_M_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(100) DEFAULT NULL, PRIMARY KEY (`FTS_M_ID`), FULLTEXT KEY `mecab_idx` (`title`) /*!50100 WITH PARSER `mecab` */ ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.7*RC *• Performance&Schema:*性能統計情報のさらなる追加*• *• SYSLOG Linux/Windows *• GIS InnoDB Boost.Geometry *• Security , *
52*
• ReplicaNon*for*be^er*scalability*and*availability*• Fabric*for*high*availability*and*sharding*
Copyright*©*201 *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)* 53*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
&
54*
• 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*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
• *– *– *
• OGC(Open*GeospaIal*ConsorIum) *– *
• Boost.Geometry *– *– *
• Boost.Geometry *
MySQL&5.7:&GIS&8&Boost.Geometry &
55*
ALTER*TABLE* add*SPATIAL*index( );
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.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
56
mysqld*``iniIalize*``user=mysql
mysql_install_db*``user=mysql
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
Security&8&EncrypNon,&Passwords,&InstallaNon&• AES*256*EncrypIon*(Default*in*MySQL*5.7*)*• *
– *• *
– / *– ,* (test),* *
57*
[&Global&ConfiguraNon&]&SET*GLOBAL*default_password_lifeIme*=*180;*[&Individual&user&accounts&]&ALTER*USER*joro@sv1*PASSWORD*EXPIRE*INTERVAL*90*DAY;*ALTER*USER*joro@sv1PASSWORD*EXPIRE*DEFAULT;*ALTER*USER*joro@sv1PASSWORD*EXPIRE*NEVER;*
Copyright*©*201 *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&
58*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.7:*スキーマ内マルチスレッドスレーブ*• *
5 *– *– *
*
• GTID*&* **
• Sysbench*OLTP*test*– 1,000 *– SSD*/*48*core*HT*/*512*GB*RAM*
*59*
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*
88slave8parallel8type&&1.&DATABASE**:*(Default)*Use*the*db*parIIoned*MTS*(1*worker*per*database)*2.&LOGICAL_CLOCK:**Use*logical*clock*based*parallelizaIon*mode.&
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|* 60
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)
)*
MySQL85.7.38&Making&MySQL&Slave&ReplicaNon&Filters&Dynamic&
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*Fabric*1.5:* *&* *• OpenStack* *• *
– ;**
• *– *
• *
– *– *
• Fabric :*Python,*Java,*PHP,*.NET,*C*(labs)*– *
*62*
MySQL&Fabric&
Connector*
ApplicaIon*
Read8slaves&
mappings&
SQL&
HA&group&
Read8slaves&
HA&group&
Connector*
ApplicaIon*
Copyright*©*201 *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
Copyright*©*201 *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)*
65*
labs.mysql.com*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*Binlog*EventsBinlog&API
• C++ *• *
– 2 "transport"*– TCP*Transport*&*File*Transport*
• *– *
• API*h^p://mysqlhighavailability.com/author/nehakumari/*
66
Copyright*©*201 *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;*h^p://www.slideshare.net/nixnutz/h^p`plugin`for`mysql`39598656*
67*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
HTTP*Plugin*for*MySQLThe&SQL&endpoint&and&JSON&
68
shell> curl -X GET --user scott:tiger --url 'http://127.0.0.1:8080/sql/world/SELECT+ID,Name+FROM+City+WHERE+Name=%27Tokyo%27' [ { "meta":[
{"type":,"catalog":"def","database":"world","table":"City","org_table":"city","column":"ID","org_column":"ID","charset":63,"length":11,"flags":16899,"decimals":0},
{"type":254,"catalog":"def","database":"world","table":"City","org_table":"city","column":"Name","org_column":"Name","charset":33,"length":105,"flags":1,"decimals":0} ], "data":[ ["1532","Tokyo"] ], "status":[{"server_status":34,"warning_count":0 } ]
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
HTTP*Plugin*for*MySQL*–*SQL CRUD JSON&
URL h>p[s]://server:port/sql/ h>p[s]://server:port/crud/ h>p[s]://server:port/doc/
SQL CRUD CRUD
JSON *
SQL Yes No No
HTTP GET GET,&PUT.&DELETE GET,&PUT.&DELETE&
Yes No Yes
Yes Yes Yes
UTF88 UTF88 UTF88
Yes Yes Yes
69
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.7:*JSON*• *• JSON *
– *
• JSON *– *– SQL *
• Generated*Columns( ) **– InnoDB STORED VIRTUAL Generated*Columns *– *
• h^p://mysqlserverteam.com/json`labs`release`overview/*70*
RC2*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.7:*JSON
71
mysql> CREATE TABLE employees (ename 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; +---------------------------+ | ename| +---------------------------+ | {"id": 1, "name": "Jane"} | | {"id": 2, "name": "Joe"} | +---------------------------+ 2 rows in set (0,00 sec)
RC2*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL*5.7:*JSON• Document*ValidaIon*
– on*insert*only**
• Efficient*Access*
72
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 JSON_EXTRACT(ename, '$.name') FROM employees; +-------------------------------+ | JSON_EXTRACT(ename, '$.name') | +-------------------------------+ | "Jane" | | "Joe" | +-------------------------------+ 2 rows in set (0,00 sec)
RC2*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
New*JSON*datatype:*Supported*Types• JSON *
– Bool*– *
• *– (dateIme) (Imestamp)*– NULL*(5.7.9*)*–
73
RC2*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
• json_array() – Build*a*JSON*array*from*list*of*expressions*
• json_object() – Builds*JSON*objects*from*a*variable*length*list*of*key/value*pairs*
• json_insert() – Adds*'missing'*data*to*JSON*documents*
• json_remove() – Removes*a^ributes*from*exisIng*JSON*documents*
• json_set() – Sets*a^ributes*within*JSON*documents*
• json_replace() – Replaces*(but*doesn't*add)*a^ributes*within*JSON*documents*
• json_append() json_array_append()*(5.7.9+)*– Adds*a*value*to*the*end*of*an*array*
• json_merge() – Merges*two*arrays**
• json_extract() – Returns*a*value*nested*inside*of*a*JSON*document*
74*
JSON*FuncIons*for*CreaIng*&*ManipulaIng**JSON*Documents*
RC2*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
• json_search() – Search*for*values*within*JSON*documents*and*return*their*locaIons*
• json_contains() – Checks*for*a*specific*element*and*value*
• json_contains_path() – Determine*if*a*specific*element*is*present*in*a*document*in*a*specific*posiIon*
• json_valid() – Check*if*document*is*a*valid*JSON*document*
• json_type() – Find*the*type*of*a*value*within*a*document*
• json_keys() – Returns*arrays*of*the*key*names*for*the*JSON*documents*
• json_length() – Number*of*elements*in*JSON*document*
• json_depth() – Level*of*nesIng*in*JSON*document*
• json_unquote() – Helps*move*from*JSON*to*other*MySQL*types*
• json_quote() – Helps*move*from*other*MySQL*types*to*JSON*
75*
Query*and*Search*JSON*FuncIons*RC2*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
Generated*Columns*`* &
• Virtual*Generated*Column*– *– *
• Stored*Generated*Column*– *– *mysql> ALTER TABLE employees ADD iname VARCHAR(100) GENERATED ALWAYS AS(json_extract(ename, '$.name')) VIRTUAL; mysql> ALTER TABLE employees ADD INDEX(iname); h^p://mysqlserverteam.com/*
76*
JSON &
RC2*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
• *
– JOIN*– *–
*
• *– /
*
77*
?*
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
5.6& MySQL&Server&8&GA&InnoDB & &
&&&NoSQL &
MySQL&Cluster&8&GA&2 NoSQL 200 SQL &
&7.4&
5.7& MySQL&Server&8&RC2&&&& &
JSON Group&ReplicaNon &
78
Copyright*©*201 *Oracle*and/or*its*affiliates.*All*rights*reserved.**|*
MySQL• MySQL *
– h^p://www.mysql.gr.jp*
• MySQL*5.6*– h^p://dev.mysql.com/doc/refman/5.6/ja/index.html*
• MySQL 1 MySQL *– h^p://gihyo.jp/dev/serial/01/mysql`road`construcIon`news/0001*
• MySQL *– h^p://mysqlserverteam.com/*