Spec-Zone .ru
спецификации, руководства, описания, API
|
innochecksum prints checksums for InnoDB
files. 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. 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 this tool rather than waiting for a server in production usage to encounter the damaged pages.
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. Attempting to run innochecksum on a tablespace that the server already has
open will result in an "Unable to lock file"
error.
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.
Invoke innochecksum like this:
shell> innochecksum [options
]
file_name
innochecksum supports the following options. For options that refer to page numbers, the numbers are zero-based.
--help
, -?
Displays command line help. Example usage:
shell> innochecksum --help
--info
, -I
Synonym for --help
.
Displays command line help. Example usage:
shell> innochecksum --info
--version
, -V
Displays version information. Example usage:
shell> innochecksum --version
--verbose
, -v
Verbose mode; print a progress indicator every five seconds. Example usage:
shell> innochecksum --verbose ../data/test/tab1.ibd
Sample output:
Variables (--variable-name=value)and boolean options {FALSE|TRUE} Value (after reading options)--------------------------------- -----------------------------verbose TRUEdebug FALSEcount FALSEstart-page 0end-page 0page 0strict-check crc32no-check FALSEallow-mismatches 0write crc32page-type-summary FALSEpage-type-dump (No default value)log (No default value)
--count
, -c
Print a count of the number of pages in the file and exit. Example usage:
shell> innochecksum --count ../data/test/tab1.ibd
--start-page=
, num
-s
num
Start at this page number. Example usage:
shell> innochecksum --start-page=600 ../data/test/tab1.ibd
or:
shell> innochecksum -s 600 ../data/test/tab1.ibd
--end-page=
, num
-e
num
End at this page number. Example usage:
shell> innochecksum --end-page=700 ../data/test/tab1.ibd
or:
shell> innochecksum --p 700 ../data/test/tab1.ibd
--page=
, num
-p
num
Check only this page number. Example usage:
shell> innochecksum --page=701 ../data/test/tab1.ibd
--strict-check
, -C
Specify a strict checksum algorithm. Options include innodb
, crc32
, and none
.
In this example, the innodb
checksum algorithm is specified:
shell> innochecksum --strict-check=innodb ../data/test/tab1.ibd
In this example, the crc32
checksum algorithm is specified:
shell> 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
.
If you specify the none
option, only
checksums generated by none
are allowed.
If you specify the innodb
option, only
checksums generated by innodb
are allowed.
If you specify the crc32
option, only
checksums generated by crc32
are allowed.
--no-check
, -n
Ignore the checksum verification when rewriting a checksum. This option may only be used with the innochecksum --write
option. If the --write
option is not specified, innochecksum will terminate.
In this example, an innodb
checksum is rewritten to replace an invalid
checksum:
shell> innochecksum --no-check --write innodb ../data/test/tab1.ibd
The maximum number of checksum mismatches allowed before innochecksum terminates. The default setting is 0.
If --allow-mismatches=
N
,
where
, N
>=0N
mismatches are permitted and innochecksum terminates at
. When N
+1--allow-mismatches
is set to 0, innochecksum terminates on the first checksum
mismatch.
In this example, an existing innodb
checksum is rewritten to set --allow-mismatches
to 1.
shell> 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. 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.
--write=
, name
-w
num
Rewrite a checksum. When rewriting an invalid checksum, the --no-check
option must be used together with the --write
option. The --no-check
option tells innochecksum to ignore verification of the
invalid checksum. You do not have to specify the --no-check
option if the current checksum is valid.
An algorithm must be specified when using the --write
option. Possible values for the --write
option are:
innodb
: A checksum calculated in software,
using the original algorithm from InnoDB
.
crc32
: A checksum calculated using the
crc32
algorithm, possibly done with a hardware assist.
none
: A constant number.
The --write
option rewrites entire pages to disk. If the new checksum is
identical to the existing checksum, the new checksum is not written to disk in order to minimize
I/O.
innochecksum
obtains an exclusive lock when the --write
option is used.
In this example, a crc32
checksum is written for tab1.ibd
:
shell> innochecksum -w crc32 ../data/test/tab1.ibd
In this example, a crc32
checksum is rewritten to replace an invalid
crc32
checksum:
shell> innochecksum --no-check --write crc32 ../data/test/tab1.ibd
Display a count of each page type in a tablespace. Example usage:
shell> innochecksum --page-type-summary ../data/test/tab1.ibd
Sample output for --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 otherUndo 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:
shell> 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.
Log output contains checksum values for each tablespace page. For uncompressed tables, LSN values
are also provided. The --log
replaces the --debug
option,
which was available in earlier releases. Example usage:
shell> innochecksum --log=/tmp/log.txt ../data/test/tab1.ibd
or:
shell> innochecksum -l /tmp/log.txt ../data/test/tab1.ibd
Specify the "-
"
option to read from standard input. If the "-
" option is missing when "read from standard in" is expected, innochecksum reports an error.
shell> cat t1.ibd | ./bin/innochecksum -