Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb restore problems

Tags:

mongodb

Mongodb, running on an Ubuntu 12.04 box, decided to dump core because it opened too many files (applause). After running mongod --repair as root as http://docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/ alluded to (but didn't specify), I now find that mongo has apparently whacked out its own file permissions somehow - every time I try to start I get

Mon Apr  1 15:10:08 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", nojournal: "true" }
Mon Apr  1 15:10:09 [initandlisten] couldn't open /var/lib/mongod/cerebro_test_import_ayp_part2.ns errno:1 Operation not permitted
Mon Apr  1 15:10:09 [initandlisten] error couldn't open file /var/lib/mongodb/cerebro_test_import_ayp_part2.ns terminating

"Operation not permitted"? Really? Even after

$ sudo chmod -R 777 /var/lib/mongodb

? I'm a couple of millimeters away from just blowing this whole database away and chalking it up as yet another reason Mongo sucks. What can I do to get mongo happy again so I don't have to do that? What haven't I tried? What gives?

like image 909
cbmanica Avatar asked Apr 01 '13 22:04

cbmanica


People also ask

How do I restore my MongoDB database?

Restoring MongoDB From a Backup There are basically two ways you can use a BSON format dump: Run mongod directly from the backup directory. Run mongorestore and restore the backup.

What does mongod repair do?

Starting in MongoDB 4.4, for the WiredTiger storage engine, mongod --repair : Rebuilds all indexes for collections with one or more inconsistent indexes. Discards corrupt data. Creates empty/stub files for missing data/metadata files.

Does Mongorestore overwrite?

No. From mongorestore: If you restore to an existing database, mongorestore will only insert into the existing database, and does not perform updates of any kind. If existing documents have the same value _id field in the target database and collection, mongorestore will not overwrite those documents.

How do I restore a .GZ file in MongoDB?

You should just be able to do mongorestore --gzip <path to gzip folder). Side note you can use mongodump with --gzip option and it will compress it for you.


1 Answers

Did you try sudo chown -Rh mongodb:mongodb /var/lib/mongod*?

This has all the hallmarks of a Linux permissions problem, chmod'ding 777 is always a bad idea.

like image 176
Nick Avatar answered Sep 22 '22 11:09

Nick