简体   繁体   English

MongoDB数据不见了

[英]MongoDB Data disappeared

I just had to do an emergency reboot of my linux server. 我只需要紧急重启Linux服务器即可。 I did it gracefully, not a hard reboot. 我做到了优雅,而不是硬重启。 I have been gathering data through a node.js app for a month, but when the server started up again, all the data was gone! 我已经通过node.js应用程序收集数据一个月了,但是当服务器再次启动时,所有数据都消失了!

I have a long log file: http://clintberry.com/mongod.log 我的日志文件很长: http : //clintberry.com/mongod.log

I also ran a repair to see if it would help but to no avail. 我还进行了维修,以查看是否有帮助,但无济于事。

New Development It looks like I was running mongo with the command 'service mongod start' and when I try to run that command again, I get this: 新开发看起来我正在使用命令“ service mongod start”运行mongo,当我尝试再次运行该命令时,我得到了:

************** 
old lock file: /var/lib/mongo/mongod.lock.  probably means unclean shutdown recommend
removing file and running --repair see: http://dochub.mongodb.org/core/repair 
for more information
*************

So that means the repair I was trying was not working since I wasn't using the correct config file. 因此,这意味着我尝试的修复无法正常运行,因为我没有使用正确的配置文件。

When I run repair with the correct config file it doesn't seem to run repair, just spits out this: 当我使用正确的配置文件运行修复程序时,似乎没有运行修复程序,只需吐出以下内容:

root@es2 [/var/log/mongo]# mongod --dbpath /var/lib/mongo/ --repair
Wed Nov 30 12:09:40 [initandlisten] MongoDB starting : pid=26916 port=27017 dbpath=/var/lib/mongo/ 64-bit
Wed Nov 30 12:09:40 [initandlisten] db version v1.8.4, pdfile version 4.5
Wed Nov 30 12:09:40 [initandlisten] git version: 81f12749a15e3d158b1b16bab6bc3faea538e166
Wed Nov 30 12:09:40 [initandlisten] build sys info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
**************
old lock file: /var/lib/mongo/mongod.lock.  probably means unclean shutdown
recommend removing file and running --repair
see: http://dochub.mongodb.org/core/repair for more information
*************
Wed Nov 30 12:09:40 [initandlisten] exception in initAndListen std::exception: old lock file, terminating
Wed Nov 30 12:09:40 dbexit:
Wed Nov 30 12:09:40 [initandlisten] shutdown: going to close listening sockets...
Wed Nov 30 12:09:40 [initandlisten] shutdown: going to flush diaglog...
Wed Nov 30 12:09:40 [initandlisten] shutdown: going to close sockets...
Wed Nov 30 12:09:40 [initandlisten] shutdown: waiting for fs preallocator...
Wed Nov 30 12:09:40 [initandlisten] shutdown: closing all files...
Wed Nov 30 12:09:40 closeAllFiles() finished
Wed Nov 30 12:09:40 dbexit: really exiting now

As mpobrien 's comment suggested, the issue was that when starting mongo it was using a different dbpath (location for the data). 正如mpobrien的评论所暗示的那样,问题在于,启动mongo时,它使用的是不同的dbpath(数据的位置)。 For those that have mongo installed on CentOS, if you use the service command to start mongo, 对于在CentOS上安装了mongo的用户,如果使用service命令启动mongo,

service mongod start

then mongo will use the configuration file /etc/mongo.conf when starting, which puts your dbpath as /var/lib/mongo 然后mongo在启动时将使用配置文件/etc/mongo.conf,这会将您的dbpath设置为/ var / lib / mongo

but if you start mongo with the regular mongod command, it will not use that folder and will use the mongo default. 但是,如果您使用常规mongod命令启动mongo,它将不使用该文件夹,而是使用mongo默认设置。

Thanks for the help. 谢谢您的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM