zoukankan      html  css  js  c++  java
  • mysql—Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

    一、问题

    MySQL启动时提示如下错误:

    [ck@hadoop102 conf]$ sudo systemctl start mysqld.service
    [sudo] atguigu 的密码:
    Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

    二、原因分析

    查看日志分析

    [root@hadoop102 conf]# journalctl -xe
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit mysqld.service has failed.
    -- 
    -- The result is failed.
    2月 08 09:50:30 hadoop102 systemd[1]: Unit mysqld.service entered failed state.
    2月 08 09:50:30 hadoop102 systemd[1]: mysqld.service failed.
    2月 08 09:50:31 hadoop102 setroubleshoot[5663]: SELinux is preventing /usr/sbin/mysqld from write access on the file ibdata1. For comple
    2月 08 09:50:31 hadoop102 python[5663]: SELinux is preventing /usr/sbin/mysqld from write access on the file ibdata1.
                                             
                                             *****  Plugin catchall_labels (83.8 confidence) suggests   *******************
                                             
                                             If you want to allow mysqld to have write access on the ibdata1 file
                                             Then you need to change the label on ibdata1
                                             Do
                                             # semanage fcontext -a -t FILE_TYPE 'ibdata1'
                                             where FILE_TYPE is one of the following: afs_cache_t, faillog_t, hugetlbfs_t, initrc_tmp_t, krb
                                             Then execute:
                                             restorecon -v 'ibdata1'
                                             
                                             
                                             *****  Plugin catchall (17.1 confidence) suggests   **************************
                                             
                                             If you believe that mysqld should be allowed write access on the ibdata1 file by default.
                                             Then you should report this as a bug.
                                             You can generate a local policy module to allow this access.
                                             Do
                                             allow this access for now by executing:
                                             # ausearch -c 'mysqld' --raw | audit2allow -M my-mysqld
                                             # semodule -i my-mysqld.pp
                                             
    2月 08 09:50:31 hadoop102 systemd[1]: mysqld.service holdoff time over, scheduling restart.
    2月 08 09:50:31 hadoop102 systemd[1]: Stopped MySQL Server.
    -- Subject: Unit mysqld.service has finished shutting down
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit mysqld.service has finished shutting down.
    2月 08 09:50:31 hadoop102 systemd[1]: Starting MySQL 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.

    selinux限制导致mysql服务启动失败

    三、解决办法

    [root@hadoop102 conf]# getenforce     (查看selinux状态)
    Enforcing
    [root@hadoop102 conf]# setenforce 0    (临时关闭)
    [root@hadoop102 conf]# vim /etc/selinux/config     (永久关闭,将SELINUX=enforcing改为SELINUX=disabled,保存后退出)  
    [root@hadoop102 conf]# getenforce              
    Permissive
    [root@hadoop102 conf]# systemctl start mysqld.service
    [root@hadoop102 conf]# systemctl status mysqld.service
    ● mysqld.service - MySQL Server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
       Active: active (running) since 一 2021-02-08 10:02:40 CST; 42s ago
         Docs: man:mysqld(8)
               http://dev.mysql.com/doc/refman/en/using-systemd.html
      Process: 6370 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
      Process: 6346 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
     Main PID: 6372 (mysqld)
        Tasks: 27
       CGroup: /system.slice/mysqld.service
               └─6372 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
    
    2月 08 10:02:39 hadoop102 mysqld[6370]: 2021-02-08T02:02:39.259391Z 0 [Note] Skipping generation of SSL certificates as ce...ectory.
    2月 08 10:02:39 hadoop102 mysqld[6370]: 2021-02-08T02:02:39.283310Z 0 [Warning] CA certificate ca.pem is self signed.
    2月 08 10:02:39 hadoop102 mysqld[6370]: 2021-02-08T02:02:39.283368Z 0 [Note] Skipping generation of RSA key pair as key fi...ectory.
    2月 08 10:02:39 hadoop102 mysqld[6370]: 2021-02-08T02:02:39.340104Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
    2月 08 10:02:39 hadoop102 mysqld[6370]: 2021-02-08T02:02:39.396911Z 0 [Note] IPv6 is available.
    2月 08 10:02:39 hadoop102 mysqld[6370]: 2021-02-08T02:02:39.396987Z 0 [Note]   - '::' resolves to '::';
    2月 08 10:02:39 hadoop102 mysqld[6370]: 2021-02-08T02:02:39.397056Z 0 [Note] Server socket created on IP: '::'.
    2月 08 10:02:39 hadoop102 mysqld[6370]: 2021-02-08T02:02:39.399136Z 0 [Note] InnoDB: Buffer pool(s) load completed at 2102...0:02:39
    2月 08 10:02:40 hadoop102 mysqld[6370]: 2021-02-08T02:02:40.123553Z 0 [Note]
    2月 08 10:02:40 hadoop102 systemd[1]: Started MySQL Server.
    Hint: Some lines were ellipsized, use -l to show in full.
    [root@hadoop102 conf]# 
  • 相关阅读:
    C++线程池实现-代码分析
    TortoiseGit如何更换用户名和密码
    go 访问apollo配置
    go 操作redis遇到的坑
    java类加载过程
    了解Python
    Java线程
    百度搜索引擎和谷歌搜索引擎的区别
    设置swiper容器同时显示的slide数量
    CSS last-child不起作用
  • 原文地址:https://www.cnblogs.com/zs-chenkang/p/14387755.html
Copyright © 2011-2022 走看看