systemd[1]: mariadb.service: Can't open PID file /da

时间:2022-01-01 05:58:23

   环境:Centos8
   编译安装Mariadb-10.4.11,安装到make install都没有问题,添加服务启动脚本到/lib/systemd/system/,服务启动脚本名为mariadb.service,下面是自己添加的Mariadb服务启动脚本

 1 [Unit]
 2 Description=Mariadb Community Server
 3 After=network.target
 4 
 5 [Service]
 6 User=mariadb
 7 Group=mariadb
 8 Type=forking
 9 PermissionsStartOnly=true
10 PIDFile=/data/mariadb/30-mariadb-1.pid
11 ExecStart=/usr/local/mariadb/support-files/mysql.server start
12 ExecReload=/usr/local/mariadb/support-files/mysql.server restart
13 ExecStop=/usr/local/mariadb/support-files/mysql.server stop
14 PrivateTmp=false
15 
16 [Install]
17 WantedBy=multi-user.target

   使用systemctl start mariadb尝试启动Mariadb,结果出错

systemd[1]: mariadb.service: Can't open PID file /da

   查看Mariadb错误日志并没有找到有用的信息

systemd[1]: mariadb.service: Can't open PID file /da
   查看mariadb状态出现下面内容
systemd[1]: mariadb.service: Can't open PID file /da

   “systemd[1]: mariadb.service: Can‘t open PID file /data/mariadb/mysql/30-mariadb-1.pid (yet?) after start: No such file or directory”根据这行内容,留意了一下该pid文件,发现在启动mariadb时会出现,启动出错后消失,该/data/maridb目录本身所属主与所属组都是mariadb并且权限是777,按理来说不可能是因为权限不足的原因造成的

   通过百度到的这篇问答https://askubuntu.com/questions/1117330/opendkim-wont-start-cant-open-pid-file,虽然并不是围绕Mariadb的问题,但一样显示Can‘t open PID file问题,下面回复的解决方法是注释或删除掉在启动脚本中PIDFile行,试了一下,问题解决mariadb成功启动

systemd[1]: mariadb.service: Can't open PID file /da