Wednesday, August 10, 2016

innochecksum

innochecksum utility :: 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. As of MySQL 5.7.2, innochecksum supports files greater than 2GB in size. Previously, innochecksum only supported files up to 2GB in size.

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.

If DB and application is running:
Error: Unable to lock file:: test.ibd
fcntl: Resource temporarily unavailable

Good to shut down database and then perform.
[root@ip]# ./5.7.10/bin/innochecksum --page-type-summary --verbose --log=/tmp/log.txt practice/test.ibd

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
verbose                           TRUE
count                             FALSE
start-page                        0
end-page                          0
page                              0
strict-check                      crc32
no-check                          FALSE
allow-mismatches                  0
write                             crc32
page-type-summary                 TRUE
page-type-dump                    (No default value)
log                               /tmp/log.txt

File::practice/test.ibd
================PAGE TYPE SUMMARY==============
#PAGE_COUNT     PAGE_TYPE
===============================================
   11930        Index page
       0        Undo log page
       1        Inode page
       0        Insert buffer free list page
    1635        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

Log File:
[root@ip]# cat /tmp/log2.txt
InnoDB File Checksum Utility.
Filename = test.ibd
file test.ibd = 98304 bytes (6 pages)
page::0; log sequence number:first = 2524276; second = 2524276
page::0; old style: calculated = 1691960001; recorded = 1691960001
..
..
Page::13566 is empty and uncorrupted
page::13567; log sequence number:first = 0; second = 0
Page::13567 is empty and uncorrupted

References:
https://dev.mysql.com/doc/refman/5.7/en/innochecksum.html

No comments:

Post a Comment