1INNOCHECKSUM(1) MySQL Database System INNOCHECKSUM(1)
2
3
4
6 innochecksum - offline InnoDB file checksum utility
7
9 innochecksum [options] file_name
10
12 innochecksum prints checksums for InnoDB files. This tool reads an
13 InnoDB tablespace file, calculates the checksum for each page, compares
14 the calculated checksum to the stored checksum, and reports mismatches,
15 which indicate damaged pages. It was originally developed to speed up
16 verifying the integrity of tablespace files after power outages but can
17 also be used after file copies. Because checksum mismatches cause
18 InnoDB to deliberately shut down a running server, it may be preferable
19 to use this tool rather than waiting for an in-production server to
20 encounter the damaged pages.
21
22 innochecksum cannot be used on tablespace files that the server already
23 has open. For such files, you should use CHECK TABLE to check tables
24 within the tablespace. Attempting to run innochecksum on a tablespace
25 that the server already has open results in an Unable to lock file
26 error.
27
28 If checksum mismatches are found, restore the tablespace from backup or
29 start the server and attempt to use mysqldump to make a backup of the
30 tables within the tablespace.
31
32 Invoke innochecksum like this:
33
34 innochecksum [options] file_name
35
36 innochecksum Options
37
38 innochecksum supports the following options. For options that refer to
39 page numbers, the numbers are zero-based.
40
41 • --help, -? Displays command line help. Example usage:
42
43 innochecksum --help
44
45 • --info, -I Synonym for --help. Displays command line help. Example
46 usage:
47
48 innochecksum --info
49
50 • --version, -V Displays version information. Example usage:
51
52 innochecksum --version
53
54 • --verbose, -v Verbose mode; prints a progress indicator to the log
55 file every five seconds. In order for the progress indicator to be
56 printed, the log file must be specified using the --log option. To
57 turn on verbose mode, run:
58
59 innochecksum --verbose
60
61 To turn off verbose mode, run:
62
63 innochecksum --verbose=FALSE
64
65 The --verbose option and --log option can be specified at the same
66 time. For example:
67
68 innochecksum --verbose --log=/var/lib/mysql/test/logtest.txt
69
70 To locate the progress indicator information in the log file, you
71 can perform the following search:
72
73 cat ./logtest.txt | grep -i "okay"
74
75 The progress indicator information in the log file appears similar
76 to the following:
77
78 page 1663 okay: 2.863% done
79 page 8447 okay: 14.537% done
80 page 13695 okay: 23.568% done
81 page 18815 okay: 32.379% done
82 page 23039 okay: 39.648% done
83 page 28351 okay: 48.789% done
84 page 33023 okay: 56.828% done
85 page 37951 okay: 65.308% done
86 page 44095 okay: 75.881% done
87 page 49407 okay: 85.022% done
88 page 54463 okay: 93.722% done
89 ...
90
91 • --count, -c Print a count of the number of pages in the file and
92 exit. Example usage:
93
94 innochecksum --count ../data/test/tab1.ibd
95
96 • --start-page=num, -s num Start at this page number. Example usage:
97
98 innochecksum --start-page=600 ../data/test/tab1.ibd
99
100 or:
101
102 innochecksum -s 600 ../data/test/tab1.ibd
103
104 • --end-page=num, -e num End at this page number. Example usage:
105
106 innochecksum --end-page=700 ../data/test/tab1.ibd
107
108 or:
109
110 innochecksum --p 700 ../data/test/tab1.ibd
111
112 • --page=num, -p num Check only this page number. Example usage:
113
114 innochecksum --page=701 ../data/test/tab1.ibd
115
116 • --strict-check, -C Specify a strict checksum algorithm. Options
117 include innodb, crc32, and none.
118
119 In this example, the innodb checksum algorithm is specified:
120
121 innochecksum --strict-check=innodb ../data/test/tab1.ibd
122
123 In this example, the crc32 checksum algorithm is specified:
124
125 innochecksum -C crc32 ../data/test/tab1.ibd
126
127 The following conditions apply:
128
129 • If you do not specify the --strict-check option, innochecksum
130 validates against innodb, crc32 and none.
131
132 • If you specify the none option, only checksums generated by
133 none are allowed.
134
135 • If you specify the innodb option, only checksums generated by
136 innodb are allowed.
137
138 • If you specify the crc32 option, only checksums generated by
139 crc32 are allowed.
140
141 • --no-check, -n Ignore the checksum verification when rewriting a
142 checksum. This option may only be used with the innochecksum
143 --write option. If the --write option is not specified,
144 innochecksum terminates.
145
146 In this example, an innodb checksum is rewritten to replace an
147 invalid checksum:
148
149 innochecksum --no-check --write innodb ../data/test/tab1.ibd
150
151 • --allow-mismatches, -a The maximum number of checksum mismatches
152 allowed before innochecksum terminates. The default setting is 0.
153 If --allow-mismatches=N, where N>=0, N mismatches are permitted and
154 innochecksum terminates at N+1. When --allow-mismatches is set to
155 0, innochecksum terminates on the first checksum mismatch.
156
157 In this example, an existing innodb checksum is rewritten to set
158 --allow-mismatches to 1.
159
160 innochecksum --allow-mismatches=1 --write innodb ../data/test/tab1.ibd
161
162 With --allow-mismatches set to 1, if there is a mismatch at page
163 600 and another at page 700 on a file with 1000 pages, the checksum
164 is updated for pages 0-599 and 601-699. Because --allow-mismatches
165 is set to 1, the checksum tolerates the first mismatch and
166 terminates on the second mismatch, leaving page 600 and pages
167 700-999 unchanged.
168
169 • --write=name, -w num Rewrite a checksum. When rewriting an invalid
170 checksum, the --no-check option must be used together with the
171 --write option. The --no-check option tells innochecksum to ignore
172 verification of the invalid checksum. You do not have to specify
173 the --no-check option if the current checksum is valid.
174
175 An algorithm must be specified when using the --write option.
176 Possible values for the --write option are:
177
178 • innodb: A checksum calculated in software, using the original
179 algorithm from InnoDB.
180
181 • crc32: A checksum calculated using the crc32 algorithm,
182 possibly done with a hardware assist.
183
184 • none: A constant number.
185
186 The --write option rewrites entire pages to disk. If the new
187 checksum is identical to the existing checksum, the new checksum is
188 not written to disk in order to minimize I/O.
189
190 innochecksum obtains an exclusive lock when the --write option is
191 used.
192
193 In this example, a crc32 checksum is written for tab1.ibd:
194
195 innochecksum -w crc32 ../data/test/tab1.ibd
196
197 In this example, a crc32 checksum is rewritten to replace an
198 invalid crc32 checksum:
199
200 innochecksum --no-check --write crc32 ../data/test/tab1.ibd
201
202 • --page-type-summary, -S Display a count of each page type in a
203 tablespace. Example usage:
204
205 innochecksum --page-type-summary ../data/test/tab1.ibd
206
207 Sample output for --page-type-summary:
208
209 File::../data/test/tab1.ibd
210 ================PAGE TYPE SUMMARY==============
211 #PAGE_COUNT PAGE_TYPE
212 ===============================================
213 2 Index page
214 0 Undo log page
215 1 Inode page
216 0 Insert buffer free list page
217 2 Freshly allocated page
218 1 Insert buffer bitmap
219 0 System page
220 0 Transaction system page
221 1 File Space Header
222 0 Extent descriptor page
223 0 BLOB page
224 0 Compressed BLOB page
225 0 Other type of page
226 ===============================================
227 Additional information:
228 Undo page type: 0 insert, 0 update, 0 other
229 Undo page state: 0 active, 0 cached, 0 to_free, 0 to_purge, 0 prepared, 0 other
230
231 • --page-type-dump, -D Dump the page type information for each page
232 in a tablespace to stderr or stdout. Example usage:
233
234 innochecksum --page-type-dump=/tmp/a.txt ../data/test/tab1.ibd
235
236 • --log, -l Log output for the innochecksum tool. A log file name
237 must be provided. Log output contains checksum values for each
238 tablespace page. For uncompressed tables, LSN values are also
239 provided. The --log replaces the --debug option, which was
240 available in earlier releases. Example usage:
241
242 innochecksum --log=/tmp/log.txt ../data/test/tab1.ibd
243
244 or:
245
246 innochecksum -l /tmp/log.txt ../data/test/tab1.ibd
247
248 • - option. Specify the - option to read from standard input. If the
249 - option is missing when “read from standard in” is expected,
250 innochecksum prints innochecksum usage information indicating that
251 the “-” option was omitted. Example usages:
252
253 cat t1.ibd | innochecksum -
254
255 In this example, innochecksum writes the crc32 checksum algorithm
256 to a.ibd without changing the original t1.ibd file.
257
258 cat t1.ibd | innochecksum --write=crc32 - > a.ibd
259 Running innochecksum on Multiple User-defined Tablespace Files
260
261 The following examples demonstrate how to run innochecksum on multiple
262 user-defined tablespace files (.ibd files).
263
264 Run innochecksum for all tablespace (.ibd) files in the “test”
265 database:
266
267 innochecksum ./data/test/*.ibd
268
269 Run innochecksum for all tablespace files (.ibd files) that have a file
270 name starting with “t”:
271
272 innochecksum ./data/test/t*.ibd
273
274 Run innochecksum for all tablespace files (.ibd files) in the data
275 directory:
276
277 innochecksum ./data/*/*.ibd
278
279
280 Note
281 Running innochecksum on multiple user-defined tablespace files is
282 not supported on Windows operating systems, as Windows shells such
283 as cmd.exe do not support glob pattern expansion. On Windows
284 systems, innochecksum must be run separately for each user-defined
285 tablespace file. For example:
286
287 innochecksum.exe t1.ibd
288 innochecksum.exe t2.ibd
289 innochecksum.exe t3.ibd
290 Running innochecksum on Multiple System Tablespace Files
291
292 By default, there is only one InnoDB system tablespace file (ibdata1)
293 but multiple files for the system tablespace can be defined using the
294 innodb_data_file_path option. In the following example, three files for
295 the system tablespace are defined using the innodb_data_file_path
296 option: ibdata1, ibdata2, and ibdata3.
297
298 ./bin/mysqld --no-defaults --innodb-data-file-path="ibdata1:10M;ibdata2:10M;ibdata3:10M:autoextend"
299
300 The three files (ibdata1, ibdata2, and ibdata3) form one logical system
301 tablespace. To run innochecksum on multiple files that form one logical
302 system tablespace, innochecksum requires the - option to read
303 tablespace files in from standard input, which is equivalent to
304 concatenating multiple files to create one single file. For the example
305 provided above, the following innochecksum command would be used:
306
307 cat ibdata* | innochecksum -
308
309 Refer to the innochecksum options information for more information
310 about the “-” option.
311
312 Note
313 Running innochecksum on multiple files in the same tablespace is
314 not supported on Windows operating systems, as Windows shells such
315 as cmd.exe do not support glob pattern expansion. On Windows
316 systems, innochecksum must be run separately for each system
317 tablespace file. For example:
318
319 innochecksum.exe ibdata1
320 innochecksum.exe ibdata2
321 innochecksum.exe ibdata3
322
324 Copyright © 1997, 2022, Oracle and/or its affiliates.
325
326 This documentation is free software; you can redistribute it and/or
327 modify it only under the terms of the GNU General Public License as
328 published by the Free Software Foundation; version 2 of the License.
329
330 This documentation is distributed in the hope that it will be useful,
331 but WITHOUT ANY WARRANTY; without even the implied warranty of
332 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
333 General Public License for more details.
334
335 You should have received a copy of the GNU General Public License along
336 with the program; if not, write to the Free Software Foundation, Inc.,
337 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
338 http://www.gnu.org/licenses/.
339
340
342 For more information, please refer to the MySQL Reference Manual, which
343 may already be installed locally and which is also available online at
344 http://dev.mysql.com/doc/.
345
347 Oracle Corporation (http://dev.mysql.com/).
348
349
350
351MySQL 8.0 08/29/2022 INNOCHECKSUM(1)