InnoDB:错误:日志文件 ./ib_logfile0 大小不同

jac*_*ack 108 mysql innodb log-files

在将一个数据库转换为使用 InnoDB 引擎后,我只是在 /etc/mysql/my.cnf 中添加了以下几行。

innodb_buffer_pool_size = 2560M
innodb_log_file_size    = 256M
innodb_log_buffer_size  = 8M
innodb_flush_log_at_trx_commit  = 2
innodb_thread_concurrency   = 16
innodb_flush_method = O_DIRECT
Run Code Online (Sandbox Code Playgroud)

但它在第 2 行引发“ERROR 2013 (HY000): Lost connection to MySQL server during query”错误重启mysqld。并且mysql错误日志显示如下

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 268435456 bytes!
100118 20:52:52 [ERROR] Plugin 'InnoDB' init function returned error.
100118 20:52:52 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
100118 20:52:52 [ERROR] Unknown/unsupported table type: InnoDB
100118 20:52:52 [ERROR] Aborting
Run Code Online (Sandbox Code Playgroud)

所以我注释掉了这一行

# innodb_log_file_size  = 256M
Run Code Online (Sandbox Code Playgroud)

它成功地重新启动了mysql。

我想知道mysql错误中显示的“5242880字节的日志文件”是什么?它是该服务器上 InnoDB 引擎上的第一个数据库,那么该日志文件是在何时何地创建的?在这种情况下,如何在 my.cnf 中启用 innodb_log_file_size 指令?

编辑

我试图删除 /var/lib/mysql/ib_logfile0 并重新启动 mysqld 但它仍然失败。它现在在错误日志中显示以下内容。

100118 21:27:11  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 256 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100 200
InnoDB: Error: log file ./ib_logfile1 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 268435456 bytes!
Run Code Online (Sandbox Code Playgroud)

解析度

它现在可以在 /var/lib/mysql 中删除 ib_logfile0 和 ib_logfile1 后工作

wom*_*ble 125

InnoDB 对它的配置非常挑剔;如果有什么不对劲,它就会放弃并回家。要在不丢失数据的情况下更改日志文件大小:

  1. 恢复您对日志文件大小所做的任何配置更改,然后再次启动 MySQL。
  2. 在您运行的 MySQL 中: SET GLOBAL innodb_fast_shutdown =0;
  3. 停止 MySQL
  4. 对日志文件大小进行配置更改。
  5. 删除两个日志文件。
  6. 启动 MySQL。它会抱怨缺少日志文件,但它会创建它们,一切都会好起来的。

  • 删除 ib_logfile0 和 ib_logfile1 为我解决了这个问题。 (44认同)