我昨天犯了升级到15.04的错误:-)。现在我的mongod无法启动:
MongoDB shell version: 2.6.9
connecting to: test
2015-04-26T08:45:08.339-0600 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-04-26T08:45:08.339-0600 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
sudo service mongod status
● mongod.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
接下来,我搜索了与mongodb相关的锁定文件并将其删除。 - 没有帮助。 接下来我做了:
sudo -u mongodb mongod --repair --dbpath /var/lib/mongodb/
sudo service mongodb start
sudo -u mongodb mongod --repair --dbpath /var/lib/mongodb/
2015-04-26T08:56:39.844-0600 [initandlisten] MongoDB starting : pid=17760 port=27017 dbpath=/var/lib/mongodb/ 64-bit host=Parke.dynu.com
2015-04-26T08:56:39.844-0600 [initandlisten] db version v2.6.9
2015-04-26T08:56:39.844-0600 [initandlisten] git version: df313bc75aa94d192330cb92756fc486ea604e64
2015-04-26T08:56:39.844-0600 [initandlisten] build info: Linux build20.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
2015-04-26T08:56:39.844-0600 [initandlisten] allocator: tcmalloc
2015-04-26T08:56:39.844-0600 [initandlisten] options: { repair: true, storage: { dbPath: "/var/lib/mongodb/" } }
2015-04-26T08:56:39.860-0600 [initandlisten] repairDatabase tracker
2015-04-26T08:56:39.860-0600 [initandlisten] allocating new ns file /var/lib/mongodb/_tmp_repairDatabase_0/tracker.ns, filling with zeroes...
2015-04-26T08:56:39.906-0600 [FileAllocator] allocating new datafile /var/lib/mongodb/_tmp_repairDatabase_0/tracker.0, filling with zeroes...
2015-04-26T08:56:39.907-0600 [FileAllocator] creating directory /var/lib/mongodb/_tmp_repairDatabase_0/_tmp
2015-04-26T08:56:39.908-0600 [FileAllocator] done allocating datafile /var/lib/mongodb/_tmp_repairDatabase_0/tracker.0, size: 64MB, took 0 secs
2015-04-26T08:56:39.942-0600 [initandlisten] repairDatabase tracker-test
2015-04-26T08:56:39.942-0600 [initandlisten] allocating new ns file /var/lib/mongodb/_tmp_repairDatabase_0/tracker-test.ns, filling with zeroes...
2015-04-26T08:56:39.987-0600 [FileAllocator] allocating new datafile /var/lib/mongodb/_tmp_repairDatabase_0/tracker-test.0, filling with zeroes...
2015-04-26T08:56:39.988-0600 [FileAllocator] creating directory /var/lib/mongodb/_tmp_repairDatabase_0/_tmp
2015-04-26T08:56:39.990-0600 [FileAllocator] done allocating datafile /var/lib/mongodb/_tmp_repairDatabase_0/tracker-test.0, size: 64MB, took 0.001 secs
2015-04-26T08:56:40.020-0600 [initandlisten] repairDatabase test
2015-04-26T08:56:40.020-0600 [initandlisten] allocating new ns file /var/lib/mongodb/_tmp_repairDatabase_0/test.ns, filling with zeroes...
2015-04-26T08:56:40.065-0600 [FileAllocator] allocating new datafile /var/lib/mongodb/_tmp_repairDatabase_0/test.0, filling with zeroes...
2015-04-26T08:56:40.065-0600 [FileAllocator] creating directory /var/lib/mongodb/_tmp_repairDatabase_0/_tmp
2015-04-26T08:56:40.067-0600 [FileAllocator] done allocating datafile /var/lib/mongodb/_tmp_repairDatabase_0/test.0, size: 64MB, took 0.001 secs
2015-04-26T08:56:40.078-0600 [initandlisten] repairDatabase admin
2015-04-26T08:56:40.078-0600 [initandlisten] allocating new ns file /var/lib/mongodb/_tmp_repairDatabase_0/admin.ns, filling with zeroes...
2015-04-26T08:56:40.123-0600 [FileAllocator] allocating new datafile /var/lib/mongodb/_tmp_repairDatabase_0/admin.0, filling with zeroes...
2015-04-26T08:56:40.123-0600 [FileAllocator] creating directory /var/lib/mongodb/_tmp_repairDatabase_0/_tmp
2015-04-26T08:56:40.125-0600 [FileAllocator] done allocating datafile /var/lib/mongodb/_tmp_repairDatabase_0/admin.0, size: 64MB, took 0.001 secs
2015-04-26T08:56:40.148-0600 [initandlisten] repairDatabase tracker-dev
2015-04-26T08:56:40.148-0600 [initandlisten] allocating new ns file /var/lib/mongodb/_tmp_repairDatabase_0/tracker-dev.ns, filling with zeroes...
2015-04-26T08:56:40.195-0600 [FileAllocator] allocating new datafile /var/lib/mongodb/_tmp_repairDatabase_0/tracker-dev.0, filling with zeroes...
2015-04-26T08:56:40.195-0600 [FileAllocator] creating directory /var/lib/mongodb/_tmp_repairDatabase_0/_tmp
2015-04-26T08:56:40.197-0600 [FileAllocator] done allocating datafile /var/lib/mongodb/_tmp_repairDatabase_0/tracker-dev.0, size: 64MB, took 0.001 secs
2015-04-26T08:56:40.238-0600 [initandlisten] repairDatabase local
2015-04-26T08:56:40.238-0600 [initandlisten] allocating new ns file /var/lib/mongodb/_tmp_repairDatabase_0/local.ns, filling with zeroes...
2015-04-26T08:56:40.285-0600 [FileAllocator] allocating new datafile /var/lib/mongodb/_tmp_repairDatabase_0/local.0, filling with zeroes...
2015-04-26T08:56:40.285-0600 [FileAllocator] creating directory /var/lib/mongodb/_tmp_repairDatabase_0/_tmp
2015-04-26T08:56:40.288-0600 [FileAllocator] done allocating datafile /var/lib/mongodb/_tmp_repairDatabase_0/local.0, size: 64MB, took 0.001 secs
2015-04-26T08:56:40.300-0600 [initandlisten] finished checking dbs
2015-04-26T08:56:40.300-0600 [initandlisten] dbexit:
2015-04-26T08:56:40.300-0600 [initandlisten] shutdown: going to close listening sockets...
2015-04-26T08:56:40.300-0600 [initandlisten] shutdown: going to flush diaglog...
2015-04-26T08:56:40.300-0600 [initandlisten] shutdown: going to close sockets...
2015-04-26T08:56:40.300-0600 [initandlisten] shutdown: waiting for fs preallocator...
2015-04-26T08:56:40.300-0600 [initandlisten] shutdown: closing all files...
2015-04-26T08:56:40.300-0600 [initandlisten] closeAllFiles() finished
2015-04-26T08:56:40.300-0600 [initandlisten] shutdown: removing fs lock...
2015-04-26T08:56:40.300-0600 [initandlisten] dbexit: really exiting now
joel@Parke:/var/lib/mongodb$ sudo service mongodb start
Failed to start mongodb.service: Unit mongodb.service failed to load: No such file or directory.
仍然没有帮助。接下来我创建了一个/ data / db目录,希望这可能会起作用 - 不要...... 那么任何想法?我认为这与远离暴发户有关?
...谢谢
答案 0 :(得分:21)
对于遇到这种情况的其他人 - 多么痛苦! 事实证明,Mongo> 2.6.3有一个已知的问题:启动:支持Systemd(无法使用Fedora 15或更高版本的init脚本启动mongodb) 如上所述:https://jira.mongodb.org/browse/SERVER-17742似乎在Ubuntu 16.04之前可能无法完全修复> 2.6.3,除非有强烈抗议。
所以我的解决方案是发布:
sudo apt-get install --reinstall mongodb
这又回到了mongo 2.6.3,现在一切正常! 对于那些遇到这个... 感谢所有看过这个的人!
答案 1 :(得分:10)
comment here(在@JoelParke引用的Jira票证中)解释了如何通过替换apt源在Ubuntu 15.04上干净地安装当前版本的mongodb(> 3.0):
echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
请注意,Mongoid 4无法对Mongo 3进行身份验证。这将在Mongoid 5中修复。
答案 2 :(得分:3)
您可以使用debian软件包,按照说明(http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/)并用
替换来源 回声" deb http://repo.mongodb.org/apt/debian wheezy / mongodb-org / 3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list答案 3 :(得分:2)
要将mongod进程作为守护程序运行,并将其输出写入日志文件,请使用--fork
和--logpath
选项。您必须创建日志目录;但是,如果日志文件不存在,mongod将创建日志文件。
以下命令将mongod作为守护程序启动,并将日志输出记录到/var/log/mongodb.log
。
mongod --fork --logpath /var/log/mongodb.log
其他配置选项
有关常见用例的常见配置和部署的概述,请参阅运行时数据库配置。
在干净关机中,mongod完成所有待处理操作,将所有数据刷新到数据文件,并关闭所有数据文件。其他关闭是不洁净的,可能会损害数据文件的有效性。
要确保干净关闭,请始终使用以下方法之一关闭mongod实例:
使用shutdownServer()
使用db.shutdownServer()
方法从mongo shell关闭mongod,如下所示:
使用admin
db.shutdownServer()
从init脚本调用相同的方法可以实现相同的结果。
对于启用了授权的系统,用户只能在对管理数据库进行身份验证时发出db.shutdownServer(),或者在未启用身份验证的系统上通过localhost接口发出。
使用--shutdown
在Linux命令行中,使用以下命令中的--shutdown
选项关闭mongod:
mongod --shutdown