2014-09-24 227 views
0

我使用this link中的信息安裝了mongodb。但是,當我使用服務mongod start命令時,出現以下錯誤。有人可以幫我解決問題嗎?無法啓動mongod服務

[[email protected] ~]$ service mongod start 
/etc/init.d/mongod: line 54: ulimit: open files: cannot modify limit: Operation not permitted 
/etc/init.d/mongod: line 56: ulimit: max user processes: cannot modify limit: Operation not permitted 
Starting mongod: runuser: using restricted shell /bin/false 
runuser: cannot set groups: Operation not permitted 
                  [FAILED] 
[[email protected] ~]$ sudo service mongod start 
[sudo] password for Piyush: 
Starting mongod:           [FAILED] 

我試過使用--repair命令。我得到了以下的輸出:

[[email protected] ~]$ sudo mongod --repair 
2014-09-24T00:05:06.089-0400 [initandlisten] MongoDB starting : pid=2807 port=27017 dbpath=/data/db 64-bit host=localhost.localdomain 
2014-09-24T00:05:06.089-0400 [initandlisten] db version v2.6.4 
2014-09-24T00:05:06.089-0400 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910 
2014-09-24T00:05:06.089-0400 [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-24T00:05:06.089-0400 [initandlisten] allocator: tcmalloc 
2014-09-24T00:05:06.090-0400 [initandlisten] options: { repair: true } 
2014-09-24T00:05:06.106-0400 [initandlisten] finished checking dbs 
2014-09-24T00:05:06.106-0400 [initandlisten] dbexit: 
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: going to close listening sockets... 
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: going to flush diaglog... 
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: going to close sockets... 
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: waiting for fs preallocator... 
2014-09-24T00:05:06.106-0400 [initandlisten] shutdown: closing all files... 
2014-09-24T00:05:06.106-0400 [initandlisten] closeAllFiles() finished 
2014-09-24T00:05:06.107-0400 [initandlisten] shutdown: removing fs lock... 
2014-09-24T00:05:06.107-0400 [initandlisten] dbexit: really exiting now 

[編輯1] _____________________________________________________________________________

在日誌文件中我看到:

[[email protected] ~]# cat /var/log/mongodb/mongod.log.2014-09-24T16-00-32 
2014-09-24T11:54:23.636-0400 ***** SERVER RESTARTED ***** 
2014-09-24T11:54:23.665-0400 [initandlisten] MongoDB starting : pid=3004 port=27017 dbpath=/var/lib/mongo 64-bit host=localhost.localdomain 
2014-09-24T11:54:23.665-0400 [initandlisten] db version v2.6.4 
2014-09-24T11:54:23.665-0400 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910 
2014-09-24T11:54:23.665-0400 [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-24T11:54:23.665-0400 [initandlisten] allocator: tcmalloc 
2014-09-24T11:54:23.665-0400 [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-24T11:54:23.680-0400 [initandlisten] journal dir=/var/lib/mongo/journal 
2014-09-24T11:54:23.680-0400 [initandlisten] recover : no journal files present, no recovery needed 
2014-09-24T11:54:23.680-0400 [initandlisten] 
2014-09-24T11:54:23.680-0400 [initandlisten] ERROR: Insufficient free space for journal files 
2014-09-24T11:54:23.680-0400 [initandlisten] Please make at least 3379MB available in /var/lib/mongo/journal or use --smallfiles 
2014-09-24T11:54:23.680-0400 [initandlisten] 
2014-09-24T11:54:23.681-0400 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating 
2014-09-24T11:54:23.681-0400 [initandlisten] dbexit: 
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: going to close listening sockets... 
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: going to flush diaglog... 
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: going to close sockets... 
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: waiting for fs preallocator... 
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: lock for final commit... 
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: final commit... 
2014-09-24T11:54:23.681-0400 [initandlisten] shutdown: closing all files... 
2014-09-24T11:54:23.681-0400 [initandlisten] closeAllFiles() finished 
2014-09-24T11:54:23.681-0400 [initandlisten] journalCleanup... 
2014-09-24T11:54:23.681-0400 [initandlisten] removeJournalFiles 
2014-09-24T11:54:23.684-0400 [initandlisten] shutdown: removing fs lock... 
2014-09-24T11:54:23.684-0400 [initandlisten] dbexit: really exiting now 

回答

2
  1. --repair標誌是爲了修復損壞的數據庫,不解決任何權限問題
  2. 你顯然沒有按照鏈接的指示太緊密,因爲他確實以root身份啓動服務。 ;)sudo可能只允許用戶調用它的超級用戶權限來執行init腳本的某些部分。其他可能(儘管它們不應該)默默地失敗。至少對於init腳本來說:sudo!=是root。
  3. 解決此問題的方法:sudo chown mongod -R /var/log/mongodb/ && sudo chown mongod -R /var/run/mongodb && sudo chown -R /var/lib/mongo然後成爲root並嘗試使用sudo -u mongod mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log手動運行mongo。如果還有其他問題,mongodb會告訴你。修正這些問題,直到手動啓動mongodb爲止,因爲上面所寫的工作完美無瑕,然後從這一點開始使用initscript。

編輯:糾正--dbpath選項,根據註釋

+0

您的意思是'須藤CHOWN的mongod -R在/ var/lib中/ mongo'在3? – proutray 2014-09-24 15:41:17

+0

我改變了,因爲它提供了一個錯誤,並要求更多的參數。另外,當我嘗試運行你的第二個命令時,我得到'錯誤分析命令行:未知選項datadir' – proutray 2014-09-24 15:45:50

+0

但是,如果我更改爲--dbpath,我得到以下輸出: 'sudo -u mongod mongod --dbpath/var/lib/mongo --logpath /var/log/mongodb/mongod.log 2014-09-24T12:00:32.831-0400日誌文件「/var/log/mongodb/mongod.log」exists;轉移到「/var/log/mongodb/mongod.log.2014-09-24T16-00-32」。「 – proutray 2014-09-24 16:02:54