MariaDB服务器已关闭,但我仍然可以使用mysql客户端(?)登录

时间:2019-02-13 03:34:17

标签: mysql mariadb

MariaDB 10.3.8,Ubuntu 18 LTS。

当我检查数据库状态时,我发现MariaDB已关闭。但是我可以使用mysql client命令登录。有什么事吗我该如何调试呢?

sudo service mariadb status

mariadb.service - MariaDB 10.3.8 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: failed (Result: timeout) since Wed 2019-02-13 08:43:11 IST; 1min 0s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 3293 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Process: 3712 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: 3706 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 3693 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 3878 (mysqld)
Tasks: 13 (limit: 4915)
CGroup: /system.slice/mariadb.service
└─3878 /usr/sbin/mysqld


# lsof -i:3306
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  2346 user_running_mariadb   31u  IPv6  28910      0t0  TCP *:mysql (LISTEN)


ps uax | grep mysql
root      2049  0.0  0.0   4628  1812 ?        S    08:40   0:00 /bin/sh /usr/bin/mysqld_safe
user_running_mariadb   2346  0.1  0.4 3005364 114444 ?      Sl   08:40   0:02 /usr/sbin/mysqld --basedir=/usr --datadir=/my_db_files_dir --plugin-dir=/usr/lib/mysql/plugin --user=user_running_mariadb    --skip-log-error --pid-file=/my_db_rundir/run/mysqld.pid --socket=/my_db_rundir/run/mysqld.sock --port=3306


#/my_db_rundir/run# ls -l
-rw-rw---- 1 user_running_mariadb group_running_mariadb 5 Feb 13 08:40 mysqld.pid
srwxrwxrwx 1 user_running_mariadb group_running_mariadb 0 Feb 13 08:40 mysqld.sock
#/my_db_rundir/run# cat mysqld.pid
2346

我可以登录:

 mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 145
Server version: 10.3.8-MariaDB-1:10.3.8+maria~bionic-log mariadb.org
inary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input 
tatement.
MariaDB [(none)]>

其他输出:

错误日志:

2019-02-13  8:52:13 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-02-13  8:52:13 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-02-13  8:52:13 0 [Note] InnoDB: Unable to open the first data file
2019-02-13  8:52:13 0 [ERROR] InnoDB: Operating system error number 11 in a file operation.
2019-02-13  8:52:13 0 [ERROR] InnoDB: Error number 11 means 'Resource temporarily unavailable'

journalctl -u mariadb.service

Feb 13 08:51:31 my_host systemd[1]: mariadb.service: Start operation timed out. Terminating.
Feb 13 08:52:13 my_host systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Feb 13 08:52:13 my_host systemd[1]: mariadb.service: Failed with result 'timeout'.
Feb 13 08:52:13 my_host systemd[1]: Failed to start MariaDB 10.3.8 database server.

2 个答案:

答案 0 :(得分:0)

该服务超时(“结果:超时”),并且该服务具有systemd配置SendSIGKILL=no,这意味着systemd只是让mysqld继续运行。

为什么超时?看看journalctl -u mariadb.service

答案 1 :(得分:0)

我可以解决此问题,但是我不能完全确定根本原因以及真正解决问题的原因。不过,也许这些信息可以帮助其他面临相同问题的人。

  1. 重新安装了MariaDB,并已升级到10.3.12。可能不需要这样做,因为升级后我一直遇到相同的问题。
  2. 重新启动后,注意到msyqld状态显示为活动,而mariadb状态为不活动:

    / ati / mariadb / logs#sudo服务mysql状态 已加载:已加载(/etc/init.d/mysql;已生成) 活动:活动(运行中) 文件:man:systemd-sysv-generator(8) 进程:1650 ExecStart = / etc / init.d / mysql启动(代码=已退出,状态= 0 /成功) 任务:39(上限:4915) CGroup:/system.slice/mysql.service ─2003 / bin / sh / usr / bin / mysqld_safe ─2301 / usr / sbin / mysqld --basedir = / usr ... └─2302logger -t mysqld -p守护程序错误

    sudo服务mariadb状态 mariadb.service-MariaDB 10.3.12数据库服务器 已加载:已加载(/lib/systemd/system/mariadb.service;已禁用;供应商预设:已启用) 插入:/etc/systemd/system/mariadb.service.d └─从my.cnf-settings.conf迁移 有效:无效(无效)

  3. 在MariaDB网站中,使用

    找到了enabling mariadb service的方式。

    systemctl启用mariadb

  4. 现在,它可以再次工作。