MySQL Plugins
Erkan Yanar [email protected]Blog: linsenraum.de/erkules
Xing:www.xing.com/profile/Erkan Yanar
Ein Plug-in (h¨aufig auch Plugin; von engl. to plug in, “einst¨opseln, anschließen”, deutsch etwa
“Erweiterungsmodul”) ist ein Computerprogramm, das in ein anderes Softwareprodukt “eingeklinkt” wird und damit dessen Funktionalit¨at erweitert.
Break it
Plugins k¨onnen zur Laufzeit geladen werden Kein Neukompelieren Kein Neustart
mysql> INSTALL PLUGIN pluginname SONAME ’plug.so’ mysql> UNINSTALL PLUGIN pluginname
mysql> SHOW PLUGINS
mysql> SHOW VARIABLES LIKE ’plugin dir’ - -disable-plugin-plugin name
- -plugin-plugin name=OFF
PluginTypen
PluginTypen (MySQL 5.5/Maria 5.2)
Daemon
Information Schema Full Text Parser StorageEngine Authentication Replication Audit Services
Quelle: Plugin
mysql declare plugin Makro Plugintyp
mysql_declare_plugin(semi_sync_slave) {
MYSQL_REPLICATION_PLUGIN, /* PluginTyp plugin.h */ &semi_sync_slave_plugin, /* Info */
"rpl_semi_sync_slave", /* Pluginname */ "He Zhenxing", /* autor */
"Semi-synchronous replication slave", /* description */ PLUGIN_LICENSE_GPL, /* Licenz */
semi_sync_slave_plugin_init, /* Plugin Init */ semi_sync_slave_plugin_deinit, /* Plugin Deinit */
0x0100 /* Version (1.0) */,
semi_sync_slave_status_vars, /* status variables */ semi_sync_slave_system_ vars, /* system variables */
NULL /* config options aka END */
}
Daemon
MYSQL DAEMON PLUGIN
Status Variables Global Variables
Beispiele
Außerhalb von OracleInformation schema
MYSQL INFORMATION SCHEMA PLUGIN
INFORMATION SCHEMA gibt Zugriff auf Datenbank-Metadaten Auch als Data Dictionary oder Systemkatalog bekannt.
daemon + Tabellen im I S (read only)
Beispiele
sigar vmstat
StorageEngines QueryCache
Fulltext: MYSQL FTPARSER PLUGIN
Hooks DML und MATCH() .. AGAINST Text tokenizen Index erstellen mysql parse() mysql add word() HA CAN FULLTEXTCREATE TABLE ta (a text,FULLTEXT(a) WITH PARSER plugin); SELECT ...MATCH (a) AGAINST(...);
Storage Engines
sql/handler.h Daten Indizes Binlog FULLTEXT partition usw.CREATE TABLE name (. . . ) ENGINE=engine;
MYSQL STORAGE ENGINE PLUGIN
HA CAN FULLTEXT HA CAN GEOMETRI HA CAN SQL HANDLER HA BINLOG ROW CAPABLE HA CAN INSERT DELAYED HA NO TRANSACTIONS methods create() open() write row() index read() table flags() commit() show status() savepoint rollback()
BuiltInStorageEngines
MyISAM Bis 5.1 Default Geringer Footprint FULLTEXT TableLockingKein lockfreies Backup Lesestark Seit 5.5. Default RI MVCC ACID Transaktionen lockfreies Backup Clustered Index
ARCHIVE revisionssichere Archivierung INSERT/SELECT Platzsparend Schnell CSV Daten Officekompatibel speichern
Auf ODBC verzichten :-) keine Indizes
MERGE
Wrapper f¨ur MyISAM
Vereinigung von Tabellen keine Tabelle
nur eine beschreibbar
CREATE TABLE . . . ENGINE=MERGE UNION=(. . . ) INSERT METHOD=LAST
MEMORY Speicher
kein TEXT/BLOB feste Zeilenl¨ange
NDB-Cluster
Shared Nothing HA Hoher Durchsatz Skaliert Schreibstark Synchrone ReplikationAria 1.5 ISAM → MyISAM→ Maria crashsafe MVCC,ACID FULLTEXT Transaktionen (ab 2.0) Row Locking (ab 2.0)
XTRADB
Fork vom InnoDB-Plugin (Oracle)
percona.com schnelles recovery etc.
PBXT
Paul McCullaghWrite Once/Sweeper Kein R-Cache Polution RI
ACID logbased MVCC
Row Level Locking Kein Undo
Q4M
Oku KazuhoQ4M - Die Message Queue Engine Queue 4 MySQL RabbitMQ? Messages mit SQL verwalten asynchron
log based fileformat forward
priorit¨at Howto im Blog
OQGraph
Antony Curtis and Arjen LentzGraphentheorie neo4j?
”noch“ memory only
Howto im Blog Netzwerk Abh¨angigkeiten NestedSets byebye
FEDERATED
X
Patrick GalbraithZugriff auf Tabellen via Netzwerk Verbindungsdaten im CONNECTION
CREATE TABLE name (. . . ) ENGINE=FEDERATED CONNECTION=’mysql://user:pass@host/db/table’;
Spider
Kentoku ShibaSpider
Partitionierung ¨ubers Netz Federated + XA
wow
i.e. joins auf shards part,sub + part,sub
CREATE TABLE spidi ( .. ) ENGINE=SPIDER Connection ’table spidi, user
”i“, password”p“ ’ PARTITION BY RANGE (col)(
partition p1 . . . comment ’host
Sphinx
SPHINX Full-text Indiziert Gewichte Attribute Cluster SPHINXSECREATE TABLE table (. . . ) ENGINE=SPHINX CONNECTION=’sphinx://localhost/indexname’
auth-plugin
MYSQL AUTHENTICATION PLUGIN
Authentifizierung only
INSTALL PLUGIN socket_peercred SONAME ’auth_socket.so’;
CREATE USER erkan IDENTIFIED VIA socket_peercred;
select user,host,password,plugin from mysql.user where user=’erkan’; +---+---+---+---+
| user | host | password | plugin | +---+---+---+---+ | erkan | % | | socket_peercred | +---+---+---+---+
static struct st_mysql_auth socket_auth_handler= { MYSQL_AUTHENTICATION_INTERFACE_VERSION, 0, /* client plugin */ socket_auth /* function */ }; mysql_declare_plugin(socket_auth) { MYSQL_AUTHENTICATION_PLUGIN, &socket_auth_handler, "socket_peercred", "Sergei Golubchik",
"Unix Socket based authentication", PLUGIN_LICENSE_GPL, NULL, NULL, 0x0100, NULL, NULL, NULL } mysql_declare_plugin_end;
Replication-plugin
MYSQL REPLICATION PLUGIN
INSTALL PLUGIN ’rpl semi sync master’ SONAME ’semisync master.so’; SET rpl semi sync master enabled=1;
audit-plugin
MYSQL AUDIT PLUGIN
GeneralLogHook ErrorLogHook ResultSetHook SQLStat
Server Services
sql/sql plugin services.h Zugriff auf Serverfunktionen my malloc my sync thd allocEs wurden ignoriert: Tokutek ScaleDB AWSS3 infobright/infinidb IBMDB2I VP drizzle MariaDB-CREATE-Extensions
MySQL 5.1 Plugin Developement
Andrew Hutchings, Sergei Golubchik Roland Bouman
forge.mysql.com/.../FOSDEM 2009-Roland Bouman-MySQL Plugins.pdf
Sergei Golubchik Erkan Yanar http://linsenraum.de/erkules/2010/11/the-more-you-ignore-me-the-closer-i-get.html http://linsenraum.de/erkules/2010/10/q4m-schlange-stehen-mit-mysql.html http://linsenraum.de/erkules/2010/11/klopf-klopf—authentication-framework-fur-mysql.html http://linsenraum.de/erkules
Bildernachweis
http://commons.wikimedia.org/wiki/File:Lego Chicago City View 2001.jpg
http://commons.wikimedia.org/wiki/File:2005-08-30-heating-pipe-weld.jpg
http://commons.wikimedia.org/wiki/File:Belling-Lee-Stecker.jpg
http://commons.wikimedia.org/wiki/File:Der Daemon Baphomet.PNG
http://commons.wikimedia.org/wiki/File:Hungary with Turky in Europe.jpg
Bildernachweis
http://commons.wikimedia.org/wiki/File:Cigar box.jpg http://yoshinorimatsunobu.blogspot.com/2010/10/using-mysql-as-nosql-story-for.html http://forge.mysql.com/w/images/f/fd/Custom-engine-overview.png http://www.innodb.com/ http://commons.wikimedia.org/wiki/File:Historisches-Archiv-des-Erzbistums-K%C3%B6ln-Lagerung-des-Archivgutes.JPG http://www.flickr.com/photos/janten/1119099545/sizes/o/Bildernachweis
http://commons.wikimedia.org/wiki/File:Fotothek df ps 0000970 Landschaften %5E H%C3%BCgellandschaften -Gebirgslandschaften %5E .jpg
http://dev.mysql.com/tech-resources/articles/pbxt-storage-engine.html
http://3.bp.blogspot.com/ 3l-X4JQ1EX4/S6f4IHWlpdI/AAAAAAAAATk/ e4oLASegOE/s1600-h/Screen+shot+2010-03-23+at+7.50.38+AM.png
Bildernachweis
http://upload.wikimedia.org/wikipedia/commons/8/80/Bahnsteig Wittlich.jpg
http://commons.wikimedia.org/wiki/File:Bundesarchiv B 145 Bild-F000250-0053, Deutsch-deutsche Grenze bei Heldra, BGS-Beamter.jpg
http://commons.wikimedia.org/wiki/File:Dna-split.png
http://commons.wikimedia.org/wiki/File:Bundesarchiv Bild 183-R0117-0003, VEB Robotron Elektronik Dresden, Qualit%C3%A4tskontrolle.jpg