【问题标题】:MariaDB service continuosly fail to startMariaDB 服务一直无法启动
【发布时间】:2018-07-24 01:35:00
【问题描述】:

我在安装 MariaDB 的服务器上遇到了一些问题。

mariadb 进程几天前第一次突然停止工作,当我尝试重新启动它时

sudo service mariadb restart

我得到这个输出

Redirecting to /bin/systemctl restart mariadb.service
Job for mariadb.service failed because the control process exited with error cod                                                                                                     e. See "systemctl status mariadb.service" and "journalctl -xe" for details.
[root@web-customer-01 ~]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2018-02-13 15:43:56 UTC; 24s ago
  Process: 10529 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)
  Process: 10528 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
  Process: 10498 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 10528 (code=exited, status=0/SUCCESS)

Feb 13 15:43:54 web-customer-01.customer.it systemd[1]: Starting MariaDB database server...
Feb 13 15:43:54 web-customer-01.customer.it mariadb-prepare-db-dir[10498]: Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
Feb 13 15:43:54 web-customer-01.customer.it mysqld_safe[10528]: 180213 15:43:54 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Feb 13 15:43:54 web-customer-01.customer.it mysqld_safe[10528]: 180213 15:43:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Feb 13 15:43:56 web-customer-01.customer.it systemd[1]: mariadb.service: control process exited, code=exited status=1
Feb 13 15:43:56 web-customer-01.customer.it systemd[1]: Failed to start MariaDB database server.
Feb 13 15:43:56 web-customer-01.customer.it systemd[1]: Unit mariadb.service entered failed state.
Feb 13 15:43:56 web-customer-01.customer.it systemd[1]: mariadb.service failed.

作为临时解决方案,我发现删除这些文件后,服​​务将重新启动,但我不确定这是一个[好的]解决方案。

/var/lib/mysql/ib_logfile0
/var/lib/mysql/ib_logfile1

我注意到 mariadb 日志中有很多这样的行

180213 15:53:29  InnoDB: Error: page 16392 log sequence number 19972774982
InnoDB: is in the future! Current system log sequence number 731248348.
InnoDB: Your database may be corrupt or you may have copied the InnoDB
InnoDB: tablespace but not the InnoDB log files. See
InnoDB: http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html
InnoDB: for more information.

然后,如上面链接中所述,我在 my.cnf

中添加了 innodb_force_recovery
[mysqld]
innodb_force_recovery = 1

我试图调查问题,但我不知道可能的原因,因此我无法找到正确的解决方案。

-- 编辑

这是我的 /etc/my.cnf (这些天我添加了 innodb_force_recovery

[mysqld]
innodb_force_recovery = 1
innodb_buffer_pool_size=256M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
skip-name-resolve

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

[client]
port = 3306
socket = =/var/lib/mysql/mysql.sock

【问题讨论】:

  • 天哪,你真的在​​不知道它们的用途的情况下删除了这些文件吗?我也喜欢活在危险中!! dba.stackexchange.com/questions/27083/…
  • 是的@Hackerman,但我在删除这些文件之前有几天前的备份。我了解其重要性,但这是使服务器再次联机的唯一方法。
  • 你有多少内存?向我们展示您的my.cnf一些像你这样的打嗝是由错误的配置引起的。
  • @RickJames 这是一个只有 1GB 内存的 Digital Ocean VPS,我将把 my.cnf 添加到帖子中。

标签: mysql database mariadb ubuntu-server


【解决方案1】:

innodb_buffer_pool_size=256M 对于仅仅 1GB 的 RAM 来说可能太大了。更改为 64M。您是否在服务器中运行任何其他应用程序?这也会使事情变得严重。

/etc/my.cnf.d 中有什么内容?我们需要查看所有配置设置,以找出还有哪些调得过大。

或者您可以考虑获得更多 RAM。

【讨论】:

    【解决方案2】:

    我前段时间遇到过这个问题,但我不确定它是如何解决的。

    据我所知,InnoDB 有 3 个用于恢复的文件

    • ibdata1
    • ib_logfile0
    • ib_logfile1

    如果您删除这些文件,则数据库很可能会启动,但如果创建这些文件的目录与其他与数据库相关的目录具有不同的时间戳,则会引发错误,因为它会从备份时检查目录的时间戳。 (如果这有任何意义)

    我发现这可能会有所帮助:

    恢复模式

    模式说明

    0 InnoDB 正常运行时的默认模式。在 MariaDB 10.2.7 之前,它是唯一允许更改数据的模式。从 MariaDB 10.2.7 开始,使用 innodb_force_recovery

    1 (SRV_FORCE_IGNORE_CORRUPT) 允许服务器在检测到损坏页面的情况下继续运行。它通过使基于重做日志的恢复忽略某些错误来做到这一点,例如丢失数据文件或损坏的数据页。将跳过受影响文件或页面的任何重做日志。您可以通过让SELECT * FROM table_name 语句跳过损坏的索引和页面来促进转储表。

    2 (SRV_FORCE_NO_BACKGROUND) 停止主线程运行,防止在清除期间发生崩溃。不会执行清除,因此撤消日志会不断增长。

    3 (SRV_FORCE_NO_TRX_UNDO) 在崩溃恢复后不会回滚事务。不影响当前活动事务的回滚。从 MariaDB 10.2.7 开始,还将阻止一些生成撤消的后台任务运行。这些任务可能会因为已恢复且回滚被阻止的不完整事务而遇到锁定等待。

    4 (SRV_FORCE_NO_IBUF_MERGE) 不计算表统计信息并阻止插入缓冲区合并。

    5 (SRV_FORCE_NO_UNDO_LOG_SCAN) 将未完成的事务视为已提交,启动时不查看撤消日志。

    6 (SRV_FORCE_NO_LOG_REDO) 在恢复过程中不执行重做日志前滚。在此模式处于活动状态时,运行需要索引的查询可能会失败。但是,如果表转储仍然导致崩溃,您可以尝试使用SELECT * FROM tab ORDER BY primary_key DESC 转储损坏部分之后的所有数据部分。

    所以你可以尝试不同的模式,看看是否有帮助。

    【讨论】:

      【解决方案3】:

      在我的情况下,删除 innodb_additional_mem_pool_size = 128M 成功了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-04-06
        • 2021-11-06
        • 2018-10-13
        • 1970-01-01
        • 2017-05-16
        • 2018-08-30
        • 1970-01-01
        • 2015-03-03
        相关资源
        最近更新 更多