Mariadb

Ubuntu 上的 MariaDB 15 分鐘後神秘消失

  • August 5, 2021

我有一個我以前從未見過的問題……我的 MariaDB 在 1800 秒後消失,儘管預設配置為wait_timeout28800 秒。

我檢查了我所有的 my.cnf 文件,沒有針對wait_timeout.

MariaDB [andrew]> SHOW VARIABLES LIKE 'wait_%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wait_timeout  | 28800 |
+---------------+-------+
1 row in set (0.005 sec)

我還明確添加了它並重新啟動,沒有任何變化。

以下是我在 15 分鐘後一直遇到的情況:

MariaDB [andrew]> select * from images where file_name like '%test%';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR: Can't connect to the server

當我sudo service mysql status在 CLI 上執行時,我得到:

● mariadb.service - MariaDB 10.3.30 database server
    Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
    Active: failed (Result: timeout) since Thu 2021-08-05 13:03:52 UTC; 5min ago
      Docs: man:mysqld(8)
            https://mariadb.com/kb/en/library/systemd/
   Process: 27498 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
   Process: 27505 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
   Process: 27512 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment >
   Process: 27561 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Main PID: 27561 (code=exited, status=0/SUCCESS)

Aug 05 12:48:50 andrew systemd[1]: Starting MariaDB 10.3.30 database server...
Aug 05 12:48:50 andrew mysqld[27561]: 2021-08-05 12:48:50 0 [Note] /usr/sbin/mysqld (mysqld 10.3.30-MariaDB-0ubuntu0.20.04.1) starting as process 27561 ...
Aug 05 13:03:50 andrew systemd[1]: mariadb.service: start operation timed out. Terminating.
Aug 05 13:03:52 andrew systemd[1]: mariadb.service: Failed with result 'timeout'.
Aug 05 13:03:52 andrew systemd[1]: Failed to start MariaDB 10.3.30 database server.

堆棧是 Ubuntu 20.04.2 LTS、PHP 7.4.3 (cli)、10.3.30-MariaDB-0ubuntu0.20.04.1。沒有網路伺服器。

有誰知道為什麼會這樣?謝謝🙏

原來我之前在這台機器上安裝了 MySQL(而不是 Maria),而 AppArmor 正在干擾。

我用Google搜尋mariadb.service: start operation timed out. Terminating.並找到了這篇 SO 文章:

https://stackoverflow.com/questions/40997257/mysql-service-fails-to-start-hangs-up-timeout-ubuntu-mariadb

…這解決了它。

引用自:https://dba.stackexchange.com/questions/297631