innodb_log_file_sizeを変更した時のエラー対処

/tmp/my.cnfのinnodb_log_file_sizeを変更すると、エラーになりmysqlが起動できないという現象に。

mysqld.logを見てみると以下のようなエラーに。

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 134217728 bytes!

my.cnfで指定したメモリのサイズとib_logfile0のサイズが違うとのこと。ib_logfile0はInnoDB ログファイルです。

どうやら、MySQL 5.6 未満でmy.cnfのinnodb_log_file_sizeを変更すると発生するようです。

いきなり消すのは怖いので、/tmpに一旦退避させます。

$ mv /var/lib/mysql/ib_logfile0 /tmp
$ mv /var/lib/mysql/ib_logfile1 /tmp

そして、またmysqlを再起動すると以下のようなエラーに。

151118  7:04:09  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 128 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100
151118  7:04:09  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 128 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Progress in MB: 100
151118  7:04:09 InnoDB: Cannot initialize created log files because
151118  7:04:09 InnoDB: data files are corrupt, or new data files were
151118  7:04:09 InnoDB: created when the database was started previous
151118  7:04:09 InnoDB: time but the database was not shut down
151118  7:04:09 InnoDB: normally after that.

調べてみると、ib_logfile0などを消すのはあまり良くない対処のよう。

公式の、nnoDB ログファイルの数またはサイズの変更、および InnoDB テーブルスペースのサイズの変更を参考に対処しました。