MySQL 5.1では、起動中にエラーが発生した場合、InnoDBストレージエンジンが初期化に失敗する可能性があります。その場合、InnoDBを無効にして続行します。MyISAMテーブルにはアクセスできますが、InnoDBテーブルにはアクセスできません。
InnoDBストレージエンジンが有効になっていることを確認します。5.1.65のインスタンスからの出力は次のとおりです。
mysql> show variables like 'have_innodb';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb | YES |
+---------------+-------+
mysql> show engines;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
. . .
次に、my.cnfを編集してinnodb_log_file_size=256M
、ディスク上のログファイルのサイズではないsetを設定することにより、InnoDBの障害をシミュレートしました。次に、インスタンスを再起動しました。
mysql> show variables like 'have_innodb';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb | NO |
+---------------+-------+
mysql> show variables like 'innodb%';
Empty set (0.00 sec)
問題!どこを見ればいいですか?エラーログファイル:
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 268435456 bytes!
130218 12:50:46 [ERROR] Plugin 'InnoDB' init function returned error.
130218 12:50:46 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
InnoDBの初期化中にエラーが発生した場合、MySQLに強制的に起動を中止させることもできるため、このような状況に陥ることはありません。これを/etc/my.cnfに追加します。
[mysqld]
innodb=force
次に、起動しようとすると、エラーログに次のように表示されます。
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 268435456 bytes!
130218 12:55:03 [ERROR] Plugin 'InnoDB' init function returned error.
130218 12:55:03 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130218 12:55:03 [ERROR] Failed to initialize plugins.
130218 12:55:03 [ERROR] Aborting
130218 12:55:03 [Note] /home/billkarwin/opt/mysql/5.1.65/bin/mysqld: Shutdown complete
MySQL 5.5では、InnoDBの初期化に失敗した場合、サーバーは起動しません。