错误:无法将pid文件写入/var/run/mongodb/mongod.pid:没有这样的文件或目录inf fedora 20

时间:2014-09-18 04:01:57

标签: mongodb fedora

MongoDB没有启动。 我已经安装了mongo并且mongo正在运行但是在重新启动后它没有运行。

  

错误:无法将pid文件写入/var/run/mongodb/mongod.pid:没有这样的文件或目录

我的系统是Fedora 20

其日志存档。

2014-09-18T00:28:58.515-0300 ***** SERVER RESTARTED *****
2014-09-18T00:28:58.522-0300 [initandlisten] MongoDB starting : pid=3048 port=27017 dbpath=/var/lib/mongo 64-bit host=localhost.localdomain
2014-09-18T00:28:58.522-0300 [initandlisten] db version v2.6.4
2014-09-18T00:28:58.522-0300 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-09-18T00:28:58.522-0300 [initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-09-18T00:28:58.522-0300 [initandlisten] allocator: tcmalloc
2014-09-18T00:28:58.522-0300 [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2014-09-18T00:28:58.591-0300 [initandlisten] journal dir=/var/lib/mongo/journal
2014-09-18T00:28:58.600-0300 [initandlisten] recover : no journal files present, no recovery needed
2014-09-18T00:28:58.961-0300 [initandlisten] waiting for connections on port 27017
2014-09-18T00:29:06.450-0300 [initandlisten] connection accepted from 127.0.0.1:55047 #1 (1 connection now open)
2014-09-18T00:29:18.402-0300 [conn1] end connection 127.0.0.1:55047 (0 connections now open)
2014-09-18T00:29:47.336-0300 [initandlisten] connection accepted from 127.0.0.1:55049 #2 (1 connection now open)
2014-09-18T00:29:47.355-0300 [initandlisten] connection accepted from 127.0.0.1:55050 #3 (2 connections now open)
2014-09-18T00:29:58.915-0300 [clientcursormon] mem (MB) res:54 virt:604
2014-09-18T00:29:58.915-0300 [clientcursormon]  mapped (incl journal view):320
2014-09-18T00:29:58.915-0300 [clientcursormon]  connections:2
2014-09-18T00:29:59.095-0300 [initandlisten] connection accepted from 127.0.0.1:55055 #4 (3 connections now open)
2014-09-18T00:30:03.065-0300 [initandlisten] connection accepted from 127.0.0.1:55071 #5 (4 connections now open)
2014-09-18T00:30:14.503-0300 [initandlisten] connection accepted from 127.0.0.1:55082 #6 (5 connections now open)
2014-09-18T00:30:27.781-0300 [initandlisten] connection accepted from 127.0.0.1:55093 #7 (6 connections now open)
2014-09-18T00:30:34.899-0300 [initandlisten] connection accepted from 127.0.0.1:55100 #8 (7 connections now open)
2014-09-18T00:30:42.071-0300 [initandlisten] connection accepted from 127.0.0.1:55114 #9 (8 connections now open)
2014-09-18T00:30:52.297-0300 [conn3] end connection 127.0.0.1:55050 (7 connections now open)
2014-09-18T00:30:52.299-0300 [conn2] end connection 127.0.0.1:55049 (6 connections now open)
2014-09-18T00:31:01.252-0300 [conn5] end connection 127.0.0.1:55071 (5 connections now open)
2014-09-18T00:31:01.255-0300 [conn6] end connection 127.0.0.1:55082 (4 connections now open)
2014-09-18T00:31:01.256-0300 [conn7] end connection 127.0.0.1:55093 (3 connections now open)
2014-09-18T00:31:01.256-0300 [conn9] end connection 127.0.0.1:55114 (2 connections now open)
2014-09-18T00:31:01.259-0300 [conn4] end connection 127.0.0.1:55055 (1 connection now open)
2014-09-18T00:31:01.277-0300 [conn8] end connection 127.0.0.1:55100 (0 connections now open)
2014-09-18T00:31:02.252-0300 [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2014-09-18T00:31:02.252-0300 [signalProcessingThread] now exiting
2014-09-18T00:31:02.252-0300 [signalProcessingThread] dbexit: 
2014-09-18T00:31:02.252-0300 [signalProcessingThread] shutdown: going to close listening sockets...
2014-09-18T00:31:02.252-0300 [signalProcessingThread] closing listening socket: 8
2014-09-18T00:31:02.252-0300 [signalProcessingThread] closing listening socket: 9
2014-09-18T00:31:02.252-0300 [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2014-09-18T00:31:02.253-0300 [signalProcessingThread] shutdown: going to flush diaglog...
2014-09-18T00:31:02.253-0300 [signalProcessingThread] shutdown: going to close sockets...
2014-09-18T00:31:02.253-0300 [signalProcessingThread] shutdown: waiting for fs preallocator...
2014-09-18T00:31:02.253-0300 [signalProcessingThread] shutdown: lock for final commit...
2014-09-18T00:31:02.253-0300 [signalProcessingThread] shutdown: final commit...
2014-09-18T00:31:02.508-0300 [signalProcessingThread] shutdown: closing all files...
2014-09-18T00:31:02.509-0300 [signalProcessingThread] closeAllFiles() finished
2014-09-18T00:31:02.509-0300 [signalProcessingThread] journalCleanup...
2014-09-18T00:31:02.509-0300 [signalProcessingThread] removeJournalFiles
2014-09-18T00:31:03.069-0300 [signalProcessingThread] shutdown: removing fs lock...
2014-09-18T00:31:03.069-0300 [signalProcessingThread] dbexit: really exiting now
2014-09-18T00:31:49.408-0300 ***** SERVER RESTARTED *****
2014-09-18T00:31:49.457-0300 ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: No such file or directory
2014-09-18T00:34:39.353-0300 ***** SERVER RESTARTED *****
2014-09-18T00:34:39.356-0300 ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: No such file or directory
2014-09-18T00:37:04.978-0300 ***** SERVER RESTARTED *****
2014-09-18T00:37:04.983-0300 ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: No such file or directory
2014-09-18T00:40:37.708-0300 ***** SERVER RESTARTED *****
2014-09-18T00:40:37.713-0300 ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: No such file or directory
2014-09-18T00:50:07.490-0300 ***** SERVER RESTARTED *****
2014-09-18T00:50:07.494-0300 ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: No such file or directory

5 个答案:

答案 0 :(得分:6)

MongoDB软件包包含一个" bug"这会阻止它们在较新的基于RedHat的系统上正常启动。有关详细信息,请参阅SERVER-14679

作为2.6.5发布之前的解决方法,请根据https://github.com/mongodb/mongo/commit/50ca596ace0b1390482408f1b19ffb1f9170cab6

编辑init脚本

答案 1 :(得分:2)

我终于找到了一个适合我的解决方案(我在Vagrant VM上使用Ubuntu),我从这里开始:

sudo mkdir -p /var/run/mongodb/
sudo chown -R mongodb:mongodb /var/run/mongodb

但是当我用:

检查我的日志时
tail -f /var/log/mongodb/mongodb.log 

我仍然有这个:

  

[小时]我控制[主] *****服务器重新启动*****

     

[小时]我控制[主]错误:无法将pid文件写入/var/run/mongod.pid:权限被拒绝

所以我已经编辑了一个名为mongod.pid的文件,其中没有任何内容:

sudo vim /var/run/mongod.pid

我已经更改了权限:

sudo chown mongodb:mongodb mongod.pid

最终文件夹,用户和权限:

  

drwxr-xr-x 2 mongodb mongodb 40 Jul 27 09:28 mongodb /

     

-rw-r--r-- 1 mongodb mongodb 1月27日09:35 mongod.pid

然后:

sudo systemctl restart mongod

那终于奏效了:)

答案 2 :(得分:1)

这有助于我继续前进

mkdir -p  /var/run/mongodb/ ;chown -R  mongod:mongod /var/run/mongodb/

答案 3 :(得分:1)

逐步,centos 6.8

sudo kill $(sudo lsof -t -i:27017) 
rm -rf /tmp/mongodb-27017.sock
rm -f /var/lib/mongo/mongod.lock 
rm -f /var/run/mongodb/mongod.pid 
sudo service mongod start

打开端口27017并保存更改

iptables -A INPUT -p tcp --dport 27017 -j ACCEPT
sudo service iptables sav

答案 4 :(得分:1)

在Ubuntu中对我有用的是@Tuan Nguyen和@Tom Carchrae的答案的组合

sudo kill $(sudo lsof -t -i:27017) 
sudo rm -rf /tmp/mongodb-27017.sock
sudo rm -f /var/lib/mongo/mongod.lock
sudo rm -f /var/run/mongodb/mongod.pid
sudo mkdir -p  /var/run/mongodb/
touch /var/run/mongodb/mongod.pid
sudo chown -R  mongodb:mongodb /var/run/mongodb/
sudo chown mongodb:mongodb /var/run/mongodb/mongod.pid

然后您可以运行

sudo service mongod start