innochecksum is a tool for printing checksums for InnoDB files.
innochecksum [options] file_name
It 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. 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 will cause InnoDB to deliberately shut down a running server, it can be preferable to use innochecksum rather than waiting for a server in production usage to encounter the damaged pages.
Multiple filenames can be specified by a wildcard on non-Windows systems only.
innochecksum has worked with compressed pages since MariaDB 10.0.16.
MariaDB 10.1.4 added options to analyze leaf pages to estimate how fragmented an index is and how much benefit can be gained from defragmentation.
innochecksum cannot be used on tablespace files that the server already has open. For such files, you should use CHECK TABLE to check tables within the tablespace. If checksum mismatches are found, you would normally restore the tablespace from backup or start the server and attempt to use mysqldump to make a backup of the tables within the tablespace.
innochecksum supports the following options. For options that refer to page numbers, the numbers are zero-based.
Option | Description | Added |
---|---|---|
-a, --allow-mismatches=# | Maximum checksum mismatch allowed before innochecksum terminates. Defaults to 0, which terminates on the first mismatch. | MariaDB 10.2.2, MariaDB 10.1.26 |
-c, --count | Print a count of the number of pages in the file. | |
-d, --debug | Debug mode; prints checksums for each page, implies --verbose . Replaced by --log in MariaDB 10.1.26
|
|
-e num, --end-page=# | End at this page number (0-based). | |
-?, --help | Displays help and exits. | |
-I, --info | Synonym for --help. | |
-f, --leaf | Examine leaf index pages. Until MariaDB 10.2.4, the short code was -l , but this was changed to avoid confusion with the --log option. |
MariaDB 10.1.4 |
-l fn, --log=fn | Log output to the specified filename fn . |
MariaDB 10.2.2, MariaDB 10.1.26 |
-m num, --merge=# | Leaf page count if merge given number of consecutive pages. | MariaDB 10.1.4 |
-n, --no-check | Ignore the checksum verification. Must be used with the --write option. |
MariaDB 10.2.2, MariaDB 10.1.26 |
-p num, --page=# | Check only this page number (0-based). | |
-D, --page-type-dump=name | Dump the page type info for each page in a tablespace. | MariaDB 10.2.2, MariaDB 10.1.26 |
-S, --page-type-summary | Display a count of each page type in a tablespace | MariaDB 10.2.2, MariaDB 10.1.26 |
-i, --per-page-details | Print out per-page detail information. | |
-u, --skip-corrupt | Skip corrupt pages. | MariaDB 10.0.16 |
-s num, --start-page=# | Start at this page number (0-based). | |
-C, --strict-check=name | Specify the strict checksum algorithm. One of: crc32, innodb, none. If not specified, validates against innodb, crc32 and none. See also innodb_checksum_algorithm. | MariaDB 10.2.2, MariaDB 10.1.26 |
-v, --verbose | Verbose mode; print a progress indicator every five seconds. | |
-V, --version | Displays version information and exits. | |
-w, --write=name | Rewrite the checksum algorithm. One of crc32, innodb, none. An exclusive lock is obtained during use. Use in conjunction with the -no-check option to rewrite and invalid checksum. |
MariaDB 10.2.2, MariaDB 10.1.26 |
Rewriting a crc32 checksum to replace an invalid checksum:
innochecksum --no-check --write crc32 tablename.ibd
A count of each page type:
innochecksum --page-type-summary data/mysql/gtid_slave_pos.ibd File::data/mysql/gtid_slave_pos.ibd ================PAGE TYPE SUMMARY============== #PAGE_COUNT PAGE_TYPE =============================================== 1 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 Page compressed page 0 Page compressed encrypted 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 index_id #pages #leaf_pages #recs_per_page #bytes_per_page 24 1 1 0 0 index_id page_data_bytes_histgram(empty,...,oversized) 24 1 0 0 0 0 0 0 0 0 0 0 0
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/innochecksum/