MySQL kann auch NoSQL DOAG 2011linsenraum.de/documents/doag-mynosql.pdfCrash-Safe $ Storage SQL RI...
Transcript of MySQL kann auch NoSQL DOAG 2011linsenraum.de/documents/doag-mynosql.pdfCrash-Safe $ Storage SQL RI...
Einfuhrung NoSQL Reste
MySQL kann auch NoSQLDOAG 2011
Erkan Yanar
24. November 2011
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
das ich
erkan [email protected]/erkuleswww.xing.com/profile/Erkan Yanar
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
NoSQL ist der neue Hype. Antwort auf neue Aufgaben.
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Vorgestellte Losungen:
OpenSource
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Vorgestellte Losungen:
Nur OpenSource!
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Moglichkeiten (”Entwicklungspotentiale“) von MySQL
MySQL-Plugins
Audit
Authentication
FullText
Daemon
Information Schema
Storage Engine
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Moglichkeiten (”Entwicklungspotentiale“) von MySQL
MySQL-Plugins
Audit
Authentication
FullText
Daemon
Information Schema
Storage Engine
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Memcached
KeyValue
Klassischer Vertretermemcached
MySQL & memcachedubliche Kombination
get/set
Kein Storage
Kann man Memcached loswerden? Oder auf den Zug aufspringen?
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Memcached
KeyValue
Klassischer Vertretermemcached
MySQL & memcachedubliche Kombination
get/set
Kein Storage
Kann man Memcached loswerden?
Oder auf den Zug aufspringen?
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Memcached
KeyValue
Klassischer Vertretermemcached
MySQL & memcachedubliche Kombination
get/set
Kein Storage
Kann man Memcached loswerden? Oder auf den Zug aufspringen?
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Memcached ersetzen?
Idee/Losung: Umgehen des Overheads von:
Parser
Optimizer
Global Mutex (LOCK open, LOCK thread count . . . )
Global Kernel Mutex (Threading Model)
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
08/15
Force Index
HANDLER
SELECT col FROM tabelle FORCE/USE (idx) WHERE i = 11;
HANDLER tabelle OPEN;HANDLER tabelle READ ‘PRIMARY=(1);HANDLER tabelle CLOSE;
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
08/15
Force Index
HANDLER
SELECT col FROM tabelle FORCE/USE (idx) WHERE i = 11;
HANDLER tabelle OPEN;HANDLER tabelle READ ‘PRIMARY=(1);HANDLER tabelle CLOSE;
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
HandlerSocket Yoshinori Matsunobu
Abbildung: http://yoshinorimatsunobu.blogspot.com/2010/10/using-mysql-as-nosql-story-for.html
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
HandlerSocket
750k qps
Daemon Plugin
Eigenes Protokoll
Connection Pooling
Zugriff auf Tabellen
key-value,value. . .
Security?
Vorteil gegen Memcached
Kein doppelter Speicher
Keine Latenz
Immer die richtigen Daten
Crash-Safe ↔ Storage
SQL
RI (ENGINE-Pros)
INSTALL PLUGIN handlersocket SONAME ’handlersocket.so’
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
$ telnet 192.168.178.90 9998
P 0 test hand PRIMARY name,auch
0 1
0 = 1 1
0 2 nazim meow
0 > 1 1 2
0 2 wannabe mii giants they might be
0 >= 1 1 2
0 2 nazim meow wannabe mii
erkan@x300:~$ telnet 192.168.178.90 9999
P 0 test hand PRIMARY name auch
0 1
0 + 3 11 erkan yanar
0 1
MariaDB [test]> select * from hand where id=11;
+----+-------+-------+
| id | name | auch |
+----+-------+-------+
| 11 | erkan | yanar |
+----+-------+-------+Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Memcached → InnoDB
Preview 5.6.2
Daemon-Plugin
Memcached-Protocol
Memcached-Funktionalitat
Memcached-Ersatz
InnoDB-ProsAbbildung:http://dev.mysql.com/tech-resources/articles/nosql-to-mysql-with-memcached.html
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
> SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA="innodb_memcache";
+----------------+
| TABLE_NAME |
+----------------+
| cache_policies |
| config_options |
| containers |
+----------------+
> SELECT * from innodb_memcache.cache_policies;
+--------------+-------------+-------------+---------------+--------------+
| policy_name | get_policy | set_policy | delete_policy | flush_policy |
+--------------+-------------+-------------+---------------+--------------+
| cache_policy | innodb_only | innodb_only | innodb_only | innodb_only |
+--------------+-------------+-------------+---------------+--------------+
> SELECT * from innodb_memcache.containers;
+------+-----------+-----------+-------------+---------------+-------+------------+--------------------+------------------------+
| name | db_schema | db_table | key_columns | value_columns | flags | cas_column | expire_time_column | unique_idx_name_on_key |
+------+-----------+-----------+-------------+---------------+-------+------------+--------------------+------------------------+
| aaa | test | demo_test | c1 | c2 | c3 | c4 | c5 | PRIMARY |
+------+-----------+-----------+-------------+---------------+-------+------------+--------------------+------------------------+
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Memcached → Cluster
Preview Cluster 7.2.0
Memcached-NDB
Kein MySQL-Plugin
Memcached-Plugin(>1.6.0)
Cluster/HA
Online Erweitern
Viele API-Knoten
8KB vs. 1MBROW-Length
Abbildung:http://dev.mysql.com/tech-resources/articles/nosql-to-mysql-with-memcached.html
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Keine Umwege
Memcached greift auf NDB-API zu
NDB-API direkt verwenden?
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
KeyValue
Vorteil der Memcached-Implementierung
Bekanntes Protokoll
Einfache Integration in bestehende Architekturen
Erweitert Memcached um Konsistenz → InnoDB
Erweitert Memcached um Konsitsenz und HA → NDB
Vorteil von Handlersocket
Einfache Integration in die Datenbank
Konsistenz → InnoDB
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
DocumentStore
DocumentStore
Dynamic Columns
kein Plugin
Unstrukturierte Daten
BLOB
MariaDB 5.3
(virt. col) Index
COLUMN CREATE
COLUMN ADD
COLUMN DELETE
COLUMN EXISTS
COLUMN GET
COLUMN LIST
http://linsenraum.de/erkules/2011/05/mariadbs-kruschelkiste-dynamic-columns-for-mysql.html
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
DocumentStore
> CREATE TABLE dyni ( id INT, sonderlocke BLOB);
> INSERT INTO dyni VALUES(1,COLUMN_CREATE(1 , "‘hallo"’, 2 , 42));
> SELECT id, COLUMN_LIST(sonderlocke) from dyni;
+------+--------------------------+
| id | COLUMN_LIST(sonderlocke) |
+------+--------------------------+
| 1 | 1,2 |
+------+--------------------------+
> SELECT id,COLUMN_GET(sonderlocke,1 as char) from dyni;
+------+------------------------------------+
| id | COLUMN_GET(sonderlocke,id as char) |
+------+------------------------------------+
| 1 | hallo |
+------+------------------------------------+
> UPDATE dyni SET sonderlocke=COLUMN_ADD(sonderlocke,2,NULL,3,"\o/");
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
DocumentStore
Plans for Dyn. Columns
Column-Names
Indizierung
JSON/XML
HBASE als SE :)
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
GraphEngine Antony Curtis & Arien Lentz
OQgraph
GraphEngine
SE Plugin
SQL
III. BUG!
INSTALL PLUGIN oqgraph SONAME ’ha oqgraph.so’http://linsenraum.de/erkules/2010/11/the-more-you-ignore-me-the-closer-i-get.html
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
GraphEngine Antony Curtis & Arien Lentz
CREATE TABLE stadt (
latch SMALLINT UNSIGNED NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH;
INSERT INTO stadt (origid,destid)
VALUES (1,2),(2,3),(4,1),(2,5),(5,2),(3,6),(5,4),(6,5),(6,7);
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
GraphEngine Antony Curtis & Arien Lentz
MariaDB [graph]> select linkid from stadt where origid=6 and latch=0;
+--------+
| linkid |
+--------+
| 7 |
| 5 |
+--------+
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
GraphEngine Antony Curtis & Arien Lentz
MariaDB [graph]> select linkid,seq from stadt
where origid=6 and destid=3 and latch=1;
+--------+------+
| linkid | seq |
+--------+------+
| 6 | 0 |
| 5 | 1 |
| 2 | 2 |
| 3 | 3 |
+--------+------+
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Q4M Kazuho Oku
Q4M
Storage Engine
udf()
Messages
Garantiert Abholung
http://linsenraum.de/erkules/2010/10/q4m-schlange-stehen-mit-mysql.html
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Q4M Kazuho Oku
1.client> create table message_q
(num int not null, poster varchar(255), message varchar(255)) engine=queue;
1.client> insert into message_q values(1,’mama’,’komm essen’),
(2,’papa’,’pflanze einen baum’),(3,’chef’,’%&#%$’),(4,’kind’,’spielen’);
1.client> select * from message_q where queue_wait(’message_q’);
+-----+--------+------------+
| num | poster | message |
+-----+--------+------------+
| 1 | mama | komm essen |
+-----+--------+------------+
1.client> select queue_end(’message_q’);
+------------------------+
| queue_end(’message_q’) |
+------------------------+
| 1 |
+------------------------+
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Q4M Kazuho Oku
2.client> select * from message_q where queue_wait(’message_q’);
+-----+--------+--------------------+
| num | poster | message |
+-----+--------+--------------------+
| 2 | papa | pflanze einen baum |
+-----+--------+--------------------+
2.client> select queue_abort(’message_q’);
+--------------------------+
| queue_abort(’message_q’) |
+--------------------------+
| 1 |
+--------------------------+
1.client> select * from message_q where queue_wait(’message_q’);
+-----+--------+--------------------+
| num | poster | message |
+-----+--------+--------------------+
| 2 | papa | pflanze einen baum |
+-----+--------+--------------------+
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Spider Kentoku SHIBA
spider
Partitioning&Federated
Transparentes Sharding
Easy Scaleout
Storage Engine
Abbildung:http://spiderformysql.com/product.html
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Spider Kentoku SHIBA
CREATE TABLE spider (id int primary key, .. ) ENGINE=SPIDER
CONNECTION ’table "spiderc1", user "spider", password "spider"’
PARTITION BY RANGE (id)
(
PARTITION p1 VALUES LESS THAN (10000)
comment ’host "192.168.178.91", database "test"’,
PARTITION p2 VALUES LESS THAN (30000)
comment ’host "192.168.178.92", database "test"’,
PARTITION p3 VALUES LESS THAN (50000)
comment ’host "192.168.178.93", database "test2"’
);
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Spider Kentoku SHIBA
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Spider Kentoku SHIBA
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Spider Kentoku SHIBA
Mehr dazu Morgen in diesem Raum um 15:00 Uhr.
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Spider Kentoku SHIBA
Conclusion
Zusammenfassung
NoSQL (was immer das auch ist) beinhaltet Losungen jenseits derklassischen RDMBs. Jenseits von Divide&Conquer erlaubt diemodulare Architektur von MySQL einige neue Techniken zuimplementieren. Dies vereinfacht die Implementierung/Rolloutneuer Techniken unter dem selbem Dach (MySQL).
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Unterschlagen?!
(Spider) VP
Flexieviews (materialized Views)
Infobright-Infinidb
Pentaho
Gearman (map/reduce)
Galera
http://code.google.com/p/shard-query/
mysql-proxy (i.e. sharding)
. . .
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011
Einfuhrung NoSQL Reste
Ende Gelande
erkan [email protected]/erkuleswww.xing.com/profile/Erkan Yanar
Erkan Yanar: MySQL kann auch NoSQL,DOAG 2011