Chapter1. Introduction to the InnoDB Plugin

Chapter1. Introduction to the InnoDB Plugin

第一章:InnoDB Plugin简介

Table of Contents

目录

1.1.Overview

1.1. InnoDB Plugin概述

1.2.Features of the InnoDB Plugin

1.2. InnoDB Plugin特性介绍

1.3.Obtaining and Installing the InnoDB Plugin

1.3.如何获取并安装InnoDB Plugin

1.4.Viewing the InnoDB Plugin Version Number

1.4.如何查看InnoDB Plugin版本号

1.5.Operational Restrictions

1.5.InnoDB Plugin操作限制

1.1. Overview

1.1.InnoDB Plugin概述

Theunique architecture of MySQL permits multiple storage engines with differentcapabilities to be accessed through the same SQL language and APIs. Startingwith version 5.1, MySQL AB has promoted the idea of a“pluggable”storage engine architecture, which permits multiple storageengines to be added to MySQL. Currently, however, most users have accessed onlythose storage engines that are distributed by MySQL AB, and are linked into thebinary (executable) releases.

MySQL独特的架构使得多个具有不同功能的存储引擎通过相同的SQL语言和API来操作数据库。5.1版本开始,MySQL AB公司推出可插拔存储引擎”架构,它允许多个存储引擎添加到MySQL然而,目前大多数用户只能使用MySQL AB的二进制(可执行文件)分发版。

Since2001, MySQL AB has distributed the InnoDB transactional storage engine with itsreleases (both source and binary). Beginning with MySQL version 5.1, it ispossible for users to swap out one version of InnoDB and use another. Thepluggable storage engine architecture also permits Innobase Oy to release newversions of InnoDB containing bug fixes and new features independently of therelease cycle for MySQL. Users can thus take advantage of these new versions ofInnoDB in the context of their deployed MySQL installations.

2001年以来,MySQL AB公司已发布InnoDB事务存储引擎(包括源代码和二进制版本)。MySQL 5.1版本开始,它可以保证用户交换使用不同版本的InnoDB。与此同时,可插拔存储引擎”架构使得Innobase Oy公司能独立于MySQL的发布周期来发布新版本的InnoDB(包含bug修复功能及其它新特性)。因此,用户可以在其部署的MySQL安装背景下使用这些新版本InnoDB引擎。

1.2. Features of the InnoDB Plugin

1.2. InnoDB Plugin特性介绍

The InnoDB Plugin for MySQL contains severalimportant new features:

InnoDB Plugin具有以下重要的新特性:

Viewingthe InnoDB Plugin version number

查看Plugin版本

Fastindex creation: add or drop indexes without copying the data

快速创建索引:在不拷贝数据的前提下添加或者删除索引

Datacompression: shrink tables, to significantly reduce storage and i/o

数据压缩:收缩表,明显减少存储空间和I/O

Newrow format: fully off-page storage of long BLOB, TEXT, and VARCHAR columns

新的行格式:对于长的BLOB, TEXTVVARCHAR字段可进行完整的off-page存储

Fileformat management: protects upward and downward compatibility

文件格式管理:保护向上和向下的版本兼容

INFORMATION_SCHEMAtables: information about compression and locking

INFORMATION_SCHEMA 表:新增压缩和锁的信息

Performanceand scalability enhancements:

性能和可扩展性的增强:

Fasterlocking for improved scalability

更快的锁机制

Usingoperating system memory allocators

使用操作系统的内存分配器

ControllingInnoDB insert buffering

控制InnoDB插入缓冲

Controllingadaptive hash indexing

控制适用性散列索引(自适应哈希索引)

Changesregarding thread concurrency

改进线程并发机制

Changesin read ahead algorithm

改变预读算法

Multiplebackground I/O threads

多后台I/O线程

GroupCommit

组提交

Controllingmaster thread I/O rate

控制主线程的I/O速率

Controllingflushing rate of dirty pages

