ibd2sdi 是一个用于从 InnoDB 表空间文件中提取 序列化字典信息 (SDI) 的工具。所有持久性的 InnoDB 表空间文件中都存在 SDI 数据。ibd2sdi is a utility for extracting
serialized
dictionary information (SDI) from
InnoDB tablespace files. SDI data is present
in all persistent InnoDB tablespace files.
ibd2sdi 可以在 按表分文件 表空间文件(*.ibd 文件)、通用表空间 文件(*.ibd 文件)、系统表空间 文件(ibdata* 文件)以及数据字典表空间(mysql.ibd)。它不支持用于临时表空间或撤销表空间。ibd2sdi can be run on
file-per-table
tablespace files (*.ibd files),
general
tablespace files (*.ibd files),
system tablespace
files (ibdata* files), and the data
dictionary tablespace (mysql.ibd). It is
not supported for use with temporary tablespaces or undo
tablespaces.
ibd2sdi 可在运行时或服务器离线时使用。在 DDL 操作、ROLLBACK 操作以及与 SDI 相关的撤销日志清理操作期间,可能会有一个短时间间隔,导致 ibd2sdi 无法读取存储在表空间中的 SDI 数据。ibd2sdi can be used at runtime or while the
server is offline. During DDL
operations,
ROLLBACK
operations, and undo log purge operations related to SDI, there
may be a short interval of time when ibd2sdi
fails to read SDI data stored in the tablespace.
ibd2sdi 对指定表空间的 SDI 执行未提交读取。重做日志和回滚日志不会被访问。ibd2sdi performs an uncommitted read of SDI from the specified tablespace. Redo logs and undo logs are not accessed.
像这样调用 ibd2sdi 工具:Invoke the ibd2sdi utility like this:
ibd2sdi [options]file_name1[file_name2 file_name3 ...]
ibd2sdi 支持多文件表空间,如 InnoDB 系统表空间,但一次不能在多个表空间上运行。对于多文件表空间,请指定每个文件:ibd2sdi supports multi-file tablespaces like
the InnoDB system tablespace, but it cannot
be run on more than one tablespace at a time. For multi-file
tablespaces, specify each file:
ibd2sdi ibdata1 ibdata2
多文件表空间的文件必须按页面编号升序指定。如果两个连续的文件具有相同的空间 ID,则后一个文件必须从前一个文件的最后一页编号+1 开始。The files of a multi-file tablespace must be specified in order of the ascending page number. If two successive files have the same space ID, the later file must start with the last page number of the previous file + 1.
ibd2sdi 以 JSON 格式输出 SDI(包含 id、类型和数据字段)。ibd2sdi outputs SDI (containing id, type, and
data fields) in JSON format.
ibd2sdi 选项ibd2sdi Options
ibd2sdi 支持以下选项:ibd2sdi supports the following options:
--help,-h命令行格式Command-Line Format --help--help类型Type 布尔Boolean 默认值Default Value falsefalse显示帮助信息并退出。例如:Display a help message and exit. For example:
Usage: ./ibd2sdi [-v] [-c <strict-check>] [-d <dump file name>] [-n] filename1 [filenames] See http://dev.mysql.com/doc/refman/8.4/en/ibd2sdi.html for usage hints. -h, --help Display this help and exit. -v, --version Display version information and exit. -#, --debug[=name] Output debug log. See http://dev.mysql.com/doc/refman/8.4/en/dbug-package.html -d, --dump-file=name Dump the tablespace SDI into the file passed by user. Without the filename, it will default to stdout -s, --skip-data Skip retrieving data from SDI records. Retrieve only id and type. -i, --id=# Retrieve the SDI record matching the id passed by user. -t, --type=# Retrieve the SDI records matching the type passed by user. -c, --strict-check=name Specify the strict checksum algorithm by the user. Allowed values are innodb, crc32, none. -n, --no-check Ignore the checksum verification. -p, --pretty Pretty format the SDI output.If false, SDI would be not human readable but it will be of less size (Defaults to on; use --skip-pretty to disable.) Variables (--variable-name=value) and boolean options {FALSE|TRUE} Value (after reading options) --------------------------------- ---------------------------------------- debug (No default value) dump-file (No default value) skip-data FALSE id 0 type 0 strict-check crc32 no-check FALSE pretty TRUE--version,-v命令行格式Command-Line Format --version类型Type 布尔Boolean 默认值Default Value falsefalse显示版本信息并退出。例如:Display version information and exit. For example:
ibd2sdi Ver 8.4.9 for Linux on x86_64 (Source distribution)
--debug[=debug_options],-# [debug_options]--debug[=,debug_options]-# [debug_options]命令行格式Command-Line Format --debug=options类型Type 字符串String 默认值Default Value [none][none]打印调试日志。有关调试选项,请参阅 第 7.9.4 节,“DBUG 包”。Prints a debug log. For debug options, refer to Section 7.9.4, “The DBUG Package”.
ibd2sdi --debug=d:t /tmp/ibd2sdi.trace
此选项仅在 MySQL 使用
WITH_DEBUG构建时可用。Oracle 提供的 MySQL 发行版二进制文件 未 使用此选项构建。This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle are not built using this option.--dump-file=,-d命令行格式Command-Line Format --dump-file=file--dump-file=file类型Type 文件名File name 默认值Default Value [none][none]将序列化的字典信息(SDI)转储到指定的转储文件中。如果未指定转储文件,则将表空间 SDI 转储到
stdout。Dumps serialized dictionary information (SDI) into the specified dump file. If a dump file is not specified, the tablespace SDI is dumped tostdout.ibd2sdi --dump-file=
file_name../data/test/t1.ibd--skip-data,-s命令行格式Command-Line Format --skip-data类型Type 布尔Boolean 默认值Default Value falsefalse跳过从序列化字典信息 (SDI) 中检索
data字段值,仅检索id和type字段值,这些字段是 SDI 记录的主键。Skips retrieval ofdatafield values from the serialized dictionary information (SDI) and only retrieves theidandtypefield values, which are primary keys for SDI records.$>
ibd2sdi --skip-data ../data/test/t1.ibd["ibd2sdi" , { "type": 1, "id": 330 } , { "type": 2, "id": 7 } ]--id=,#-i#命令行格式Command-Line Format --id=#类型Type 整数Integer 默认值Default Value 0检索与指定的表或表空间对象 ID 匹配的序列化字典信息 (SDI)。对象 ID 对于对象类型是唯一的。表和表空间对象 ID 也可以在
mysql.tables和mysql.tablespace数据字典表的id列中找到。有关数据字典表的信息,请参见 第 16.1 节,“数据字典模式”。Retrieves serialized dictionary information (SDI) matching the specified table or tablespace object id. An object id is unique to the object type. Table and tablespace object IDs are also found in theidcolumn of themysql.tablesandmysql.tablespacedata dictionary tables. For information about data dictionary tables, see Section 16.1, “Data Dictionary Schema”.$>
ibd2sdi --id=7 ../data/test/t1.ibd["ibd2sdi" , { "type": 2, "id": 7, "object": { "mysqld_version_id": 80003, "dd_version": 80003, "sdi_version": 1, "dd_object_type": "Tablespace", "dd_object": { "name": "test/t1", "comment": "", "options": "", "se_private_data": "flags=16417;id=2;server_version=80003;space_version=1;", "engine": "InnoDB", "files": [ { "ordinal_position": 1, "filename": "./test/t1.ibd", "se_private_data": "id=2;" } ] } } } ]--type=,#-t#命令行格式Command-Line Format --type=#类型Type 枚举Enumeration 默认值Default Value 0有效值Valid Values 12检索与指定对象类型匹配的序列化字典信息(SDI)。表(type=1)和表空间(type=2)对象提供 SDI。Retrieves serialized dictionary information (SDI) matching the specified object type. SDI is provided for table (type=1) and tablespace (type=2) objects.
此示例显示了
test数据库中表空间ts1的输出:This example shows output for a tablespacets1in thetestdatabase:$>
ibd2sdi --type=2 ../data/test/ts1.ibd["ibd2sdi" , { "type": 2, "id": 7, "object": { "mysqld_version_id": 80003, "dd_version": 80003, "sdi_version": 1, "dd_object_type": "Tablespace", "dd_object": { "name": "test/ts1", "comment": "", "options": "", "se_private_data": "flags=16417;id=2;server_version=80003;space_version=1;", "engine": "InnoDB", "files": [ { "ordinal_position": 1, "filename": "./test/ts1.ibd", "se_private_data": "id=2;" } ] } } } ]由于
InnoDB处理默认值元数据的方式,即使未使用DEFAULT定义某列,给定表列在 ibd2sdi 输出中也可能存在非空默认值。考虑在名为i的数据库中使用以下语句创建的两个表:Due to the way in whichInnoDBhandles default value metadata, a default value may be present and non-empty in ibd2sdi output for a given table column even if it is not defined usingDEFAULT. Consider the two tables created using the following statements, in the database namedi:CREATE TABLE t1 (c VARCHAR(16) NOT NULL); CREATE TABLE t2 (c VARCHAR(16) NOT NULL DEFAULT "Sakila");
使用 ibd2sdi,我们可以看到列
c的default_value非空,并且在两个表中实际上都被填充到了长度,如下所示:Using ibd2sdi, we can see that thedefault_valuefor columncis nonempty and is in fact padded to length in both tables, like this:$>
ibd2sdi ../data/i/t1.ibd | grep -m1 '\"default_value\"' | cut -b34- | sed -e s/,//"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAA=" $>ibd2sdi ../data/i/t2.ibd | grep -m1 '\"default_value\"' | cut -b34- | sed -e s/,//"BlNha2lsYQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAA="使用像 jq 这样的 JSON 感知工具查看 ibd2sdi 输出可能更容易,如下所示:Examination of ibd2sdi output may be easier using a JSON-aware utility like jq, as shown here:
$>
ibd2sdi ../data/i/t1.ibd | jq '.[1]["object"]["dd_object"]["columns"][0]["default_value"]'"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAA=" $>ibd2sdi ../data/i/t2.ibd | jq '.[1]["object"]["dd_object"]["columns"][0]["default_value"]'"BlNha2lsYQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAA="欲了解更多信息,请参阅 MySQL 内部文档。For more information, see the MySQL Internals documentation.
--strict-check,-c命令行格式Command-Line Format --strict-check=algorithm类型Type 枚举Enumeration 默认值Default Value crc32有效值Valid Values crc32innodbnonenone指定用于验证读取页校验和的严格校验算法。选项包括
innodb、crc32和none。Specifies a strict checksum algorithm for validating the checksum of pages that are read. Options includeinnodb,crc32, andnone.在此示例中,指定了
innodb校验和算法的严格版本:In this example, the strict version of theinnodbchecksum algorithm is specified:ibd2sdi --strict-check=innodb ../data/test/t1.ibd
在此示例中,指定了
crc32校验和算法的严格版本:In this example, the strict version ofcrc32checksum algorithm is specified:ibd2sdi -c crc32 ../data/test/t1.ibd
如果您未指定
--strict-check选项,则验证将针对非严格的innodb、crc32和none校验和进行。If you do not specify the--strict-checkoption, validation is performed against non-strictinnodb,crc32andnonechecksums.--no-check,-n命令行格式Command-Line Format --no-check类型Type 布尔Boolean 默认值Default Value falsefalse跳过已读取页面的校验和验证。Skips checksum validation for pages that are read.
ibd2sdi --no-check ../data/test/t1.ibd
--pretty,-p命令行格式Command-Line Format --pretty类型Type 布尔Boolean 默认值Default Value falsefalse以 JSON 美化格式输出 SDI 数据。默认启用。如果禁用,SDI 就不可人类可读,但体积更小。使用
--skip-pretty来禁用。Outputs SDI data in JSON pretty print format. Enabled by default. If disabled, SDI is not human readable but is smaller in size. Use--skip-prettyto disable.ibd2sdi --skip-pretty ../data/test/t1.ibd