当前位置:   article > 正文

记一次mariadb安装后无法启动的解决方法_mariadb.service: main process exited, code=exited,

mariadb.service: main process exited, code=exited, status=1/failure

操作系统:CentOS Linux release 7.6.1810 (Core)

mariadb-10.5.16

mariadb安装目录

/opt/soft/mariadb-10.5.16-linux-systemd-x86_64

创建软连接

ln -s /opt/soft/mariadb-10.5.16-linux-systemd-x86_64 /usr/local/mysql

配置mariadb.service后,通过systemctl start mariadb,提示异常。

  1. [root@localhost mariadb]# systemctl start mariadb
  2. Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
  3. [root@localhost mariadb]#

执行 journalctl -xe 后提示 没有权限。

localhost.localdomain systemd[11216]: Failed at step EXEC spawning /usr/local/mysql/bin/mariadbd: Permission denied

  1. 425 22:35:53 localhost.localdomain polkitd[728]: Registered Authentication Agent for unix-process:10899:1223692 (system bus name :1.205 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/
  2. 425 22:35:53 localhost.localdomain systemd[1]: Starting MariaDB 10.5.16 database server...
  3. -- Subject: Unit mariadb.service has begun start-up
  4. -- Defined-By: systemd
  5. -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  6. --
  7. -- Unit mariadb.service has begun starting up.
  8. 425 22:35:53 localhost.localdomain systemd[1]: Couldn't stat device /dev/char/10:200
  9. 4月 25 22:35:53 localhost.localdomain systemd[11029]: Failed at step EXEC spawning /usr/local/mysql/bin/mariadbd: Permission denied
  10. -- Subject: Process /usr/local/mysql/bin/mariadbd could not be executed
  11. -- Defined-By: systemd
  12. -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  13. --
  14. -- The process /usr/local/mysql/bin/mariadbd could not be executed and failed.
  15. --
  16. -- The error number returned by this process is 13.
  17. 4月 25 22:35:53 localhost.localdomain systemd[1]: mariadb.service: main process exited, code=exited, status=203/EXEC
  18. 4月 25 22:35:53 localhost.localdomain systemd[1]: Failed to start MariaDB 10.5.16 database server.
  19. -- Subject: Unit mariadb.service has failed
  20. -- Defined-By: systemd
  21. -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  22. --
  23. -- Unit mariadb.service has failed.
  24. --
  25. -- The result is failed.
  26. 4月 25 22:35:53 localhost.localdomain systemd[1]: Unit mariadb.service entered failed state.
  27. 4月 25 22:35:53 localhost.localdomain systemd[1]: mariadb.service failed.
  28. 4月 25 22:35:53 localhost.localdomain polkitd[728]: Unregistered Authentication Agent for unix-process:10899:1223692 (system bus name :1.205, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, l
  29. 4月 25 22:36:06 localhost.localdomain polkitd[728]: Registered Authentication Agent for unix-process:11086:1225003 (system bus name :1.206 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/
  30. 4月 25 22:36:06 localhost.localdomain systemd[1]: Starting MariaDB 10.5.16 database server...
  31. -- Subject: Unit mariadb.service has begun start-up
  32. -- Defined-By: systemd
  33. -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  34. --
  35. -- Unit mariadb.service has begun starting up.
  36. 4月 25 22:36:06 localhost.localdomain systemd[11216]: Failed at step EXEC spawning /usr/local/mysql/bin/mariadbd: Permission denied
  37. -- Subject: Process /usr/local/mysql/bin/mariadbd could not be executed
  38. -- Defined-By: systemd
  39. -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  40. --
  41. -- The process /usr/local/mysql/bin/mariadbd could not be executed and failed.
  42. --
  43. -- The error number returned by this process is 13.
  44. 4月 25 22:36:06 localhost.localdomain systemd[1]: mariadb.service: main process exited, code=exited, status=203/EXEC
  45. 4月 25 22:36:06 localhost.localdomain systemd[1]: Failed to start MariaDB 10.5.16 database server.
  46. -- Subject: Unit mariadb.service has failed
  47. -- Defined-By: systemd
  48. -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  49. --
  50. -- Unit mariadb.service has failed.
  51. --
  52. -- The result is failed.

排查过程:

1、检查/usr/local/mysql/bin/mariadbd 权限

  1. [root@localhost mariadb]#
  2. [root@localhost mariadb]# ls -lrt /usr/local/mysql/bin/mariadbd
  3. -rwxr-xr-x 1 mysql mysql 297637010 5月 18 2022 /usr/local/mysql/bin/mariadbd
  4. [root@localhost mariadb]#
  5. [root@localhost mariadb]# ls -lrt /usr/local/mysql/
  6. 总用量 20
  7. drwxr-xr-x 2 mysql mysql 4096 1月 19 2022 bin
  8. drwxr-xr-x 5 mysql mysql 293 1月 19 2022 lib
  9. drwxrwxr-x 33 mysql mysql 4096 5月 19 2022 share
  10. drwxrwxr-x 2 mysql mysql 56 5月 19 2022 scripts
  11. drwxrwxr-x 4 mysql mysql 30 5月 19 2022 man
  12. drwxr-xr-x 2 mysql mysql 23 5月 23 2022 logs
  13. drwxrwxr-x 4 mysql mysql 202 5月 24 2022 support-files
  14. -rw-r--r-- 1 mysql mysql 5990 5月 26 2022 mariadb.service
  15. drwxr-xr-x 2 mysql mysql 6 6月 8 2022 run
  16. drwx------ 4 mysql mysql 201 6月 8 2022 data
  17. -rw-r--r-- 1 mysql mysql 1158 4月 25 22:35 my.cnf
  18. [root@localhost mariadb]# ls -lrt /usr/local/
  19. 总用量 0
  20. drwxr-xr-x. 2 root root 6 4月 11 2018 src
  21. drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
  22. drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
  23. drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
  24. drwxr-xr-x. 2 root root 6 4月 11 2018 lib
  25. drwxr-xr-x. 2 root root 6 4月 11 2018 include
  26. drwxr-xr-x. 2 root root 6 4月 11 2018 games
  27. drwxr-xr-x. 2 root root 6 4月 11 2018 etc
  28. drwxr-xr-x. 2 root root 6 4月 11 2018 bin
  29. drwxr-xr-x. 5 root root 49 2月 13 16:07 share
  30. lrwxrwxrwx 1 root root 46 4月 25 22:35 mysql -> /opt/soft/mariadb-10.5.16-linux-systemd-x86_64
  31. [root@localhost mariadb]#
  32. [root@localhost mariadb]# ls -lrt /opt/soft/
  33. 总用量 4
  34. drwxr-xr-x 11 mysql mysql 160 5月 26 2022 mariadb-10.5.16-linux-systemd-x86_64
  35. -rw-r--r-- 1 root root 241 4月 25 22:35 install.log
  36. [root@localhost mariadb]# ls -lrt /opt
  37. 总用量 40
  38. drwx--x--x. 4 root root 28 2月 27 18:44 containerd
  39. drwxr-xr-x. 3 root root 18 2月 27 18:44 LicClient
  40. drwxr-xr-x. 22 licserver licserver 4096 3月 22 16:43 license-server
  41. drwxr-xr-x. 3 root root 104 4月 12 14:16 baksoft
  42. -rw-r--r--. 1 root root 1366 4月 14 01:20 install.log
  43. drwxr-xr-x. 2 root root 62 4月 23 10:43 script
  44. drwxr-xr-x. 5 root root 201 4月 23 21:41 agent
  45. drwxr-xr-x. 32 root root 4096 4月 25 19:16 cloudops
  46. -rw-r--r--. 1 root root 25328 4月 25 19:25 log.txt
  47. drwxr-x--- 3 root root 69 4月 25 22:35 soft
  48. [root@localhost mariadb]#

发现/opt/ 下 soft 目录没有其他人的权限。

给 /opt/soft添加 其他人权限

  1. [root@localhost mariadb]# chmod 755 /opt/soft/
  2. [root@localhost mariadb]#
  3. [root@localhost mariadb]# ls -lrt /opt
  4. 总用量 40
  5. drwx--x--x. 4 root root 28 2月 27 18:44 containerd
  6. drwxr-xr-x. 3 root root 18 2月 27 18:44 LicClient
  7. drwxr-xr-x. 22 licserver licserver 4096 3月 22 16:43 license-server
  8. drwxr-xr-x. 3 root root 104 4月 12 14:16 baksoft
  9. -rw-r--r--. 1 root root 1366 4月 14 01:20 install.log
  10. drwxr-xr-x. 2 root root 62 4月 23 10:43 script
  11. drwxr-xr-x. 5 root root 201 4月 23 21:41 agent
  12. drwxr-xr-x. 32 root root 4096 4月 25 19:16 cloudops
  13. -rw-r--r--. 1 root root 25328 4月 25 19:25 log.txt
  14. drwxr-xr-x 3 root root 69 4月 25 22:35 soft
  15. [root@localhost mariadb]#

查看mariadb的服务状态已正常。

  1. [root@localhost mariadb]# systemctl status mariadb.service
  2. ● mariadb.service - MariaDB 10.5.16 database server
  3. Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  4. Active: active (running) since 二 2023-04-25 22:49:21 CST; 38s ago
  5. Docs: man:mariadbd(8)
  6. https://mariadb.com/kb/en/library/systemd/
  7. Process: 11576 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  8. Process: 11427 ExecStartPre=/bin/sh -c [ ! -e /usr/local/mysql/bin/galera_recovery ] && VAR= || VAR=`cd /usr/local/mysql/bin/..; /usr/local/mysql/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  9. Process: 11425 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  10. Main PID: 11551 (mariadbd)
  11. Status: "Taking your SQL requests now..."
  12. Tasks: 24
  13. Memory: 55.5M
  14. CGroup: /system.slice/mariadb.service
  15. └─11551 /usr/local/mysql/bin/mariadbd --defaults-file=/usr/local/mysql/my.cnf
  16. 4月 25 22:49:20 localhost.localdomain systemd[1]: Starting MariaDB 10.5.16 database server...
  17. 4月 25 22:49:21 localhost.localdomain mariadbd[11551]: 2023-04-25 22:49:21 0 [Note] /usr/local/mysql/bin/mariadbd (mysqld 10.5.16-MariaDB) starting as process 11551 ...
  18. 4月 25 22:49:21 localhost.localdomain systemd[1]: Started MariaDB 10.5.16 database server.
  19. [root@localhost mariadb]#
  20. [root@localhost mariadb]#

若提示没有mysql,检查下mysql环境变量

  1. [root@localhost mariadb]# mysql
  2. -bash: mysql: 未找到命令
  3. [root@localhost mariadb]#

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/56171
推荐阅读
相关标签
  

闽ICP备14008679号