控制刷脏页的速率

Usinga portable PAUSE to InnoDB spin loop

使用便捷式暂停来实现InnoDB的自旋循环

ControlOver Spin Lock Polling

控制自旋锁轮询

Changingdefaults of parameters

更改参数的默认值

MakingBuffer Cache Scan Resistant

缓冲区高速缓存扫描

Improvementsto Crash Recovery Performance

崩溃恢复性能的改进

Otherchanges for flexibility, ease of use and reliability:

其他关于灵活性、易用性和可靠性的改进:

Dynamiccontrol of system configuration parameters

系统配置参数的动态控制

TRUNCATETABLE reclaims space

TRUNCATE TABLE回收空间

InnoDB“strict mode”

InnoDB严格模式

Controlover statistics estimation

控制数据优化

Bettererror handling when dropping indexes

删除索引时更好地处理错误

Morecompact output of SHOW ENGINE INNODB MUTEX

更紧凑地输出SHOW ENGINE INNODB MUTEX

MoreRead Ahead Statistics

更多预读统计

Notethat the ability to use data compression and the new row format require the useof a new InnoDB file format called “Barracuda”. The previous file format, usedby the built-in InnoDB in MySQL versions 5.0 and 5.1 is now called “Antelope”and does not support these features, but does support the other featuresintroduced with the InnoDB Plugin.

需要注意的是,为了实现数据压缩和新的行格式,我们需要使用InnoDB的一个名为Barracuda的新的文件格式。不管是MySQL 5.0还是5.1版本,之前使用的文件格式均被称为Antelope,它是MySQL内置的InnoDB,不支持数据压缩及新的行格式,但支持上述InnoDB Plungin的其他功能。

TheInnoDB Plugin is upward compatible from standard InnoDB as built in to, anddistributed with, MySQL. Existing databases can be used with the InnoDB Pluginfor MySQL. As described inSection9.5, “Configuring the InnoDB Plugin”, the new parameterinnodb_file_format can help protect upward and downward compatibility betweenInnoDB versions and database files, allowing users to enable or disable use ofnew features that can only be used with certain versions of InnoDB.

这个InnoDB Plugin,与原先内置在MySQL并跟MySQL一起分发的标准版本的InnoDB互相兼容。现有的数据库可以跟这个MySQLInnoDBPlugin一起使用。正如在9.5章节“InnoDBPlugin配置所述,新的参数innodb_file_format可以帮助保护不同的InnoDB版本、不同的数据库文件之间的兼容性,允许用户启用或禁用一些只有在特定版本的InnoDB下才有的新功能。

Thebuilt-in InnoDB in MySQL since version 5.0.21 has a safety feature thatprevents it from opening tables that are in an unknown format. However, asnoted inSection11.2, “The Built-in InnoDB, the Plugin and File Formats”, thesystem tablespace may contain references to new-format tables that will confusethe built-in InnoDB in MySQL. These references will be cleared in a “slow”shutdown of the InnoDB Plugin.

MySQL 5.0.21版本开始,内置InnoDB具有这样一个安全功能:禁止打开未知格式的表。然而,正如在11.2章节内置InnoDBPlugin和文​​件格式所提及的,系统表空间可能会引用一些新格式的表,混淆了MySQL中的内置InnoDB。这些引用将在InnoDBPlugin“关闭时被清除。

 

Withprevious versions of InnoDB, no error would be returned until you try to accessa table that is in a format “too new” for the software. Beginning with version1.0.1 of the InnoDB Plugin, however, to provide early feedback, InnoDB willcheck the system tablespace to ensure that the file format used in the databaseis enabled for use before it will start. SeeSection4.4.1, “Startup File Format Compatibility Checking” for thedetails.

在以往的InnoDB版本中,只有在用户尝试使用一个太新的文件格式时,命令才将返回错误。然而,从InnoDBPlugin1.0.1版本开始,为提供早期反馈,InnoDB将全面检查系统表空间,以确保在数据库中使用的文件格式在启用前是可用的。详情参考4.4.1章节,“启动时检查文件格式的兼容性”。

