【问题标题】:InnoDB: Error: space header page consists of zero bytes in data file ./ibdata1InnoDB:错误:空间标题页由数据文件中的零字节组成 ./ibdata1
【发布时间】:2015-10-07 11:54:45
【问题描述】:

我有一个完美的 wordpress 设置,但今天服务器突然停止加载我的网站。我登录并重新启动了我的 centos 7 VPS。重新启动后,它没有启动 MariaDB。 这是我在日志中发现的:

141026 18:13:50 [Note] /usr/libexec/mysqld: Shutdown complete

141026 18:13:50 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
141026 18:14:58 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
141026 18:14:58 InnoDB: The InnoDB memory heap is disabled
141026 18:14:58 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141026 18:14:58 InnoDB: Compressed tables use zlib 1.2.7
141026 18:14:58 InnoDB: Using Linux native AIO
141026 18:14:58 InnoDB: Initializing buffer pool, size = 128.0M
141026 18:14:58 InnoDB: Completed initialization of buffer pool
InnoDB: Error: space header page consists of zero bytes in data file ./ibdata1
141026 18:14:58 InnoDB: Could not open or create data files.
141026 18:14:58 InnoDB: If you tried to add new data files, and it failed here,
141026 18:14:58 InnoDB: you should now edit innodb_data_file_path in my.cnf back
141026 18:14:58 InnoDB: to what it was, and remove the new ibdata files InnoDB created
141026 18:14:58 InnoDB: in this failed attempt. InnoDB only wrote those files full of
141026 18:14:58 InnoDB: zeros, but did not yet use them in any way. But be careful: do not
141026 18:14:58 InnoDB: remove old data files which contain your precious data!
141026 18:14:58 [ERROR] Plugin 'InnoDB' init function returned error.
141026 18:14:58 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
141026 18:14:58 [Note] Plugin 'FEEDBACK' is disabled.
141026 18:14:58 [ERROR] Unknown/unsupported storage engine: InnoDB
141026 18:14:58 [ERROR] Aborting

有人可以帮我调查可能是什么问题吗? 现在是否有可能在无法启动 MariaDB 的情况下备份我的数据库?

【问题讨论】:

    标签: database wordpress centos mariadb centos7


    【解决方案1】:

    编辑:将my-innodb-heavy-4G.cnf 复制到/etc/my.cnf.d,服务器启动正常。可能是由于更改了 binlog 大小造成的。


    听起来您更改了 InnoDB 缓冲区的大小,或者它已损坏。这些更改可能是在一段时间前进行的,并且在您重新启动时才生效。

    一定要先备份/var/lib/mysql中的数据——最好是整个目录。

    cp -R /var/lib/mysql /var/lib/mysql-backup

    备份数据后,最好的第一步是还原您对/etc/my.cnf 文件所做的任何更改并重新启动。

    如果不这样做,或者您不知道缓冲区的大小曾经是多少,下一个可能的选择是删除 InnoDB 二进制日志文件并让 MariaDB/MySQL 重新创建它们。这些文件被命名为/var/lib/mysql/ib_logfile{N},其中{N} 是一个数字。

    rm -rf /var/lib/mysql/ib_logfile*

    如果这不能解决问题,请尝试将以下内容添加到您的 /etc/my.cnf(或您使用的任何配置文件,当然要先备份)。它应该放在[innodb] 部分。

    innodb_buffer_pool_size        = 256M
    innodb_log_file_size           = 256M
    innodb_thread_concurrency      = 16
    innodb_flush_log_at_trx_commit = 2
    innodb_flush_method            = normal
    

    诀窍在于了解 MariaDB 的预期。如果上述操作没有成功,请尝试只在最后一行设置[innodb_flush_method]

    【讨论】:

    • 我从未更改过缓冲区。在 my.cnf 中,与缓冲区大小无关。我现在按照您的建议进行了备份,谢谢。我尝试按照您的建议移动 ib_logfiles,但没有帮助。
    • 查看我的编辑以获取更多尝试 - 我猜这是一个 VPS,并且在您重新启动时可能已移至新的虚拟机管理程序?
    • my.cnf 中没有 [innodb] 部分,因此我添加了一个并复制了您写的内容,但没有帮助。我尝试仅添加 innodb_flush_method = normal 也无济于事。是的,这是一个 VPS。我不知道它会被转移到一个新的管理程序。你有更多的建议吗?恢复该数据库非常重要。
    • 抱歉,刚刚仔细检查了我的服务器,这些设置在 [mysqld] 下 - 你是对的,没有 [innodb] 部分。我的配置还使用/etc/my.cnf 来加载/etc/my.cnf.d/ 中的所有cnf 文件,但我使用的是CentOS 5。我不知道重新启动时会发生什么,但由于它理论上是一个VPS,它可能在一个具有不同设置的不同主机...不太可能但可能。
    • @GwynethLlewelyn 很好,因为我使用的是 CentOS :) - 这里是所有有效的选项:dev.mysql.com/doc/refman/5.7/en/…
    【解决方案2】:

    如果您在最初安装 MySQL 时遇到此问题,只需删除 MySQL 数据目录中的 ibdataib_logfile* 文件,然后重新启动 MySQL。

    祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-25
      • 2016-06-28
      • 2020-07-24
      • 2021-11-26
      • 2011-07-27
      • 2014-12-22
      相关资源
      最近更新 更多