码迷,mamicode.com
首页 > 数据库 > 详细

MongoDB 4升级提示 /var/run/mongod.pid: Invalid argument`

时间:2020-08-04 18:14:46      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:tin   ali   schema   lan   提示   问题解决   pidfile   err   root   

因安全需要,需要升级MongoDB,本来是件很简单的事,把包下载下来 -Uvh就完事了。万万没想到花了十几分钟。升级以后一直报 Failed to read PID from file /var/run/mongod.pid: Invalid argument

Starting High-performance, schema-free document-oriented database...
Failed to read PID from file /var/run/mongod.pid: Invalid argument
Stopped High-performance, schema-free document-oriented database.

关键是MongoDB配置文件里面已经配置了pid文件

[root@ecs-11-152 mongodb]# grep pid /etc/mongod.conf 
  pidFilePath: /data/mongodb/mongod.pid  # location of pidfile

这个 /var/run/mongod.pid 不知道是哪来的

网上查没有只发现一个类似的报错,

https://my.oschina.net/u/2357619/blog/1609622

问题产生原因

因为 nginx 启动需要一点点时间,而 systemd 在 nginx 完成启动前就去读取 pid file
造成读取 pid 失败

解决方法

让 systemd 在执行 ExecStart 的指令后等待一点点时间即可
如果你的 nginx 启动需要时间更长,可以把 sleep 时间改长一点
建立目录
mkdir -p /etc/systemd/system/nginx.service.d

在新建目录中建立文件override.conf,输入内容

[Service]
ExecStartPost=/bin/sleep 0.1

然后
systemctl daemon-reload
systemctl restart nginx.service

于是去查看MongoDB的启动文件,/lib/systemd/system/mongod.service

结果发现有这么一行

PIDFile=/var/run/mongod.pid

把这一行屏蔽以后重启,问题解决

MongoDB 4升级提示 /var/run/mongod.pid: Invalid argument`

标签:tin   ali   schema   lan   提示   问题解决   pidfile   err   root   

原文地址:https://www.cnblogs.com/fsckzy/p/13434833.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!