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備份數據庫。

 


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