1. MySql plugins
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

1. MySql plugins

on

  • 444 views

 

Statistics

Views

Total Views
444
Views on SlideShare
444
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

1. MySql plugins Presentation Transcript

  • 1. Roland Bouman http://rpbouman.blogspot.com/ 1 MySQL 5.1 Plugins
  • 2. Roland Bouman http://rpbouman.blogspot.com/ 2 Hi! Welcome to the MySQL UC, Thanks for coming!!! ● Roland Bouman ● Ex MySQL AB/Sun ● BI guy, App. Developer ● Leiden, Netherlands ● Sergei Golubchik ● Sun (MySQL) ● Architect, Senior Software Developer ● Hamburg, Germany
  • 3. Roland Bouman http://rpbouman.blogspot.com/ 3 ...and you ?! ● Operating System? ● Ever compiled MySQL from Source? ● C/C++ language skills? ● Other language skills? Java? PHP? ● Virtualbox?
  • 4. Roland Bouman http://rpbouman.blogspot.com/ 4 Program● Introduction ● Generic Code tasks ● Daemon Plug-in – Hands-on (Daemon) ● Audit Plugin (Sergei) ● FULLTEXT parser Plug-in (Sergei) ● Information Schema Plug-in (Roland) – Hands-on ● Future (Sergei) ● Storage Engine Plug-in (Roland)
  • 5. Roland Bouman http://rpbouman.blogspot.com/ 5 MySQL 5.1 Plugin API – Overview ● New in MySQL 5.1 – Successor to User-defined Functions (UDFs) ● Plugin is a dynamically loadable binary library – '.so' (linux) – '.dylib' (Mac OS/X) – '.dll' (Windows) ● Dynamically add or remove functionality – No need to recompile – No need to restart
  • 6. Roland Bouman http://rpbouman.blogspot.com/ 6 Why to Extend ? • You know why • Adding functionality to the server that we have no time to add • Adding functions that we prefer not to have in the server to avoid code bloat • Adding features that you need!
  • 7. Roland Bouman http://rpbouman.blogspot.com/ 7 How to Extend: Traditional options • Compiled-in function • allows to use statically-compiled mysqld binary • requires constant maintainance • UDF • user-defined function, loaded dynamically • easier to maintain, but still not bullet-proof • Procedure • A filter that it is put after the select, but before the data are sent (like in “ls -l|wc”) • Only statically compiled, poorly documented
  • 8. Roland Bouman http://rpbouman.blogspot.com/ 8 Plugin API • New in MySQL 5.1 • Generic ― allows to load any functionality in the running mysqld • Built-in versioning • Easy to maintain and distribute • User friendly ― no cryptic arguments to install • INSTALL PLUGIN foo SONAME 'bar.so' • CREATE AGGREGATE FUNCTION median RETURNS REAL SONAME 'aggr.so';
  • 9. Roland Bouman http://rpbouman.blogspot.com/ 9 Compiling and Linking • Built separately ? Loaded dynamically ? • Yes! No! • Plugin can be built separately • Plugin can be built from the MySQL source tree • No patching of MySQL code, simply unpack the plugin tarball – it will be picked up automatically • Plugin can be loaded dynamically • Plugin can be linked in statically • Without modifying plugin source code
  • 10. Roland Bouman http://rpbouman.blogspot.com/ 10 Plugin Can • provide the code for mysqld to execute • add new status variables • SHOW STATUS • add new command-line options • --plugin-option=value • add new server variables • SHOW VARIABLES, SET @@var • add new SQL keywords (todo) • CREATE TABLE ... METHOD='deflate'
  • 11. Roland Bouman http://rpbouman.blogspot.com/ 11 MySQL 6.0 Plugin Types ● Storage Engines ● Full text parsers ● Information Schema tables ● Daemon ● Audit Plugins (New in 6.0)
  • 12. Roland Bouman http://rpbouman.blogspot.com/ 12 MySQL 5.1 Plugins – Deployment ● Place plugin library in the plugin directory: mysql> SHOW VARIABLES LIKE 'plugin_dir'; +----------------------------------------------------------+ | Variable_name | Value | +---------------+------------------------------------------+ | plugin_dir | /usr/local/mysql/lib/plugin | +---------------+------------------------------------------+ 1 row in set (0.00 sec) ● Use DDL to install: INSTALL PLUGIN <plugin_name> SONAME '<plugin_library>' ● ...and to uninstall: UNINSTALL PLUGIN <plugin_name> ● NOTE: limited support for MS Windows
  • 13. Roland Bouman http://rpbouman.blogspot.com/ 13 MySQL 5.1 Plugins – Managing ● Show all plugins with the SHOW syntax mysql> SHOW PLUGINS LIKE 'PBXT'; ● ...or query the information schema: mysql> SELECT PLUGIN_NAME -> , PLUGIN_VERSION -> , PLUGIN_STATUS -> , PLUGIN_TYPE -> , PLUGIN_TYPE_VERSION -> , PLUGIN_LIBRARY -> , PLUGIN_LIBRARY_VERSION -> , PLUGIN_AUTHOR -> , PLUGIN_DESCRIPTION -> , PLUGIN_LICENSE -> FROM information_schema.PLUGINS
  • 14. Roland Bouman http://rpbouman.blogspot.com/ 14 Storage Engine Plugins
  • 15. Roland Bouman http://rpbouman.blogspot.com/ 15 Storage Engine Plugins ● Implements a row store ● MySQL Server delegates to engine – Storage – Retrieval – Index lookup – Statistics ● Usage: CREATE TABLE <table_name> ( ...columns... ) ENGINE <plugin_name>
  • 16. Roland Bouman http://rpbouman.blogspot.com/ 16 Storage Engine Plugin Examples ● PBXT (http://www.primebase.org/download/index.php) ● InnoDB (http://www.innodb.com/innodb_plugin/) ● XTRADB (https://launchpad.net/percona-xtradb) ● Federated X (?) ● S3 (http://fallenpegasus.com/code/mysql-awss3/) ● HTTP (http://tangent.org/528/myhttp_engine.html)
  • 17. Roland Bouman http://rpbouman.blogspot.com/ 17 FULLTEXT parser Plugins ● For FULLTEXT indexes ● Filter text for built-in parser (Extraction) – Example: parse PDF and pass on the text ● Instead of built-in parser (Splitting) – Parse words out of text ● Postprocessing ● Usage: CREATE TABLE t( doc CHAR(255), FULLTEXT INDEX (doc) WITH PARSER <parser-name> );
  • 18. Roland Bouman http://rpbouman.blogspot.com/ 18 FULLTEXT parser Plugins Fulltext Parser Plugin Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc quis felis sed pede tristi- que dignissim. Fusce luctus, nibh quis pel- FOO Extracting Splitting Postprocessing Object Text Words Index
  • 19. Roland Bouman http://rpbouman.blogspot.com/ 19 Information Schema Plugins ● Implements an information_schema table – Can provide an arbitrary set of data – Can report internal server data ● Usage: new information_schema table becomes available after installation
  • 20. Roland Bouman http://rpbouman.blogspot.com/ 20 Information Schema Plugin Examples ● SIGAR plugin – https://code.launchpad.net/~m.ch/mysql-server/sigar-plugin ● Vmstat – http://krow.net/talks/PluggageInformationSchemaVancouver2007.pdf – http://download.tangent.org/vmstat_information_schema-0.1.tar.gz ● Query Cache – http://rpbouman.blogspot.com/2008/07/inspect-query-cahce-using-mysql.html
  • 21. Roland Bouman http://rpbouman.blogspot.com/ 21 Daemon Plugins ● Generic plugin – no particular type specific interface – basically, this is a hack ● Yes, more so than the other plugin types ● Examples: – Heartbeat plugin – UDP client protocol implementation
  • 22. Roland Bouman http://rpbouman.blogspot.com/ 22 Learn more ● http://dev.mysql.com/doc/refman/5.1/en/plugin-api.html ● http://rpbouman.blogspot.com/2008/02/mysql-information-schema-plugins-best.html ● http://rpbouman.blogspot.com/2008/02/reporting-mysql-internals-with.html ● http://forge.mysql.com/wiki/MySQL_Internals_Custom_Engine ● http://tangent.org/543/Skeleton_Engine_for_MySQL.html