简体   繁体   English

MySQL InnoDB 问题 - InnoDB 注册失败

[英]MySQL InnoDB problems - InnoDB registration fails

I recently attempted to upgrade a MySQL 5.1 server to 5.7.我最近尝试将 MySQL 5.1 服务器升级到 5.7。 When the server wouldn't start, I discovered you have to export the data first, else do numerous upgrades (the binaries for which aren't available anymore), so I rolled back to 5.1 to do an export.当服务器无法启动时,我发现您必须先导出数据,否则要进行大量升级(二进制文件不再可用),所以我回滚到 5.1 进行导出。

The problem is, back on 5.1, InnoDB will no longer register.问题是,回到 5.1,InnoDB 将不再注册。 In the error log i get:在错误日志中我得到:

InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
160822 17:05:12 [ERROR] Plugin 'InnoDB' init function returned error.
160822 17:05:12 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

As a workaround I set innodb_log_file_size=50331648 in my.cnf .作为一种解决方法,我在my.cnf设置了innodb_log_file_size=50331648 Another restart and:再次重启和:

InnoDB: No valid checkpoint found.
InnoDB: If this error appears when you are creating an InnoDB database,
InnoDB: the problem may be that during an earlier attempt you managed
InnoDB: to create the InnoDB data files, but log file creation failed.
InnoDB: If that is the case, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/error-creating-innodb.html

Reading that links it suggests to delete all files created by InnoDB: all ibdata files and all ib_logfile files .阅读该链接建议delete all files created by InnoDB: all ibdata files and all ib_logfile files I have a 120 GB ibdata file that I most certainly do not intend to delete, so this is a non-starter.我有一个 120 GB 的 ibdata 文件,我肯定不打算删除它,所以这是一个非启动器。 I did try renaming the logfiles though and the server still wouldn't come up.我确实尝试重命名日志文件,但服务器仍然无法启动。

Any pointers from here?任何来自这里的指针?

Edit: I also tried renaming the iblog files.编辑:我也尝试重命名 iblog 文件。 That causes another error where mysql suggests setting innodb_force_recovery=6 .这会导致另一个错误,其中 mysql 建议设置innodb_force_recovery=6 Doing that causes these errors:这样做会导致这些错误:

160823 12:17:32  InnoDB: Page checksum 271832187, prior-to-4.0.14-form checksum 315921779
InnoDB: stored checksum 401867329, prior-to-4.0.14-form stored checksum 401867329
InnoDB: Page lsn 96 3891045697, low 4 bytes of lsn at page end 3891045697
InnoDB: Page number (if stored to page already) 966706,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be a system page
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 966706.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also http://dev.mysql.com/doc/refman/5.1/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 966707.
InnoDB: You may have to recover from a backup.
160823 12:17:32  InnoDB: Page dump in ascii and hex (16384 bytes):

I encounter the similar problem just now.我刚才遇到了类似的问题。 I run both MySQL 5.1 and 5.7 in the same server.我在同一台服务器上同时运行 MySQL 5.1 和 5.7。

With MySQL 5.1, the default innodb_log_file_size is 5m.在 MySQL 5.1 中,默认的 innodb_log_file_size 是 5m。

mysql> show variables like 'innodb_log_file_size';

    +----------------------+---------+
    | Variable_name        | Value   |
    +----------------------+---------+
    | innodb_log_file_size | 5242880 |
    +----------------------+---------+
    1 row in set (0.00 sec)

While MySQL 5.7, the default innodb_log_file_size is 48m.而 MySQL 5.7,默认的 innodb_log_file_size 是 48m。

mysql> show variables like 'innodb_log_file_size';
+----------------------+----------+
| Variable_name        | Value    |
+----------------------+----------+
| innodb_log_file_size | 50331648 |
+----------------------+----------+
1 row in set (0.01 sec)

When upgrade a MySQL 5.1 server to 5.7 and then downgrade to 5.1, the ib_logfile0/1 file was changed in a magic way.当将 MySQL 5.1 服务器升级到 5.7 然后降级到 5.1 时,ib_logfile0/1 文件以一种神奇的方式发生了变化。 The checkpoint of log file cannot be identified.无法识别日志文件的检查点。 So innodb cannot execute a normal recovery using the log files.因此 innodb 无法使用日志文件执行正常恢复。 I didn't make a deep research so i can't give a detailed explanation.我没有做深入研究,所以我不能给出详细的解释。

Solution解决方案

Backup datafile and restart MySQL备份数据文件并重启 MySQL

mv ibdata1 ibdata1.bak
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak
service mysqld restart

Modify my.cnf file, add the following line修改my.cnf文件,添加下面一行

innodb_force_recovery=6

Restore datafile and restart again恢复数据文件并重新启动

mv ibdata1.bak ibdata1

service mysqld restart

Now you will see MySQL start successfully.现在您将看到 MySQL 成功启动。 Ibdata1 may not work properly. Ibdata1 可能无法正常工作。 You can backup your application data using mysqldump.您可以使用 mysqldump 备份您的应用程序数据。 Then remove the recovery line in my.cnf file.然后删除 my.cnf 文件中的恢复行。 Remove ibdata and logfile as well.也删除 ibdata 和 logfile。 Restart MySQL and Import your backup.重新启动 MySQL 并导入您的备份。

A little complex, but these help me.有点复杂,但这些对我有帮助。

Faults故障

As the redo log file was recreated, a little piece of log cannot be redo.由于重新创建了重做日志文件,因此无法重做一小段日志。

Do not delete ibdata* .不要删除ibdata* That is where all the data is!这就是所有数据的所在!

By now, the log files should not matter.到目前为止,日志文件应该无关紧要。 So, there are a couple of ways to deal with the 'error'.因此,有几种方法可以处理“错误”。

Get back the old my.cnf .找回旧的my.cnf If that is not practical, at least set如果那不切实际,至少设置

innodb_log_file_size = 50331648 

(The change to the log file is a bit tricky. Apparently 5.7 increased it to the new default of 48MB without a problem. However, 5.1 does not have the code to dynamically change the file size.) (更改日志文件有点棘手。显然 5.7 将其增加到新的默认值 48MB 没有问题。但是,5.1 没有动态更改文件大小的代码。)

Another approach is to delete (or move aside) the iblog* files.另一种方法是删除(或移开)iblog* 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM