1 year ago
#281400
JNicolls
MySQL 8 & RHEL 7 - starting services automatically is failing
I'm trying to shutdown and startup a MySQL 8 installation gracefully on reboot. I've enable the service with systemctl with the following command.
systemctl enable rh-mysql80-mysqld.service
After rebooting I check the status
root@localhost > systemctl status rh-mysql80-mysqld.service
ā rh-mysql80-mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/rh-mysql80-mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2022-03-11 12:18:24 PST; 16min ago
Process: 1635 ExecStopPost=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
Process: 1242 ExecStart=/opt/rh/rh-mysql80/root/usr/libexec/mysqld-scl-helper enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mysql80/root/usr (code=exited, status=1/FAILURE)
Process: 1165 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Process: 1098 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 1059 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mysql80 (code=exited, status=0/SUCCESS)
Main PID: 1242 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
I see this in the mysqld.log
/var/log/mysql/mysqld.log
2022-03-11T20:18:24.356194Z 0 [ERROR] [MY-011811] [Server] Can't start server: can't check PID filepath: No such file or directory
After executing the following commands I am able to manually start the service
[root@localhost ~]# sudo mkdir -p /var/run/rh-mysql80-mysqld/
[root@localhost ~]# sudo chown mysql.mysql /var/run/rh-mysql80-mysqld/
[root@localhost ~]# systemctl status rh-mysql80-mysqld.service
ā rh-mysql80-mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/rh-mysql80-mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2022-03-11 12:58:16 PST; 58s ago
Process: 1635 ExecStopPost=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
Process: 14780 ExecStartPost=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 14678 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Process: 14647 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /opt/rh/rh-mysql80/root/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Process: 14641 ExecStartPre=/usr/bin/scl enable $RH_MYSQL80_SCLS_ENABLED -- /usr/bin/scl_enabled rh-mysql80 (code=exited, status=0/SUCCESS)
Main PID: 14721 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/rh-mysql80-mysqld.service
āā14721 /opt/rh/rh-mysql80/root/usr/libexec/mysqld --basedir=/opt/rh/rh-mysql80/root/usr
Mar 11 12:58:15 localhost systemd[1]: Starting MySQL 8.0 database server...
Mar 11 12:58:15 localhost scl[14647]: Socket file /var/lib/mysql/mysql.sock exists.
Mar 11 12:58:15 localhost scl[14647]: No process is using /var/lib/mysql/mysql.sock, which means it is a garbage, so it will be removed automatically.
Mar 11 12:58:16 localhost systemd[1]: Started MySQL 8.0 database server.
Can anyone tell me what needs to be done so that the service can successfully start on reboot without the manual intervention ?
OS Linux 3.10.0-1160.59.1.el7.x86_64 #1 SMP Wed Feb 16 12:17:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
UPDATE: I think I found my problem.
While visiting google university I found other people had "fixed" the same or similar problem by creating a service to create the missing directory in /var/run. I tried this unsuccessfully for an hour or so.
I then stumbled across a MySQL bug report which sent me on a search to locate this file.
-rw-r--r-- 1 root root 44 Sep 16 05:05 /usr/lib/tmpfiles.d/rh-mysql80-mysqld.conf
The contents of this file
d /run/rh-mysql80-mysqld 0755 mysql mysql -
If this file exists, why is it not working. I took a look in /varlog/messages and found this:
Mar 11 15:43:03 systemd-tmpfiles: [/usr/lib/tmpfiles.d/rh-mysql80-mysqld.conf:1] Unknown group 'mysql'.
Mar 11 15:43:03 systemd: systemd-tmpfiles-setup.service: main process exited, code=exited, status=1/FAILURE
Mar 11 15:43:03 systemd: Unit systemd-tmpfiles-setup.service entered failed state.
Mar 11 15:43:03 systemd: systemd-tmpfiles-setup.service failed.
"mysql" wasnt in the /etc/group file (despite the groupadd command saying that it already existed) so I manually added it.
Made this change, rebooted.... and BOOM!!....Mysql started automatically!
mysql
linux
redhat
enterprise
systemctl
0 Answers
Your Answer