ubuntu下mysql无法启动&syslog报“multipath add missing path”怎么回事
时间:2022-06-15 10:46:50
由于给ubuntu虚拟机设置了快照,导致磁盘空间不足,进而导致ubuntu直接被挂起死机,删除快照并重启ubuntu后,则发现mysql无法启动。
使用sudo service mysql status
命令后,报错是这样的:
× mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2021-04-19 00:01:33 CST; 533ms ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 14629 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Process: 14650 ExecStart=/usr/bin/mysqld $MYSQLD_OPTS (code=exited, status=127)
Main PID: 14650 (code=exited, status=127)
CPU: 112ms
4月 19 00:01:33 RISE systemd[1]: mysqld.service: Scheduled restart job, restart counter is at 5.
4月 19 00:01:33 RISE systemd[1]: Stopped MySQL Server.
4月 19 00:01:33 RISE systemd[1]: mysqld.service: Start request repeated too quickly.
4月 19 00:01:33 RISE systemd[1]: mysqld.service: Failed with result 'exit-code'.
4月 19 00:01:33 RISE systemd[1]: Failed to start MySQL Server.
排查/var/log/syslog日志文件,发现大量如下报错:
Jun 11 12:27:28 ubuntu multipathd[681]: sda: add missing path
Jun 11 12:27:28 ubuntu multipathd[681]: sda: failed to get udev uid: Invalid argument
Jun 11 12:27:28 ubuntu multipathd[681]: sda: failed to get sysfs uid: Invalid argument
Jun 11 12:27:28 ubuntu multipathd[681]: sda: failed to get sgio uid: No such file or directory
Jun 11 12:27:33 ubuntu multipathd[681]: sda: add missing path
Jun 11 12:27:33 ubuntu multipathd[681]: sda: failed to get udev uid: Invalid argument
Jun 11 12:27:33 ubuntu multipathd[681]: sda: failed to get sysfs uid: Invalid argument
Jun 11 12:27:33 ubuntu multipathd[681]: sda: failed to get sgio uid: No such file or directory
Jun 11 12:27:38 ubuntu multipathd[681]: sda: add missing path
Jun 11 12:27:38 ubuntu multipathd[681]: sda: failed to get udev uid: Invalid argument
Jun 11 12:27:38 ubuntu multipathd[681]: sda: failed to get sysfs uid: Invalid argument
Jun 11 12:27:38 ubuntu multipathd[681]: sda: failed to get sgio uid: No such file or directory
Jun 11 12:27:43 ubuntu multipathd[681]: sda: add missing path
Jun 11 12:27:43 ubuntu multipathd[681]: sda: failed to get udev uid: Invalid argument
Jun 11 12:27:43 ubuntu multipathd[681]: sda: failed to get sysfs uid: Invalid argument
Jun 11 12:27:43 ubuntu multipathd[681]: sda: failed to get sgio uid: No such file or directory
Jun 11 12:27:48 ubuntu multipathd[681]: sda: add missing path
Jun 11 12:27:48 ubuntu multipathd[681]: sda: failed to get udev uid: Invalid argument
Jun 11 12:27:48 ubuntu multipathd[681]: sda: failed to get sysfs uid: Invalid argument
Jun 11 12:27:48 ubuntu multipathd[681]: sda: failed to get sgio uid: No such file or directory
Jun 11 12:27:53 ubuntu multipathd[681]: sda: add missing path
Jun 11 12:27:53 ubuntu multipathd[681]: sda: failed to get udev uid: Invalid argument
Jun 11 12:27:53 ubuntu multipathd[681]: sda: failed to get sysfs uid: Invalid argument
Jun 11 12:27:53 ubuntu multipathd[681]: sda: failed to get sgio uid: No such file or directory
经过百度搜索得知,是multipath 的配置问题,需要排除本地的sda磁盘(此问题有可能是ubuntu是虚拟机导致的,直接在物理机上部署ubuntu从来没遇到过)。
解决multipath多路径配置问题
1.修改/etc/multipath.conf文件
sudo vi /etc/multipath.conf
2.添加以下内容,sda视本地环境做调整
blacklist {
devnode "sda"
}
3.重启multipath-tools服务
sudo service multipath-tools restart
再次查看/var/log/syslog日志,发现没有报错了,但尝试重启mysql仍然无法启动,排查发现/var/log/syslog提示没有/etc/mysql/my.cnf这个文件,日志截图如下:
Jun 11 12:36:12 ubuntu multipathd[681]: --------shut down-------
Jun 11 12:36:12 ubuntu systemd[1]: Stopping Device-Mapper Multipath Device Controller...
Jun 11 12:36:12 ubuntu systemd[1]: multipathd.service: Succeeded.
Jun 11 12:36:12 ubuntu systemd[1]: Stopped Device-Mapper Multipath Device Controller.
Jun 11 12:36:12 ubuntu systemd[1]: Starting Device-Mapper Multipath Device Controller...
Jun 11 12:36:12 ubuntu multipathd[2463]: --------start up--------
Jun 11 12:36:12 ubuntu multipathd[2463]: read /etc/multipath.conf
Jun 11 12:36:12 ubuntu multipathd[2463]: path checkers start up
Jun 11 12:36:12 ubuntu systemd[1]: Started Device-Mapper Multipath Device Controller.
Jun 11 12:36:38 ubuntu systemd[1]: Starting MySQL Community Server...
Jun 11 12:36:38 ubuntu mysql-systemd-start[2498]: MySQL configuration not found at /etc/mysql/my.cnf. Please create one.
Jun 11 12:36:38 ubuntu systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILURE
Jun 11 12:36:38 ubuntu systemd[1]: mysql.service: Failed with result 'exit-code'.
Jun 11 12:36:38 ubuntu systemd[1]: Failed to start MySQL Community Server.
Jun 11 12:36:38 ubuntu systemd[1]: mysql.service: Scheduled restart job, restart counter is at 1.
Jun 11 12:36:38 ubuntu systemd[1]: Stopped MySQL Community Server.
Jun 11 12:36:38 ubuntu systemd[1]: Starting MySQL Community Server...
手动创建配置文件
cd /etc
sudo mkdir mysql
cd mysql
sudo touch my.cnf
使用sudo service mysql start 命令重启mysql,发现已经可以正常启动了。
lanyirenjg@ubuntu:/etc/mysql$ sudo service mysql start
lanyirenjg@ubuntu:/etc/mysql$ sudo service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-06-11 12:43:20 UTC; 6s ago
Process: 2875 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 2897 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
Main PID: 2899 (mysqld)
Tasks: 27 (limit: 4612)
Memory: 198.0M
CGroup: /system.slice/mysql.service
└─2899 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Jun 11 12:43:20 ubuntu mysqld[2899]: 2022-06-11T12:43:20.634817Z 0 [Warning] CA certificate ca.pem is self signed.
Jun 11 12:43:20 ubuntu mysqld[2899]: 2022-06-11T12:43:20.634934Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
Jun 11 12:43:20 ubuntu mysqld[2899]: 2022-06-11T12:43:20.636509Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
Jun 11 12:43:20 ubuntu mysqld[2899]: 2022-06-11T12:43:20.636673Z 0 [Note] IPv6 is available.
Jun 11 12:43:20 ubuntu mysqld[2899]: 2022-06-11T12:43:20.636738Z 0 [Note] - '::' resolves to '::';
Jun 11 12:43:20 ubuntu mysqld[2899]: 2022-06-11T12:43:20.636779Z 0 [Note] Server socket created on IP: '::'.
Jun 11 12:43:20 ubuntu mysqld[2899]: 2022-06-11T12:43:20.669118Z 0 [Note] Event Scheduler: Loaded 0 events
Jun 11 12:43:20 ubuntu mysqld[2899]: 2022-06-11T12:43:20.669508Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Jun 11 12:43:20 ubuntu mysqld[2899]: Version: '5.7.38-0ubuntu0.18.04.1'socket: '/var/run/mysqld/mysqld.sock'port: 3306(Ubuntu)
Jun 11 12:43:20 ubuntu systemd[1]: Started MySQL Community Server.