hiranoです。
あるサービスで使用しているMySQLが突然起動しなくなった時の対処方法を記す。
背景
何もしてないのに突然MySQLが起動しなくなった!
調査
MySQLのログを見ると以下のように表示されている。
170412 10:52:01 mysqld_safe Starting mysqld daemon with databases from /path/to/mysql
2017-04-12 10:52:01 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-04-12 10:52:01 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27) starting as process 2716 ...
中略
2017-04-12 10:52:01 2716 [Note] InnoDB: Log scan progressed past the checkpoint lsn 86908734689
2017-04-12 10:52:01 2716 [Note] InnoDB: Database was not shutdown normally!
2017-04-12 10:52:01 2716 [Note] InnoDB: Starting crash recovery.
2017-04-12 10:52:01 2716 [Note] InnoDB: Reading tablespace information from the .ibd files...
2017-04-12 10:52:01 2716 [ERROR] InnoDB: space header page consists of zero bytes in tablespace ./dbname/table_name.ibd (table dbname/table_name)
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size:1024 Pages to analyze:64
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size: 1024, Possible space_id count:0
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size:2048 Pages to analyze:32
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size: 2048, Possible space_id count:0
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size:4096 Pages to analyze:16
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size: 4096, Possible space_id count:0
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size:8192 Pages to analyze:8
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size: 8192, Possible space_id count:0
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size:16384 Pages to analyze:4
2017-04-12 10:52:01 2716 [Note] InnoDB: Page size: 16384, Possible space_id count:0
2017-04-12 10:52:01 7fb422a60720 InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
InnoDB: If you are installing InnoDB, remember that you must create
InnoDB: directories yourself, InnoDB does not create them.
InnoDB: Error: could not open single-table tablespace file ./dbname/table_name.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
続きを読む