我使用this link中的信息安装了mongodb。但是,当我使用service mongod start命令时,我收到以下错误。有人可以帮我解决问题吗?
[Piyush@localhost ~]$ 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]
[Piyush@localhost ~]$ sudo service mongod start
[sudo] password for Piyush:
Starting mongod: [FAILED]
我尝试使用--repair命令。我得到了以下输出:
[Piyush@localhost ~]$ 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] _____________________________________________________________________________
在日志文件中,我看到:
[root@localhost ~]# 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
答案 0 :(得分:2)
--repair
标志用于修复损坏的数据库,而不是解决任何权限问题sudo
可能只允许用户调用init脚本的某些部分以超级用户权限执行。其他可能(尽管他们不应该)默默地失败。至少对于init脚本:sudo!=是root。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选项