1.3. Obtaining and Installing the InnoDB Plugin

1.3.如何获取并安装InnoDB Plugin

From theMySQL download site, youcan download the MySQL Server 5.1.38 and up, containing an additional, upgradedversion of InnoDB with additional features beyond the built-in InnoDB providedby MySQL. You can configure your server to use the InnnoDB Plugin rather thanthe built-in InnoDB, to take advantage of the extra features and performanceenhancements in the Plugin. The InnoDB Plugin for MySQL is licensed under thesame license that MySQL uses (GPLv2). It is available at no charge for use andcan be freely redistributed, subject to the same requirements of the GPL as isMySQL itself (see theGNU General PublicLicense, version 2). Limited support is available for the InnoDBPlugin for MySQL athttp://forums.innodb.com. Youmay also report bugs in the InnoDB Plugin using theMySQL bug database.

您可以访问MySQL下载网站http://dev.mysql.com/downloads/),下载并安装MySQL Server 5.1.38版本,它包含一个额外的InnoDB升级版本,其附加功能比MySQL提供的内置InnoDB要强大得多。在配置服务器时,您可以直接使用InnnoDB Plugin,而不是内置的InnoDB引擎,充分利用InnnoDB Plugin的附加功能及性能增强的优势。与MySQL的授权方式一样, InnoDBPlugin也在GPL第二版的许可证下授权发布。InnoDBPluginMySQL同样遵守GPL条款,并且可以完全免费使用以及免费再分发(详情参阅第2GNU通用公共许可证http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)。关于MySQLInnoDBPlugin,用户还可以访问http://forums.innodb.com/网站获取更多使用方面的信息,也可以在http://bugs.mysql.com/网站上提交InnoDBPlugin错误报告。

 

In many environments, the InnoDB plugincan dynamically be added to a MySQL instance without relinking the MySQLserver. The plugin version of InnoDB then “takes over” from the staticallylinked InnoDB that is part of the mysqld binary. In other environments, it iscurrently necessary to build the entire MySQL server, including the InnoDBplugin, from source code.

在许多环境中,MySQL配置支持动态加载InnoDBPluginMySQL实例管理器,而无需重新连接MySQL服务器。然后,InnoDBPlugin版本便取代了包含mysqld二进制可执行文件的静态编译的InnoDB版本。在其他环境中,目前仍有必要建立整个MySQL服务器,包括InnoDBPlugin的源代码。

 

OnLinux, Unix and Windows, it is a simple matter of installing the InnoDB Pluginfor MySQL using theMySQL commandINSTALL PLUGIN. When the InnoDB Plugin forMySQL is installed, it replaces the statically-linked version of InnoDB that isincorporated in the MySQL binary as distributed by MySQL AB.

