CentOS 7下MySQL辦事啟動掉敗的疾速處理辦法。本站提示廣大學習愛好者:(CentOS 7下MySQL辦事啟動掉敗的疾速處理辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是CentOS 7下MySQL辦事啟動掉敗的疾速處理辦法正文
明天,啟動MySQL辦事器掉敗,以下所示:
[root@spark01 ~]# /etc/init.d/mysqld start Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. [FAILED]
依據提醒,分離應用systemctl status mysqld.service和journalctl -xe檢查辦事啟動掉敗的緣由
[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 18:26:57 CST; 40s ago Docs: man:systemd-sysv-generator(8) Process: 2979 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE) Jan 20 18:26:56 spark01 systemd[1]: Starting SYSV: MySQL database server.... Jan 20 18:26:57 spark01 mysqld[2979]: MySQL Daemon failed to start. Jan 20 18:26:57 spark01 mysqld[2979]: Starting mysqld: [FAILED] Jan 20 18:26:57 spark01 systemd[1]: mysqld.service: control process exited, code=exited status=1 Jan 20 18:26:57 spark01 systemd[1]: Failed to start SYSV: MySQL database server.. Jan 20 18:26:57 spark01 systemd[1]: Unit mysqld.service entered failed state. Jan 20 18:26:57 spark01 systemd[1]: mysqld.service failed.
[root@spark01 ~]# journalctl -xe
-- -- Unit session-2.scope has begun starting up. Jan 20 18:26:48 spark01 sshd[2916]: pam_unix(sshd:session): session opened for user spark by (uid=0) Jan 20 18:26:52 spark01 su[2944]: (to root) spark on pts/1 Jan 20 18:26:52 spark01 su[2944]: pam_unix(su-l:session): session opened for user root by spark(uid=1000) Jan 20 18:26:56 spark01 polkitd[909]: Registered Authentication Agent for unix-process:2974:117137 (system bus name :1.25 Jan 20 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. Jan 20 18:26:57 spark01 mysqld[2979]: MySQL Daemon failed to start. Jan 20 18:26:57 spark01 mysqld[2979]: Starting mysqld: [FAILED] Jan 20 18:26:57 spark01 systemd[1]: mysqld.service: control process exited, code=exited status=1 Jan 20 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/listinfo/systemd-devel -- -- Unit mysqld.service has failed. -- -- The result is failed. Jan 20 18:26:57 spark01 systemd[1]: Unit mysqld.service entered failed state. Jan 20 18:26:57 spark01 systemd[1]: mysqld.service failed. Jan 20 18:26:57 spark01 polkitd[909]: Unregistered Authentication Agent for unix-process:2974:117137 (system bus name :1.
但,惋惜的時,這些信息其實不能供給辦事啟動掉敗的真正緣由。
這時候候,無妨翻開MySQL的告警日記,究竟,只需MySQL辦事啟動,告警日記都邑有輸入信息的,果真
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 file: No such file or directory 160120 18:00:20 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
MySQL辦事在啟動的時刻,不克不及創立pid文件。
在終端看一下該目次能否存在,果真,不存在。
因而,創立了/var/run/mysqld/目次,重啟MySQL辦事
[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. See "systemctl status mysqld.service" and "journalctl -xe" for details. [FAILED]
照舊報錯,從新檢查告警日記,有以下輸入
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: Permission denied 160120 18:28:37 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 160120 18:32:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
本來,/var/run/mysqld/的屬主和屬組照樣root,mysql其實不能在個中創立文件,後修正該目次的屬主和屬組,啟動OK。
[root@spark01 ~]# ls -ld /var/run/mysqld/ drwxr-xr-x 2 root root 40 Jan 20 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 ]
總結:
之前在玩Kubernetes的時刻,常碰到啟動掉敗的情形,依據systemctl的提醒,經由過程systemctl status mysqld.service和journalctl -xe敕令檢查辦事啟動掉敗的緣由常常其實不如人意,反而給了一種毛病的暗示,認為這個跟體系有關。其實,經由過程檢查辦事的日記,常常更能清楚的曉得辦事啟動掉敗的緣由。
以上這篇CentOS 7下MySQL辦事啟動掉敗的疾速處理辦法就是小編分享給年夜家的全體內容了,願望能給年夜家一個參考,也願望年夜家多多支撐。