复制故障驱动器后,mysql 和 mariadb 拒绝运行

复制故障驱动器后,mysql 和 mariadb 拒绝运行

我的硬盘出现故障,我克隆了该磁盘以保持服务器运行。我注意到 mysql 无法运行,并尝试清除 mysql,尝试安装 mariadb,尝试清除并重新安装多次。看起来 mysql/mariadb 安装得很好,但现在我一直遇到此故障:

Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mariadb.service - MariaDB 10.2.14 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: failed (Result: exit-code) since Fri 2018-04-13 09:12:43 MDT; 10ms ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 22033 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
  Process: 21876 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 21870 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 21865 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 22033 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [Note] Plugin 'FEEDBACK' is disabled.
Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [ERROR] mysqld: File '/var/log/mysql/mariadb-bin.000008' not found (Errcode: 2 "No ...directory")
Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [ERROR] Failed to open log (file '/var/log/mysql/mariadb-bin.000008', errno 2)
Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [ERROR] Could not open log file
Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [ERROR] Can't init tc log
Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [ERROR] Aborting
Apr 13 09:12:43 SSDUbuntuServer systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Apr 13 09:12:43 SSDUbuntuServer systemd[1]: Failed to start MariaDB 10.2.14 database server.
Apr 13 09:12:43 SSDUbuntuServer systemd[1]: mariadb.service: Unit entered failed state.
Apr 13 09:12:43 SSDUbuntuServer systemd[1]: mariadb.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package mariadb-server-10.2 (--configure):
 subprocess installed post-installation script returned error exit status 1

我很想让我的数据库再次运行,但不知道为什么它无法启动。我多次清除并重新安装了 mysql 和 maria,但都出现了同样的错误。

谢谢!

编辑

在授予上述日志目录的写权限后,我得到

Apr 13 11:06:02 SSDUbuntuServer mysqld[8060]: 2018-04-13 11:06:02 140331412616960 [Note] InnoDB: FTS optimize thread exiting.
Apr 13 11:06:02 SSDUbuntuServer mysqld[8060]: 2018-04-13 11:06:02 140332290479872 [Note] Event Scheduler: Purging the queue. 0 events
Apr 13 11:06:02 SSDUbuntuServer mysqld[8060]: 2018-04-13 11:06:02 140332290479872 [Note] InnoDB: Starting shutdown...
Apr 13 11:06:02 SSDUbuntuServer mysqld[8060]: 2018-04-13 11:06:02 140331370653440 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
Apr 13 11:06:02 SSDUbuntuServer mysqld[8060]: 2018-04-13 11:06:02 140331370653440 [Note] InnoDB: Buffer pool(s) dump completed at 180413 11:06:02
Apr 13 11:06:03 SSDUbuntuServer mysqld[8060]: 2018-04-13 11:06:03 140332290479872 [Note] InnoDB: Shutdown completed; log sequence number 1620101
Apr 13 11:06:03 SSDUbuntuServer mysqld[8060]: 2018-04-13 11:06:03 140332290479872 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"

答案1

经过进一步研究,我发现/etc/mysql/debian-start缺少了,并导致了失败。我创建了该文件,并在其内容中填充了这是来自 mariadb 的版本并且一切顺利。

答案2

克隆之前你的驱动器是如何设置的?

Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [Note] Plugin 'FEEDBACK' is disabled.
Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [ERROR] mysqld: File '/var/log/mysql/mariadb-bin.000008' not found (Errcode: 2 "No ...directory")
Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [ERROR] Failed to open log (file '/var/log/mysql/mariadb-bin.000008', errno 2)
Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [ERROR] Could not open log file
Apr 13 09:12:41 SSDUbuntuServer mysqld[22033]: 2018-04-13  9:12:41 140424825977024 [ERROR] Can't init tc log

表示进程未找到日志目录或无权访问已存在的内容。请先尝试列出目录/var/log/mysql/以查看其中是否有内容。

相关内容