什么是插件以及它在mysql中的工作原理?

时间:2016-01-21 06:33:37

标签: mysql mariadb

我正在探讨MySql官方网站(https://dev.mysql.com/doc/refman/5.1/en/partitioning.html)中的分区问题。 在第一页中,我找到了plugins

mysql> show plugins;
+----------------------------+----------+--------------------+---------+---------+
| Name                       | Status   | Type               | Library | License |
+----------------------------+----------+--------------------+---------+---------+
| binlog                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| mysql_native_password      | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
| mysql_old_password         | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
| sha256_password            | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
| MyISAM                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| MRG_MYISAM                 | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| MEMORY                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| CSV                        | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| InnoDB                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| INNODB_TRX                 | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_LOCKS               | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_LOCK_WAITS          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP                 | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_RESET           | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMPMEM              | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMPMEM_RESET        | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_PER_INDEX       | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_PER_INDEX_RESET | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_PAGE         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_PAGE_LRU     | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_POOL_STATS   | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_METRICS             | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_DEFAULT_STOPWORD | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_DELETED          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_BEING_DELETED    | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_CONFIG           | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_INDEX_CACHE      | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_INDEX_TABLE      | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLES          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLESTATS      | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_INDEXES         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_COLUMNS         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FIELDS          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FOREIGN         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FOREIGN_COLS    | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLESPACES     | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_DATAFILES       | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| PERFORMANCE_SCHEMA         | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| FEDERATED                  | DISABLED | STORAGE ENGINE     | NULL    | GPL     |
| ARCHIVE                    | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| BLACKHOLE                  | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| partition                  | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
+----------------------------+----------+--------------------+---------+---------+
42 rows in set (0.05 sec)

在我的脑海中有一些问题

  1. 什么是plugins
  2. 它是如何工作的?
  3. MySql可用多少个插件?
  4. 我可以添加其他plugins吗?
  5. 如果我可以添加如何添加?

2 个答案:

答案 0 :(得分:3)

在分析关于插件之后,我发现了更多关于它的事情。我深入解释。

<强> What is plugins and How it is work?

MySQL支持一个插件API,可以创建服务器组件。插件可以在服务器启动时加载,也可以在运行时加载和卸载,而无需重新启动服务器。 API是通用的,不指定插件可以执行的操作。此接口支持的组件包括但不限于存储引擎,全文解析器插件和服务器扩展。

例如,全文解析器插件可用于替换或扩充内置的全文解析器。插件可以使用与内置解析器使用的规则不同的规则将文本解析为单词。如果您需要解析具有与内置解析器所期望的特性不同的特性的文本,这将非常有用。

  

插件界面比旧的用户​​定义更通用   函数(UDF)接口。

<强> How much plugin available for MySql? (Types of Plugins)

插件API支持创建实现多种功能的插件:

  • 存储引擎
  • 全文解析器
  • 守护程序
  • INFORMATION_SCHEMA表格
  • 半同步复制
  • 审计
  • 验证
  • 密码验证和强度检查
  • 协议追踪
  • 查询重写

<强> Can i add other plugins ? / If i can add then how to add ?

使用INSTALL PLUGIN语句安装的插件:

可以使用INSTALL PLUGIN语句在运行时加载位于插件库文件中的插件。该语句还在mysql.plugin表中注册该插件,以使服务器在后续重新启动时加载它。因此,INSTALL PLUGIN需要mysql.plugin表的INSERT权限。

mysql> INSTALL PLUGIN myplugin SONAME 'somepluglib.so';

卸载插件

在运行时,UNINSTALL PLUGIN语句禁用和卸载服务器已知的插件。该语句卸载插件并将其从mysql.plugin表中删除,如果它在那里注册的话。因此,UNINSTALL PLUGIN语句需要mysql.plugin表的DELETE权限。由于插件不再在表中注册,服务器将不会自动加载插件以便后续重新启动。

答案 1 :(得分:1)

这是我安装的插件列表。还有更多。他们可以做很多事情。它们可以是存储引擎或处理用户功能或调度程序或... 因此,可以通过普通的SQL和and。来读取或写入直接的CSV或JSON文件。

您可以在这里找到一些Informations

MariaDB > SHOW PLUGINS;
+-----------------------------+--------+--------------------+------------------------+---------+
| Name                        | Status | Type               | Library                | License |
+-----------------------------+--------+--------------------+------------------------+---------+
| binlog                      | ACTIVE | STORAGE ENGINE     | NULL                   | GPL     |
| mysql_native_password       | ACTIVE | AUTHENTICATION     | NULL                   | GPL     |
| mysql_old_password          | ACTIVE | AUTHENTICATION     | NULL                   | GPL     |
| CSV                         | ACTIVE | STORAGE ENGINE     | NULL                   | GPL     |
| MEMORY                      | ACTIVE | STORAGE ENGINE     | NULL                   | GPL     |
| MyISAM                      | ACTIVE | STORAGE ENGINE     | NULL                   | GPL     |
| MRG_MyISAM                  | ACTIVE | STORAGE ENGINE     | NULL                   | GPL     |
| Aria                        | ACTIVE | STORAGE ENGINE     | NULL                   | GPL     |
| PERFORMANCE_SCHEMA          | ACTIVE | STORAGE ENGINE     | NULL                   | GPL     |
| InnoDB                      | ACTIVE | STORAGE ENGINE     | NULL                   | GPL     |
| XTRADB_READ_VIEW            | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| XTRADB_INTERNAL_HASH_TABLES | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| XTRADB_RSEG                 | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_TRX                  | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_LOCKS                | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_LOCK_WAITS           | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_CMP                  | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_CMP_RESET            | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_CMPMEM               | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_CMPMEM_RESET         | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_CMP_PER_INDEX        | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_CMP_PER_INDEX_RESET  | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_BUFFER_PAGE          | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_BUFFER_PAGE_LRU      | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_BUFFER_POOL_STATS    | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_METRICS              | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_FT_DEFAULT_STOPWORD  | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_FT_DELETED           | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_FT_BEING_DELETED     | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_FT_CONFIG            | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_FT_INDEX_CACHE       | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_FT_INDEX_TABLE       | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_SYS_TABLES           | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_SYS_TABLESTATS       | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_SYS_INDEXES          | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_SYS_COLUMNS          | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_SYS_FIELDS           | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_SYS_FOREIGN          | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_SYS_FOREIGN_COLS     | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_SYS_TABLESPACES      | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_SYS_DATAFILES        | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| INNODB_CHANGED_PAGES        | ACTIVE | INFORMATION SCHEMA | NULL                   | GPL     |
| partition                   | ACTIVE | STORAGE ENGINE     | NULL                   | GPL     |
| SEQUENCE                    | ACTIVE | STORAGE ENGINE     | ha_sequence.so         | GPL     |
| CONNECT                     | ACTIVE | STORAGE ENGINE     | ha_connect.so          | GPL     |
| QUERY_CACHE_INFO            | ACTIVE | INFORMATION SCHEMA | QUERY_CACHE_INFO.so    | BSD     |
| QUERY_RESPONSE_TIME         | ACTIVE | INFORMATION SCHEMA | query_response_time.so | GPL     |
| METADATA_LOCK_INFO          | ACTIVE | INFORMATION SCHEMA | metadata_lock_info.so  | GPL     |
| QUERY_RESPONSE_TIME_AUDIT   | ACTIVE | AUDIT              | query_response_time.so | GPL     |
| SPHINX                      | ACTIVE | STORAGE ENGINE     | ha_sphinx.so           | GPL     |
+-----------------------------+--------+--------------------+------------------------+---------+
50 rows in set (0.01 sec)