首页 > 解决方案 > MariaDB:启动后立即关闭

问题描述

因此,当我尝试启动 mariadb 时,会发生这种情况:

Job for mariadb.service failed because a timeout was exceeded.
See "systemctl status mariadb.service" and "journalctl -xe" for details.

systemctl status mariadb.service 显示:

    * mariadb.service - MariaDB database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: failed (Result: timeout) since Mon 2019-02-18 10:11:09 UTC; 4min 1s ago
  Process: 779 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 692 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]
  Process: 690 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 689 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 779 (code=exited, status=0/SUCCESS)

Feb 18 10:09:36 vps-zap348646-1 systemd[1]: Starting MariaDB database server...
Feb 18 10:09:37 vps-zap348646-1 mysqld[779]: 2019-02-18 10:09:37 140439143227328 [Note] /usr/sbin/mysqld (mysqld 10.1.29-MariaDB-6ubuntu2) starting as process
Feb 18 10:11:07 vps-zap348646-1 systemd[1]: mariadb.service: Start operation timed out. Terminating.
Feb 18 10:11:09 vps-zap348646-1 systemd[1]: mariadb.service: Failed with result 'timeout'.
Feb 18 10:11:09 vps-zap348646-1 systemd[1]: Failed to start MariaDB database server.

journalctl -xe 显示:

Feb 18 10:17:09 vps-zap348646-1 systemd[1]: Starting MariaDB database server...
-- Subject: Unit mariadb.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mariadb.service has begun starting up.
Feb 18 10:17:10 vps-zap348646-1 mysqld[940]: 2019-02-18 10:17:10 139827003494336 [Note] /usr/sbin/mysqld (mysqld 10.1.29-MariaDB-6ubuntu2)
Feb 18 10:18:39 vps-zap348646-1 systemd[1]: mariadb.service: Start operation timed out. Terminating.
Feb 18 10:18:41 vps-zap348646-1 systemd[1]: mariadb.service: Failed with result 'timeout'.
Feb 18 10:18:41 vps-zap348646-1 systemd[1]: Failed to start MariaDB database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mariadb.service has failed.
--
-- The result is RESULT.

最后是mysql中的error.log:

2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: The InnoDB memory heap is disabled
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Using Linux native AIO
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Using SSE crc32 instructions
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Initializing buffer pool, size = 1.0G
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Completed initialization of buffer pool
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Highest supported file format is Barracuda.
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: 128 rollback segment(s) are active.
2019-02-18 10:17:10 139827003494336 [Note] InnoDB: Waiting for purge to start
2019-02-18 10:17:10 139827003494336 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.36-82.2 started; log sequence number 103241    029
2019-02-18 10:17:10 139827003494336 [Note] Plugin 'FEEDBACK' is disabled.
2019-02-18 10:17:10 139825235617536 [Note] InnoDB: Dumping buffer pool(s) not yet started
2019-02-18 10:17:10 139827003494336 [Note] Server socket created on IP: '127.0.0.1'.
2019-02-18 10:17:10 139827003494336 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.1.29-MariaDB-6ubuntu2'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  Ubuntu 18.10
2019-02-18 10:18:39 139827002763008 [Note] /usr/sbin/mysqld: Normal shutdown

2019-02-18 10:18:39 139827002763008 [Note] Event Scheduler: Purging the queue. 0 events
2019-02-18 10:18:39 139825283266304 [Note] InnoDB: FTS optimize thread exiting.
2019-02-18 10:18:39 139827002763008 [Note] InnoDB: Starting shutdown...
2019-02-18 10:18:39 139827002763008 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2019-02-18 10:18:41 139827002763008 [Note] InnoDB: Shutdown completed; log sequence number 103241039
2019-02-18 10:18:41 139827002763008 [Note] /usr/sbin/mysqld: Shutdown complete

要么我是盲人,要么没有任何错误,而 mariadb 只是不工作。也许你们中的一个人有一个想法。谢谢。

编辑:

我现在找到了一个“解决方案”,mariadb因为启动时超时而关闭,所以现在我将超时设置为0。现在这个解决方案已经足够了,但必须有一个真正的解决方案。

标签: mysqlmariadb

解决方案


请注意,从 10.1.10 开始,MariaDB 使用 systemd 来启动服务。不再使用 /etc/init.d/mysql 脚本,因此 MYSQLD_STARTUP_TIMEOUT 没有效果。

你需要找到你的 mariadb.service 文件。在我们的例子中,它不包含超时,因此使用的是 MariaDB 默认值。只需添加/etc/systemd/system/mariadb.service.d/override.conf文件,然后放入:

[Service]
TimeoutStartSec = 0

在 [Service] 部分,它永远不会超时。创建文件后:

# systemctl daemon-reload
# systemctl restart mysql.service

推荐阅读