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
    

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

  • 相关阅读:
    算法竞赛进阶指南 0.1
    补题 : 过分的谜题
    矩阵快速幂【模板】
    10774: matrix
    火车进出栈问题 【求卡特兰数】
    [最小割]StoerWagner算法
    安装、使用sklearn
    [线段树]跳蚤
    [树形dp][换根]Maximum White Subtree
    [组合数学]Many Many Paths
  • 原文地址:https://www.cnblogs.com/fsckzy/p/13434833.html
Copyright © 2011-2022 走看看