zoukankan      html  css  js  c++  java
  • MongoDB 4升级提示 /var/run/mongod.pid: Invalid argument`

    因安全需要,需要升级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
    

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

  • 相关阅读:
    锤炼自己,即便是铁,也要是铁中的佼佼者。
    数据库简单学习
    英雄总结
    强化肖龙
    神兽世界
    魔豆魔豆
    硬链接和软连接的区别
    深拷贝和浅拷贝的区别
    C++程序员(终身学习)
    矫健《圣徒》读后感
  • 原文地址:https://www.cnblogs.com/fsckzy/p/13434833.html
Copyright © 2011-2022 走看看