LinuxUnixWindows环境下,易于安装InnoDBPlugin(详情参考http://dev.mysql.com/doc/refman/5.1/en/install-plugin.html)。安装完毕后,InnoDBPlugin替代了InnoDB的静态链接版本(该版本为MySQL AB公司分发版本,包含MySQL二进制可执行文件)。

 

Onplatforms where the dynamic plugin is not available, users must download thesource code for the InnoDB Plugin for MySQL and build MySQL from source.Building from source also facilitates the distribution of a MySQL server wherethe InnoDB Plugin is already “installed”, so all users of an organization canuse the new capabilities without the INSTALL step. The procedure for buildingfrom source code is documented inSection9.4, “Building the InnoDB Plugin from Source Code”.

对于某些平台,动态Plugin是不可用的,用户必须下载MySQLInnoDB Plugin的源码,并通过源码建立MySQL。在源码基础上建立MySQL有利于MySQL服务器的分布,且该服务器自带InnoDB Plugin。如此一来,同一数据库的所有用户都可以跳过InnoDB Plugin的安装步骤而使用其新功能。具体操作方法请查阅9.4章节“源码安装InnoDB Plugin ”。

 

Fullinstructions are provided in Chapter9,Installing the InnoDB Plugin.

关于InnoDB Plugin的安装步骤,9 InnoDB Plugin的安装”将有详细说明。

1.4. Viewing the InnoDB Plugin Version Number

1.4.如何查看InnoDB Plugin版本号

InnoDBPlugin releases are numbered with version numbers independent of MySQL releasenumbers. The initial release of the InnoDB Plugin is version 1.0, and it isdesigned to work with MySQL 5.1.

InnoDB Plugin的版本号独立于MySQL的版本号,InnoDB Plugin 1.0是其发布的初始版本,它是为MySQL 5.1设计的。

 

The first component of the InnoDB Pluginversion number designates a major release level.

InnoDB Plugin的版本号由三部分组成。第一部分代表重要的发布级别。

 

The second component corresponds to theMySQL release. The digit 0 corresponds to MySQL 5.1.

第二个部分与MySQL版本相对应。数字0对应的是MySQL 5.1

 

Thethird component indicates the specific release of the InnoDB Plugin (at a givenmajor release level and for a specific MySQL release); only bug fixes and minorfunctional changes are introduced at this level.

第三部分表示特定版本的InnoDB Plugin(在给定的发布级别上与特定的MySQL发布版本相对应);在此情况下,只有bug修复及其他功能有细微变化。

 

Onceyou have installed the InnoDB Plugin, you can check its version number in threeways:

一旦安装了InnoDB Plugin,你可以通过三种渠道查看其版本号:

 

Inthe error log, it is printed during startup

InnoDB Plugin启动的时候,会在错误日志中打印版本号

 

SELECT@@innodb_version;

 

TheInnoDB Plugin writes its version number to the error log, which can be helpfulin diagnosis of errors:

InnoDB Plugin将版本号写进错误日志中,有助于诊断错误:

09110512:28:06 InnoDB Plugin 1.0.5 started; log sequence number 46509

 

Notethat the PLUGIN_VERSION column in the table INFORMATION_SCHEMA.PLUGINS does notdisplay the third component of the version number, only the first and secondcomponents, as in 1.0.

须注意,在表INFORMATION_SCHEMA.PLUGINSPLUGIN_VERSION这一列只表示版本号的第一和第二部分,如1.0,而不表示第三部分。

1.5. Operational Restrictions

1.5.InnoDB Plugin操作限制

Because the InnoDB Plugin introduces a new file format, withnew on-disk data structures within both the database and log files, there areimportant restrictions on the use of the plugin in typical user environments.Specifically, you should pay special attention to the information presentedhere about file format compatibility with respect to the following scenarios:

由于InnoDB Plugin引入了新的文件格式和磁盘数据结构,包括数据库以及日志文件,在传统的用户环境中造成了重要限制。具体来说,你要特别注意下列情况中有关文件格式兼容性的信息:

 

Downgradingfrom the InnoDB Plugin to the built-in InnoDB, or otherwise using differentversions of InnoDB with database files created by the InnoDB Plugin

降级InnoDB Pluginbuilt-in InnoDB时,或者对InnoDBPlugin创建的数据库文件使用不同版本的InnoDB

 

Usingmysqldump

使用mysqldump

 

UsingMySQL replication

使用MySQL的复制

 

UsingInnoDB Hot Backup

使用InnoDB热备份

 

WARNING: Once you use the InnoDB Plugin on a setof database files, care must be taken to avoid crashes and corruptions whenusing those files with an earlier version of InnoDB, as might happen by openingthe database with MySQL when the plugin is not installed. It is strongly recommended that you use a“slow shutdown” (SET GLOBAL innodb_fast_shutdown=0) when stopping the MySQLserver when the InnoDB Plugin is enabled. This will ensure log files and othersystem information written by the plugin will not cause problems when using aprior version of InnoDB. SeeSection11.3, “How to Downgrade”.

警告:一旦在一批数据库文件上使用InnoDB Plugin,尤其是与早期版本的InnoDB一起使用时,你要细致谨慎,因为在未安装Plugin的情况下,打开MySQL数据库很可能造成文件的崩溃和损坏。我们强烈建议您在启用InnoDB Plugin时使用“慢关闭”(SET GLOBALinnodb_fast_shutdown=0)来停止MySQL服务器。当使用前一版本的InnoDB时,这将确保Plugin写入的日志文件和其他系统信息不会出现错误。详情参考11.3章节,“如何降级”

 

Becauseof these considerations, and although it may be useful in certain circumstancesto use the plugin in a temporary way as just described, many users will find itpreferable to test their application with the plugin and use it on an on-goingbasis, without reverting back to the standard, built-in InnoDB.

考虑到以上因素,尽管在某些情况下,像刚才描述的那样用一种临时的方法来使用和操作Plugin是很有效的,很多用户更倾向于持续使用Plugin来测试应用程序,而不是恢复标准的内置InnoDB

 

WARNING: If you dump a database containingcompressed tables with mysqldump, the dump file may contain CREATE TABLEcommands that attempt to create compressed tables, or those usingROW_FORMAT=DYNAMIC in the new database. Therefore, you should be sure the newdatabase is running the InnoDB Plugin, with the proper settings forinnodb_file_format and innodb_file_per_table, if you want to have the tablesre-created as they exist in the original database. Typically, however, when themysqldump file is loaded, MySQL and InnoDB will ignore CREATE TABLE optionsthey do not recognize, and the table(s) will be created in a format used by therunning server.

警告:如果使用mysqldump导出含有压缩表的数据库,那么,导出文件可能包含CREATE TABLE命令并尝试创建压缩表,或者在新数据库使用ROW_FORMAT=DYNAMIC命令创建动态表。因此,如果想重建原始数据库中已存在的表格,首先应该确保新的数据库已运行InnoDB Plugin并正确设置innodb_file_formatinnodb_file_per_table然而,通常情况下,mysqldump文件加载完毕时,MySQLInnoDB会忽略那些不能被识别的CREATE TABLE选项,在正在运行的服务器上创建表格。

 

WARNING: If you use MySQL replication, you shouldbe careful to ensure all slaves are configured with the InnoDB Plugin, with thesame settings for innodb_file_format and innodb_file_per_table. If you do notdo so, and you create tables that require the new “Barracuda” file format,replication errors may occur. If a slave MySQL server is running the built-inInnoDB, it will ignore the CREATE TABLE options to create a compressed table orone with ROW_FORMAT=DYNAMIC, and create the table uncompressed, withROW_FORMAT=COMPACT.

 警告:如果启用MySQL复制,应当确保所有节点都已配置InnoDB Plugin,并设置相同的innodb_file_formatinnodb_file_per_table参数。如果不这样做而直接创建Barracuda文件格式的表,复制可能会出现错误。如果MySQL服务器运行内置InnoDBCREATE TABLE选项会被忽略,转而使用ROW_FORMAT=DYNAMIC命令创建一个压缩表,或使用ROW_FORMAT=COMPACT命令创建一个非压缩表。

 

WARNING: The current version of InnoDB Hot Backupdoes not support the new “Barracuda” file format. Using InnoDB Hot BackupVersion 3 to backup databases in this format will cause unpredictable behavior.A future version of InnoDB Hot Backup will support databases used with theInnoDB Plugin. As an alternative, you may back up such databases withmysqldump.

警告:InnoDB热备份当前版本并不支持新的Barracuda文件格式,在此文件格式上使用第三版InnoDB热备份会导致未知的结果。InnoDB热备份的未来版本将支持使用InnoDB Plugin的数据库。目前可以使用mysqldump备份数据库。

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章