innochecksum prints checksums for innochecksum打印InnoDB files. InnoDB文件的校验和。This tool reads an 此工具读取InnoDB tablespace file, calculates the checksum for each page, compares the calculated checksum to the stored checksum, and reports mismatches, which indicate damaged pages. InnoDB表空间文件,计算每个页面的校验和,将计算的校验和与存储的校验和进行比较,并报告不匹配,这表明页面已损坏。It was originally developed to speed up verifying the integrity of tablespace files after power outages but can also be used after file copies. 它最初是为了在停电后加快验证表空间文件的完整性而开发的,但也可以在文件复制后使用。Because checksum mismatches cause 因为校验和不匹配会导致InnoDB to deliberately shut down a running server, it may be preferable to use this tool rather than waiting for an in-production server to encounter the damaged pages.InnoDB故意关闭正在运行的服务器,所以最好使用此工具,而不是等待生产中的服务器遇到损坏的页面。
innochecksum cannot be used on tablespace files that the server already has open. innochecksum不能用于服务器已打开的表空间文件。For such files, you should use 对于此类文件,您应该使用CHECK TABLE to check tables within the tablespace. CHECK TABLE检查表空间中的表。Attempting to run innochecksum on a tablespace that the server already has open results in an Unable to lock file error.尝试在服务器已打开的表空间上运行innochecksum会导致无法锁定文件错误。
If checksum mismatches are found, restore the tablespace from backup or start the server and attempt to use mysqldump to make a backup of the tables within the tablespace.如果发现校验和不匹配,请从备份中还原表空间或启动服务器,并尝试使用mysqldump对表空间中的表进行备份。
Invoke innochecksum like this:像这样调用innocecksum:
innochecksum [options]file_name
innochecksum supports the following options. For options that refer to page numbers, the numbers are zero-based.innochecksum支持以下选项。对于涉及页码的选项,这些数字是从零开始的。
--help, -?
Displays command line help. Example usage:显示命令行帮助。示例用法:
innochecksum --help
--info, -I
Synonym for --help. Displays command line help. Example usage:--help的同义词。显示命令行帮助。示例用法:
innochecksum --info
--version, -V
Displays version information. Example usage:显示版本信息。示例用法:
innochecksum --version
--verbose, -v
Verbose mode; prints a progress indicator to the log file every five seconds. 详细模式;每五秒在日志文件中打印一个进度指示器。In order for the progress indicator to be printed, the log file must be specified using the 为了打印进度指示器,必须使用--log option. To turn on verbose mode, run:--log选项指定日志文件。要打开详细模式,请运行:
innochecksum --verbose
To turn off verbose mode, run:要关闭详细模式,请运行:
innochecksum --verbose=FALSE
The 可以同时指定--verbose option and --log option can be specified at the same time. For example:--verbose选项和--log选项。例如:
innochecksum --verbose --log=/var/lib/mysql/test/logtest.txt
To locate the progress indicator information in the log file, you can perform the following search:要在日志文件中查找进度指示器信息,可以执行以下搜索:
cat ./logtest.txt | grep -i "okay"
The progress indicator information in the log file appears similar to the following:日志文件中的进度指示器信息显示如下:
page 1663 okay: 2.863% done page 8447 okay: 14.537% done page 13695 okay: 23.568% done page 18815 okay: 32.379% done page 23039 okay: 39.648% done page 28351 okay: 48.789% done page 33023 okay: 56.828% done page 37951 okay: 65.308% done page 44095 okay: 75.881% done page 49407 okay: 85.022% done page 54463 okay: 93.722% done ...
--count, -c
Print a count of the number of pages in the file and exit. Example usage:打印文件中的页数计数并退出。示例用法:
innochecksum --count ../data/test/tab1.ibd
--start-page=, num-s num
Start at this page number. Example usage:从这个页码开始。示例用法:
innochecksum --start-page=600 ../data/test/tab1.ibd
or:或者:
innochecksum -s 600 ../data/test/tab1.ibd
--end-page=, num-e num
End at this page number. Example usage:到此页码结束。示例用法:
innochecksum --end-page=700 ../data/test/tab1.ibd
or:或者:
innochecksum --p 700 ../data/test/tab1.ibd
--page=, num-p num
Check only this page number. Example usage:只检查此页码。示例用法:
innochecksum --page=701 ../data/test/tab1.ibd
--strict-check, -C
Specify a strict checksum algorithm. Options include 指定严格的校验和算法。选项包括innodb, crc32, and none.InnoDB、crc32和none。
In this example, the 在此示例中,指定了innodb checksum algorithm is specified:InnoDB校验和算法:
innochecksum --strict-check=innodb ../data/test/tab1.ibd
In this example, the 在此示例中,指定了crc32 checksum algorithm is specified:crc32校验和算法:
innochecksum -C crc32 ../data/test/tab1.ibd
The following conditions apply:以下条件适用:
If you do not specify the 如果不指定--strict-check option, innochecksum validates against innodb, crc32 and none.--strict-check选项,innochecksum将对InnoDB、crc32和none进行验证。
If you specify the 如果指定none option, only checksums generated by none are allowed.none选项,则只允许使用none生成的校验和。
If you specify the 如果指定innodb option, only checksums generated by innodb are allowed.InnoDB选项,则只允许使用InnoDB生成的校验和。
If you specify the 如果指定crc32 option, only checksums generated by crc32 are allowed.crc32选项,则只允许使用crc32生成的校验和。
--no-check, -n
Ignore the checksum verification when rewriting a checksum. 重写校验和时忽略校验和验证。This option may only be used with the innochecksum 此选项只能与innochecksum --write option. --write选项一起使用。If the 如果未指定--write option is not specified, innochecksum terminates.--write选项,则innochecksum终止。
In this example, an 在这个例子中,innodb checksum is rewritten to replace an invalid checksum:InnoDB校验和被重写以替换无效的校验和:
innochecksum --no-check --write innodb ../data/test/tab1.ibd
The maximum number of checksum mismatches allowed before innochecksum terminates. 在innocehecksum终止之前允许的最大校验和不匹配数。The default setting is 0. If 默认设置为0。如果--allow-mismatches=N, where , N>=0N mismatches are permitted and innochecksum terminates at . N+1--allow mismatchs=N,其中N>=0,则允许N个不匹配,innocecksum在N+1处终止。When 当--allow-mismatches is set to 0, innochecksum terminates on the first checksum mismatch.--allow-mismatchs设置为0时,innochecksum在第一个校验和不匹配时终止。
In this example, an existing 在这个例子中,现有的innodb checksum is rewritten to set --allow-mismatches to 1.InnoDB校验和被重写为设置--allow-mismatches为1。
innochecksum --allow-mismatches=1 --write innodb ../data/test/tab1.ibd
With 将--allow-mismatches set to 1, if there is a mismatch at page 600 and another at page 700 on a file with 1000 pages, the checksum is updated for pages 0-599 and 601-699. --allow-mismatchs设置为1后,如果在1000页的文件中,第600页和第700页存在不匹配,则会更新第0-599页和第601-699页的校验和。Because 因为--allow-mismatches is set to 1, the checksum tolerates the first mismatch and terminates on the second mismatch, leaving page 600 and pages 700-999 unchanged.--allow-mismatches设置为1,校验和容忍第一个失配,并在第二个失配时终止,使第600页和第700-999页保持不变。
--write=, name-w num
Rewrite a checksum. When rewriting an invalid checksum, the 重写校验和。重写无效的校验和时,--no-check option must be used together with the --write option. --no-check选项必须与--write选项一起使用。The --no-check option tells innochecksum to ignore verification of the invalid checksum. --no-check选项告诉innochchecksum忽略无效校验和的验证。You do not have to specify the 如果当前校验和有效,则不必指定--no-check option if the current checksum is valid.--no-check选项。
An algorithm must be specified when using the 使用--write option. Possible values for the --write option are:--write选项时必须指定算法。--write选项的可能值有:
innodb: A checksum calculated in software, using the original algorithm from :使用InnoDB.InnoDB的原始算法在软件中计算的校验和。
crc32: A checksum calculated using the :使用crc32 algorithm, possibly done with a hardware assist.crc32算法计算的校验和,可能在硬件辅助下完成。
none: A constant number.:一个常数。
The --write option rewrites entire pages to disk. --write选项将整个页面重写到磁盘。If the new checksum is identical to the existing checksum, the new checksum is not written to disk in order to minimize I/O.如果新校验和与现有校验和相同,则不会将新校验和写入磁盘,以尽量减少I/O。
innochecksum obtains an exclusive lock when the 当使用--write option is used.--write选项时,innochecksum会获得独占锁。
In this example, a 在这个例子中,为crc32 checksum is written for tab1.ibd:tab1.ibd编写了crc32校验和:
innochecksum -w crc32 ../data/test/tab1.ibd
In this example, a 在此示例中,重写crc32 checksum is rewritten to replace an invalid crc32 checksum:crc32校验和以替换无效的crc32检验和:
innochecksum --no-check --write crc32 ../data/test/tab1.ibd
Display a count of each page type in a tablespace. Example usage:显示表空间中每种页面类型的计数。示例用法:
innochecksum --page-type-summary ../data/test/tab1.ibd
Sample output for --page-type-summary:--page-type-summary的示例输出:
File::../data/test/tab1.ibd
================PAGE TYPE SUMMARY==============
#PAGE_COUNT PAGE_TYPE
===============================================
2 Index page
0 Undo log page
1 Inode page
0 Insert buffer free list page
2 Freshly allocated page
1 Insert buffer bitmap
0 System page
0 Transaction system page
1 File Space Header
0 Extent descriptor page
0 BLOB page
0 Compressed BLOB page
0 Other type of page
===============================================
Additional information:
Undo page type: 0 insert, 0 update, 0 other
Undo page state: 0 active, 0 cached, 0 to_free, 0 to_purge, 0 prepared, 0 other --page-type-dump, -D
Dump the page type information for each page in a tablespace to 将表空间中每个页面的页面类型信息转储到stderr or stdout. Example usage:stderr或stdout。示例用法:
innochecksum --page-type-dump=/tmp/a.txt ../data/test/tab1.ibd
--log, -l
Log output for the innochecksum tool. A log file name must be provided. innocecksum工具的日志输出。必须提供日志文件名。Log output contains checksum values for each tablespace page. For uncompressed tables, LSN values are also provided. 日志输出包含每个表空间页面的校验和值。对于未压缩的表,还提供了LSN值。The --log replaces the --debug option, which was available in earlier releases. Example usage:--log替换了早期版本中可用的--debug选项。示例用法:
innochecksum --log=/tmp/log.txt ../data/test/tab1.ibd
or:或者:
innochecksum -l /tmp/log.txt ../data/test/tab1.ibd
Specify the 指定从标准输入读取的- option to read from standard input. -选项。If the 如果在预期“从标准中读取”时缺少-选项,innochecksum将打印innochecksum使用信息,指示省略了“-”选项。示例用法:- option is missing when “read from standard in” is expected, innochecksum prints innochecksum usage information indicating that the “-” option was omitted. Example usages:
cat t1.ibd | innochecksum -
In this example, innochecksum writes the 在这个例子中,innocecksum将crc32 checksum algorithm to a.ibd without changing the original t1.ibd file.crc32校验和算法写入a.ibd,而不更改原始的t1.ibd文件。
cat t1.ibd | innochecksum --write=crc32 - > a.ibd
The following examples demonstrate how to run innochecksum on multiple user-defined tablespace files (以下示例演示了如何在多个用户定义的表空间文件(.ibd files)..ibd文件)上运行innochecksum。
Run innochecksum for all tablespace (对“test”数据库中的所有表空间(ibd)文件运行innochecksum:.ibd) files in the “test” database:
innochecksum ./data/test/*.ibd
Run innochecksum for all tablespace files (对所有文件名以“t”开头的表空间文件(.ibd files) that have a file name starting with “t”:.ibd文件)运行innochecksum:
innochecksum ./data/test/t*.ibd
Run innochecksum for all tablespace files (对数据目录中的所有表空间文件(.ibd files) in the data directory:.ibd文件)运行innochecksum:
innochecksum ./data/*/*.ibd
Running innochecksum on multiple user-defined tablespace files is not supported on Windows operating systems, as Windows shells such as cmd.exe do not support glob pattern expansion. Windows操作系统不支持在多个用户定义的表空间文件上运行innochecksum,因为cmd.exe等Windows shell不支持glob模式扩展。On Windows systems, innochecksum must be run separately for each user-defined tablespace file. For example:在Windows系统上,必须为每个用户定义的表空间文件单独运行innochecksum。例如:
innochecksum.exe t1.ibd innochecksum.exe t2.ibd innochecksum.exe t3.ibd
By default, there is only one 默认情况下,只有一个InnoDB system tablespace file (ibdata1) but multiple files for the system tablespace can be defined using the innodb_data_file_path option. InnoDB系统表空间文件(ibdata1),但可以使用innodb_data_file_path选项定义系统表空间的多个文件。In the following example, three files for the system tablespace are defined using the 在以下示例中,使用innodb_data_file_path option: ibdata1, ibdata2, and ibdata3.innodb_data_file_path选项定义了系统表空间的三个文件:ibdata1、ibdata2和ibdata3。
./bin/mysqld --no-defaults --innodb-data-file-path="ibdata1:10M;ibdata2:10M;ibdata3:10M:autoextend"
The three files (这三个文件(ibdata1, ibdata2, and ibdata3) form one logical system tablespace. ibdata1、ibdata2和ibdata3)形成一个逻辑系统表空间。To run innochecksum on multiple files that form one logical system tablespace, innochecksum requires the 要对形成一个逻辑系统表空间的多个文件运行innochecksum,innochecksum需要- option to read tablespace files in from standard input, which is equivalent to concatenating multiple files to create one single file. -选项从标准输入中读取表空间文件,这相当于连接多个文件以创建一个文件。For the example provided above, the following innochecksum command would be used:对于上面提供的示例,将使用以下innochecksum命令:
cat ibdata* | innochecksum -
Refer to the innochecksum options information for more information about the “-” option.有关“-”选项的更多信息,请参阅innochecksum选项信息。
Running innochecksum on multiple files in the same tablespace is not supported on Windows operating systems, as Windows shells such as cmd.exe do not support glob pattern expansion. Windows操作系统不支持在同一表空间中的多个文件上运行innochecksum,因为cmd.exe等Windows shell不支持glob模式扩展。On Windows systems, innochecksum must be run separately for each system tablespace file. For example:在Windows系统上,必须为每个系统表空间文件单独运行innochecksum。例如:
innochecksum.exe ibdata1 innochecksum.exe ibdata2 innochecksum.exe ibdata3