MongoDB 4升級提示 /var/run/mongod.pid: Invalid argument`
因安全需要,需要升級MongoDB,本來是件很簡單的事,把包下載下來 ??-Uvh?
??就完事了。萬萬沒想到花了十幾分鐘。升級以后一直報(bào) ??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.
關(guān)鍵是MongoDB配置文件里面已經(jīng)配置了pid文件
[root@ecs-11-152 mongodb]# grep pid /etc/mongod.conf
pidFilePath: /data/mongodb/mongod.pid # location of pidfile
這個(gè) ??/var/run/mongod.pid?
? 不知道是哪來的
網(wǎng)上查沒有只發(fā)現(xiàn)一個(gè)類似的報(bào)錯(cuò)?
問題產(chǎn)生原因
因?yàn)?nginx 啟動(dòng)需要一點(diǎn)點(diǎn)時(shí)間,而 systemd 在 nginx 完成啟動(dòng)前就去讀取 pid file
造成讀取 pid 失敗解決方法
讓 systemd 在執(zhí)行 ExecStart 的指令后等待一點(diǎn)點(diǎn)時(shí)間即可
如果你的 nginx 啟動(dòng)需要時(shí)間更長,可以把 sleep 時(shí)間改長一點(diǎn)
建立目錄
mkdir -p /etc/systemd/system/nginx.service.d在新建目錄中建立文件override.conf,輸入內(nèi)容
[Service]
ExecStartPost=/bin/sleep 0.1然后
systemctl daemon-reload
systemctl restart nginx.service
于是去查看MongoDB的啟動(dòng)文件,??/lib/systemd/system/mongod.service?
?
結(jié)果發(fā)現(xiàn)有這么一行
PIDFile=/var/run/mongod.pid
把這一行屏蔽以后重啟,問題解決
本文摘自 :https://blog.51cto.com/u