Today, the start of the MySQL server failed, as follows:
[Root@spark01 ~]#/etc/init.d/mysqld start
starting mysqld (via Systemctl): Job for Mysqld.service failed the Control process exited with error code. "Systemctl status Mysqld.service" and "Journalctl-xe" for details.
[FAILED]
According to the prompts, use the Systemctl status Mysqld.service and Journalctl-xe respectively to see why the service failed to start
[Root@spark01 ~]# systemctl status Mysqld.service
?. Mysqld.service-sysv:mysql database server.
Loaded:loaded (/ETC/RC.D/INIT.D/MYSQLD)
active:failed (Result:exit-code) since Wed-2016-01-20 CST; 40s ago
Docs:man:systemd-sysv-generator (8)
process:2979 execstart=/etc/rc.d/init.d/mysqld Start (code=exited, status=1/failure) 18:26:56
spark01 SYSTEMD[1]: Starting sysv:mysql database server ....
18:26:57 spark01 mysqld[2979]: MySQL Daemon failed to start.
18:26:57 spark01 mysqld[2979]: Starting mysqld: [FAILED] an 18:26:57
spark01]: systemd[1 Ntrol Process exited code=exited Status=1 18:26:57 spark01
]: systemd[1 to start Failed database SE RVer.
. 18:26:57 spark01 systemd[1]: unit Mysqld.service entered failed state.
18:26:57 spark01 systemd[1]: Mysqld.service failed.
[Root@spark01 ~]# Journalctl-xe
----Unit Session-2.scope has begun starting up. 18:26:48 spark01 sshd[2916]: Pam_unix (sshd:session): Session opened for user spark by (uid=0) 18:26:52 SU[2944]: (to root) spark on PTS/1 18:26:52 spark01 su[2944]: Pam_unix (su-l:session): Sessions opened for user ro OT by Spark (uid=1000) to 18:26:56 spark01 polkitd[909]: Registered authentication Agent for unix-process:2974:117137 ( System bus name:1.25 18:26:56 spark01 systemd[1]: Starting sysv:mysql database server ...-subject:unit mysqld . Service has begun start-up--defined-by:systemd--support:http://lists.freedesktop.org/mailman/listinfo/
Systemd-devel----Unit Mysqld.service has begun starting up.
18:26:57 spark01 mysqld[2979]: MySQL Daemon failed to start. 18:26:57 spark01 mysqld[2979]: Starting mysqld: [FAILED] an 18:26:57 spark01]: systemd[1 L process exited, code=exited Status=1 18:26:57 spark01 systemd[1]: Failed to start SysV:MySQL database server. --Subject:unit Mysqld.service has failed--defined-by:systemd--Support:http://lists.freedesktop.org/mailman/listin
Fo/systemd-devel----Unit Mysqld.service has failed.
----The result is failed.
18:26:57 spark01 systemd[1]: unit Mysqld.service entered failed state.
18:26:57 spark01 systemd[1]: Mysqld.service failed. 18:26:57 spark01 polkitd[909]: Unregistered authentication Agent for unix-process:2974:117137 (System bus name:1.
Unfortunately, however, this information does not provide the real reason for the failure of the service to start.
At this time, may wish to open the MySQL alarm log, after all, as long as the MySQL service startup, alarm log will have output information, sure enough
2016-01-20t10:00:19.935771z 0 [ERROR]/usr/sbin/mysqld:can ' t create/write to file '/var/run/mysqld/mysqld.pid ' ( Errcode:2-No such file or directory)
2016-01-20t10:00:19.935795z 0 [ERROR] Can ' t start server:can ' t create PID fil E:no such file or directory
160120 18:00:20 mysqld_safe mysqld from PID File/var/run/mysqld/mysqld.pid ended
The MySQL service cannot create a PID file when it is started.
In the terminal to see if the directory exists, sure enough, does not exist.
So, create the/var/run/mysqld/directory, restart the MySQL service
[Root@spark01 ~]# mkdir-p/var/run/mysqld/
[Root@spark01 ~]#/etc/init.d/mysqld start
Starting mysqld (via Systemctl): Job for Mysqld.service failed because the control process exited with error code. "Systemctl status Mysqld.service" and "Journalctl-xe" for details.
[FAILED]
Still error, review the alarm log, have the following output
2016-01-20t10:28:37.183387z 0 [ERROR]/usr/sbin/mysqld:can ' t create/write to file '/var/run/mysqld/mysqld.pid ' ( Errcode:13-permission denied)
2016-01-20t10:28:37.183431z 0 [ERROR] Can ' t start server:can ' t create PID file:perm Ission denied
160120 18:28:37 mysqld_safe mysqld from PID File/var/run/mysqld/mysqld.pid ended 160120 18:32:06
m Ysqld_safe starting mysqld daemon with databases From/var/lib/mysql
It turns out that the owner and group of/var/run/mysqld/or Root,mysql cannot create a file in it, and then modify the owner and group of the directory to start OK.
[Root@spark01 ~]# ls-ld/var/run/mysqld/
drwxr-xr-x 2 root 18:28/var/run/mysqld/
[root@spark01 ~] # chown mysql.mysql/var/run/mysqld/
[root@spark01 ~]#/etc/init.d/mysqld start starting
mysqld (via Systemctl) : [OK]
Summarize:
In the past, when playing kubernetes, often encounter startup failure, according to Systemctl prompts, through the Systemctl status Mysqld.service and Journalctl-xe command to see the failure of service startup is often unsatisfactory, Instead, it gives a false hint that this is related to the system. In fact, by looking at the service log, it is often clearer to know the cause of service startup failure.
Above this article CentOS 7 MySQL service starts the failure The quick solution is the small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.