mongodbrestore don't seem to restore all documents - mongodb

In dump/enron directory messages.bson and messages.medata.json fiels. It should restore
120,477 documents.
I want to restore data from it.
I input command:
mongorestore -v --db enron --drop dump/enron
After command is finished I get a messagee:
120477 objects found
don't know what to do with file [dump/enron/messages.metadata.json]
But in the collection message I see 112196 documents using:
db.messages.count()
Could you please tell me what's the problem with it?
The output of the command:
c:\mongodb\mongodb-win32-i386-2.0.5\bin>mongorestore -v dump/enron/
Tue Dec 11 14:17:39 creating new connection to:127.0.0.1
Tue Dec 11 14:17:39 BackgroundJob starting: ConnectBG
Tue Dec 11 14:17:39 connected connection!
connected to: 127.0.0.1
Tue Dec 11 14:17:39 dump/enron/messages.bson
Tue Dec 11 14:17:39 going into namespace [enron.messages]
Tue Dec 11 14:17:39 file size: 396236668
126878231/396236668 32%
270206614/396236668 68%
375698921/396236668 94%
381433738/396236668 96%
387378348/396236668 97%
394626836/396236668 99%
120477 objects found
don't know what to do with file [dump/enron/messages.metadata.json]
What does the message: "don't know what to do with file [dump/enron/messages.metadata.json]" mean?

This should work:
ssharma$ mongorestore -d enron --collection messages /dump/enron/messages.bson
connected to: 127.0.0.1
Thu Mar 7 13:05:05 /dump/enron/messages.bson
Thu Mar 7 13:05:05 going into namespace [enron.messages]
Thu Mar 7 13:05:09 74234213/396236668 18% (bytes)
Thu Mar 7 13:05:12 126614885/396236668 31% (bytes)
Thu Mar 7 13:05:15 192098158/396236668 48% (bytes)
Thu Mar 7 13:05:18 208083274/396236668 52% (bytes)
Thu Mar 7 13:05:21 231816712/396236668 58% (bytes)
Thu Mar 7 13:05:24 293564538/396236668 74% (bytes)
Thu Mar 7 13:05:27 356071219/396236668 89% (bytes)
Thu Mar 7 13:05:30 379387449/396236668 95% (bytes)
120477 objects found
Thu Mar 7 13:05:32 Creating index: { key: { _id: 1 }, ns: "enron.messages", name: "_id_" }
ssharma$ ./mongo
MongoDB shell version: 2.2.2
connecting to: test
> use enron
switched to db enron
> db.messages.count()
120477

You need to specify the database and the collection when restoring the bson file.
It works for me like so:
$ mongodump -d mark --collection coll
connected to: 127.0.0.1
DATABASE: mark to dump/mark
mark.coll to dump/mark/coll.bson
1000 objects
and
$ mongorestore -d mark --collection newcoll dump/mark/
connected to: 127.0.0.1
Wed Aug 29 11:48:39 dump/mark/coll.bson
Wed Aug 29 11:48:39 going into namespace [mark.newcoll]
1000 objects found
Can you try -
mongorestore -d enron --collection messages /dump/enron/

Related

Postgres restore from WAL files without having a basebackup using pg_basebackup

I have the following situation.
Have a master/replica setup.
Somehow the database was dropped and a new database with the same name was created by django. in this case, will the WAL files of the previous database still be there?
I have not created a backup using of the previous database using a tool like pg_basebackup, but do have some WAL files in the pg_xlog.
Now, i am trying to do the following:
- Shutdown the postgres server.
- Use the recovery.conf file in PGDATA (/var/lib/postgresql/9.3/main) directory and entering the following in there:
restore_command = 'cp /var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/%f %p'
recovery_target_time = '2016-01-07 03:00:00'
- Startup the postgres server again.
What I see in the log file is:
postgres:~/9.3/main/pg_log$ tail -100f postgresql-2016-01-07_170256.log
2016-01-07 17:02:56 UTC LOG: database system was shut down at 2016-01-07 17:02:55 UTC
2016-01-07 17:02:56 UTC LOG: starting point-in-time recovery to 2016-01-06 00:00:00+00
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A.history’: No such file or directory
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A00000000000000CC’: No such file or directory
2016-01-07 17:02:56 UTC LOG: consistent recovery state reached at 0/CC000090
2016-01-07 17:02:56 UTC LOG: record with zero length at 0/CC000090
2016-01-07 17:02:56 UTC LOG: redo is not required
2016-01-07 17:02:56 UTC LOG: database system is ready to accept read only connections
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A00000000000000CC’: No such file or directory
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000B.history’: No such file or directory
2016-01-07 17:02:56 UTC LOG: selected new timeline ID: 11
cp: cannot stat ‘/var/lib/postgresql/9.3/main/pg_xlog_backup_jan072016/0000000A.history’: No such file or directory
2016-01-07 17:02:57 UTC LOG: archive recovery complete
2016-01-07 17:02:57 UTC LOG: autovacuum launcher started
2016-01-07 17:02:57 UTC LOG: database system is ready to accept connections
2016-01-07 17:02:57 UTC LOG: incomplete startup packet
My pg_xlog_backup_jan072016 folder has the foll content.:
:~/9.3/main/pg_xlog_backup_jan072016$ ls -larth
total 161M
-rw------- 1 postgres postgres 257 Jan 7 15:57 00000007.history
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000CA
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000C9
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000C8
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000C7
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000C6
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000C5
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000C4
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000C3
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000C2
-rw------- 1 postgres postgres 16M Jan 7 15:57 0000000700000000000000C1
-rw------- 1 postgres postgres 298 Jan 7 15:57 00000007000000000000005D.00000028.backup
-rw------- 1 postgres postgres 214 Jan 7 15:57 00000006.history
-rw------- 1 postgres postgres 171 Jan 7 15:57 00000005.history
drwx------ 3 postgres postgres 4.0K Jan 7 16:54 .
drwx------ 18 postgres postgres 4.0K Jan 7 17:02 ..
drwx------ 2 postgres postgres 4.0K Jan 7 17:08 archive_status
The thing I am trying to figure out is:
Is it possible to restore from WAL without have a backup from pg_basebackup command? I am just trying to restore from WAL in an existing postgres installation.
Why does the log say that it cannot find 0000000A.history and 0000000A00000000000000CC files? The folder does not contain any such files.
Can anyone help us with this?
Thanks.
Sarthak

Mongo shell closes immediately

When I launch the mongo shell it closes immediately. There is no error. It was working fine (yesterday). My MongoDB server is running perfectly, and my application is connecting to it fine. I can't even launch the shell without connecting to a database:
C:\mongodb\bin> mongo --verbose
MongoDB shell version: 2.4.7
Fri Mar 27 10:35:38.425 versionArrayTest passed
connecting to: test
Fri Mar 27 10:35:38.472 creating new connection to:127.0.0.1:27017
Fri Mar 27 10:35:38.472 BackgroundJob starting: ConnectBG
Fri Mar 27 10:35:38.487 connected connection!
bye
Fri Mar 27 10:35:38.487 freeing 1 uncollected class mongo::DBClientCursor objects
Fri Mar 27 10:35:38.487 freeing 1 uncollected class mongo::DBClientWithCommands objects
Fri Mar 27 10:35:38.487 freeing 1 uncollected class mongo::BSONHolder objects
Similarly when connecting with no db:
C:\mongodb\bin> mongo --nodb --norc --verbose
MongoDB shell version: 2.4.7
Fri Mar 27 10:37:00.513 versionArrayTest passed
bye
Any and all thoughts on how to connect gratefully received.
As, mongod service has stopped; you need to go in the task manager-> Services Tab
-> search for MongoDB
-> Right click and click start.
You will find mongod shell is working as it was working previously.
I hope this helped!

MongoDB Illegal Instruction

When I type in "mongo" in terminal
it cannot run and shows up these thing
MongoDB shell version: 2.4.9
Illegal instruction (core dumped)
then nothing happen.
I install mongodb in arch linux.
I have create /data/db.
What kind of processor is this running on? There have been issues in the past with unimplemented instructions on some older processor architectures.
Can you use gdb to examine the core file, or start the mongo process under gdb and reproduce the problem, and determine
what is the illegal instruction that is being executed?
what is the stack backtrace at the point where the illegal instruction occurs?
have you started mongod --dbpath "db location" first? – Eugene P yesterday
Did you get MongoDB from your system package manager or somewhere else? – sudo_O yesterday
This sounds like corruption, new versions of the mongo shell should produce another error if the MongoDB server isn't reachable. – Sammaye yesterday
I have used mongod --dbpath /data/db.
I get mongodb from pacakge manager, i have tried to compile from source, it also same.
mongod --dbpath /data/db
Tue Feb 25 13:27:46.024
Tue Feb 25 13:27:46.027 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Tue Feb 25 13:27:46.032
Tue Feb 25 13:27:46.128 [initandlisten] MongoDB starting : pid=23705 port=27017 dbpath=/data/db 32-bit host=xeraph.hk
Tue Feb 25 13:27:46.129 [initandlisten]
Tue Feb 25 13:27:46.131 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary .
Tue Feb 25 13:27:46.133 [initandlisten] ** 32 bit builds are limited to le ss than 2GB of data (or less with --journal).
Tue Feb 25 13:27:46.134 [initandlisten] ** Note that journaling defaults t o off for 32 bit and is currently off.
Tue Feb 25 13:27:46.136 [initandlisten] ** See http://dochub.mongodb.org/c ore/32bit
Tue Feb 25 13:27:46.138 [initandlisten]
Tue Feb 25 13:27:46.139 [initandlisten] db version v2.4.9
Tue Feb 25 13:27:46.140 [initandlisten] git version: nogitversion
Tue Feb 25 13:27:46.141 [initandlisten] build info: Linux root-armv6-copy 3.4.76 -1-ARCH #1 SMP PREEMPT Wed Jan 15 15:31:14 MST 2014 armv7l BOOST_LIB_VERSION=1_5 5
Tue Feb 25 13:27:46.141 [initandlisten] allocator: system
Tue Feb 25 13:27:46.142 [initandlisten] options: { dbpath: "/data/db" }
Tue Feb 25 13:27:46.227 [websvr] admin web console waiting for connections on po rt 28017
Tue Feb 25 13:27:46.228 [initandlisten] waiting for connections on port 27017
The terminal pause there, then i login to another ssh terminal,
mongo
Also illegal instruction.

Cant initialise replica set on debian (open/create failed in createPrivateMap)

I try to setup MongoDB on my new virtual Server running with Debian 7.3. If a try to configurate the replica set with
hosts = {
"_id" : "rs0",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" : "localhost:27017"
}
]
}
rs.initiate(hosts);
MongoDB crashes with following exceptions:
Tue Jan 21 00:10:24.599 [initandlisten] MongoDB starting : pid=3616 port=27017 dbpath=/var/lib/mongodb 64-bit host=lvps176-28-17-95.dedicated.hosteurope.de
Tue Jan 21 00:10:24.599 [initandlisten]
Tue Jan 21 00:10:24.600 [initandlisten] ** WARNING: You are running in OpenVZ. This is known to be broken!!!
Tue Jan 21 00:10:24.600 [initandlisten]
Tue Jan 21 00:10:24.600 [initandlisten] db version v2.4.7
Tue Jan 21 00:10:24.600 [initandlisten] git version: 0161738abf06c1f067b56a465b706efd6f4bf2aa
Tue Jan 21 00:10:24.600 [initandlisten] build info: Linux ip-10-2-29-40 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_49
Tue Jan 21 00:10:24.600 [initandlisten] allocator: tcmalloc
Tue Jan 21 00:10:24.600 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", replSet: "rs0" }
Tue Jan 21 00:10:24.609 [initandlisten] journal dir=/var/lib/mongodb/journal
Tue Jan 21 00:10:24.609 [initandlisten] recover : no journal files present, no recovery needed
Tue Jan 21 00:10:24.740 [initandlisten] preallocateIsFaster=true 2.38
Tue Jan 21 00:10:24.780 [initandlisten] waiting for connections on port 27017
Tue Jan 21 00:10:24.780 [websvr] admin web console waiting for connections on port 28017
Tue Jan 21 00:10:24.786 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Tue Jan 21 00:10:24.786 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done
Tue Jan 21 00:10:27.429 [initandlisten] connection accepted from 127.0.0.1:50602 #1 (1 connection now open)
Tue Jan 21 00:10:34.786 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Tue Jan 21 00:10:40.160 [conn1] replSet replSetInitiate admin command received from client
Tue Jan 21 00:10:40.163 [conn1] replSet replSetInitiate config object parses ok, 1 members specified
Tue Jan 21 00:10:40.164 [conn1] replSet replSetInitiate all members seem up
Tue Jan 21 00:10:40.164 [conn1] ******
Tue Jan 21 00:10:40.164 [conn1] creating replication oplog of size: 24630MB...
Tue Jan 21 00:10:40.165 [FileAllocator] allocating new datafile /var/lib/mongodb/local.1, filling with zeroes...
Tue Jan 21 00:10:40.165 [FileAllocator] creating directory /var/lib/mongodb/_tmp
Tue Jan 21 00:10:40.205 [FileAllocator] done allocating datafile /var/lib/mongodb/local.1, size: 2047MB, took 0.036 secs
Tue Jan 21 00:10:40.206 [FileAllocator] allocating new datafile /var/lib/mongodb/local.2, filling with zeroes...
Tue Jan 21 00:10:40.233 [FileAllocator] done allocating datafile /var/lib/mongodb/local.2, size: 2047MB, took 0.027 secs
Tue Jan 21 00:10:40.234 [FileAllocator] allocating new datafile /var/lib/mongodb/local.3, filling with zeroes...
Tue Jan 21 00:10:40.255 [FileAllocator] done allocating datafile /var/lib/mongodb/local.3, size: 2047MB, took 0.02 secs
Tue Jan 21 00:10:40.256 [FileAllocator] allocating new datafile /var/lib/mongodb/local.4, filling with zeroes...
Tue Jan 21 00:10:40.275 [FileAllocator] done allocating datafile /var/lib/mongodb/local.4, size: 2047MB, took 0.019 secs
Tue Jan 21 00:10:40.276 [FileAllocator] allocating new datafile /var/lib/mongodb/local.5, filling with zeroes...
Tue Jan 21 00:10:40.355 [FileAllocator] done allocating datafile /var/lib/mongodb/local.5, size: 2047MB, took 0.079 secs
Tue Jan 21 00:10:40.356 [FileAllocator] allocating new datafile /var/lib/mongodb/local.6, filling with zeroes...
Tue Jan 21 00:10:40.372 [FileAllocator] done allocating datafile /var/lib/mongodb/local.6, size: 2047MB, took 0.014 secs
Tue Jan 21 00:10:40.372 [FileAllocator] allocating new datafile /var/lib/mongodb/local.7, filling with zeroes...
Tue Jan 21 00:10:40.498 [FileAllocator] done allocating datafile /var/lib/mongodb/local.7, size: 2047MB, took 0.121 secs
Tue Jan 21 00:10:40.499 [FileAllocator] allocating new datafile /var/lib/mongodb/local.8, filling with zeroes...
Tue Jan 21 00:10:40.546 [FileAllocator] done allocating datafile /var/lib/mongodb/local.8, size: 2047MB, took 0.046 secs
Tue Jan 21 00:10:40.546 [conn1] ERROR: mmap private failed with out of memory. (64 bit build)
Tue Jan 21 00:10:40.546 [conn1] Assertion: 13636:file /var/lib/mongodb/local.8 open/create failed in createPrivateMap (look in log for more information)
0xde0151 0xda188b 0xda1dcc 0xa5a63b 0xa5af9a 0xaba3b1 0x8d518d 0x8d5698 0x8d577f 0x8d5a1e 0xabbb00 0xac1429 0xa75908 0xc10af1 0x8dd4da 0x8de04d 0x8df582 0xa81f00 0xa867cc 0x9fa469
/usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xde0151]
/usr/bin/mongod(_ZN5mongo11msgassertedEiPKc+0x9b) [0xda188b]
/usr/bin/mongod() [0xda1dcc]
/usr/bin/mongod(_ZN5mongo8MongoMMF13finishOpeningEv+0x1fb) [0xa5a63b]
/usr/bin/mongod(_ZN5mongo8MongoMMF6createERKSsRyb+0x5a) [0xa5af9a]
/usr/bin/mongod(_ZN5mongo13MongoDataFile4openEPKcib+0x141) [0xaba3b1]
/usr/bin/mongod(_ZN5mongo8Database7getFileEiib+0xbd) [0x8d518d]
/usr/bin/mongod(_ZN5mongo8Database8addAFileEib+0x38) [0x8d5698]
/usr/bin/mongod(_ZN5mongo8Database12suitableFileEPKcibb+0xaf) [0x8d577f]
/usr/bin/mongod(_ZN5mongo8Database11allocExtentEPKcibb+0x9e) [0x8d5a1e]
/usr/bin/mongod(_ZN5mongo13_userCreateNSEPKcRKNS_7BSONObjERSsPb+0x7a0) [0xabbb00]
/usr/bin/mongod(_ZN5mongo12userCreateNSEPKcNS_7BSONObjERSsbPb+0x2b9) [0xac1429]
/usr/bin/mongod(_ZN5mongo11createOplogEv+0xa78) [0xa75908]
/usr/bin/mongod(_ZN5mongo18CmdReplSetInitiate3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x1da1) [0xc10af1]
/usr/bin/mongod(_ZN5mongo12_execCommandEPNS_7CommandERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x3a) [0x8dd4da]
/usr/bin/mongod(_ZN5mongo7Command11execCommandEPS0_RNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0x71d) [0x8de04d]
/usr/bin/mongod(_ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x5f2) [0x8df582]
/usr/bin/mongod(_ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x40) [0xa81f00]
/usr/bin/mongod(_ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_+0xd7c) [0xa867cc]
/usr/bin/mongod() [0x9fa469]
Tue Jan 21 00:10:40.563 [conn1] replSet replSetInitiate exception: file /var/lib/mongodb/local.8 open/create failed in createPrivateMap (look in log for more information)
Tue Jan 21 00:10:40.563 [conn1] command admin.$cmd command: { replSetInitiate: { _id: "rs0", version: 1.0, members: [ { _id: 0.0, host: "localhost:27017" } ] } } ntoreturn:1 keyUpdates:0 locks(micros) W:401$
Tue Jan 21 00:10:44.787 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Tue Jan 21 00:10:53.835 [conn1] replSet replSetInitiate admin command received from client
Tue Jan 21 00:10:53.835 [conn1] replSet replSetInitiate config object parses ok, 1 members specified
Tue Jan 21 00:10:53.835 [conn1] replSet replSetInitiate all members seem up
Tue Jan 21 00:10:53.835 [conn1] replSet info saving a newer config version to local.system.replset
Tue Jan 21 00:10:54.564 Invalid access at address: 0x18 from thread: conn1
Tue Jan 21 00:10:54.564 Got signal: 11 (Segmentation fault).
Why MongoDB tries to create 8 files a 2GB? My machine run with 16GB ram, may that is the problem? Because in one line the error "[conn1] ERROR: mmap private failed with out of memory. (64 bit build)" looks like my machine run out of memory. But i only create a replica set with one member and an empty database. Sombody know that bug?
It's not RAM but disk space that is the problem, it's not a bug either.
Tue Jan 21 00:10:40.164 [conn1] creating replication oplog of size: 24630MB...
From MongoDB docs:
The oplog (operations log) is a special capped collection that keeps a
rolling record of all operations that modify the data stored in your
databases. MongoDB applies database operations on the primary and then
records the operations on the primary’s oplog. The secondary members
then copy and apply these operations in an asynchronous process. All
replica set members contain a copy of the oplog, allowing them to
maintain the current state of the database.
For 64-bit Linux, Solaris, FreeBSD, and Windows systems, MongoDB
allocates 5% of the available free disk space to the oplog. If this
amount is smaller than a gigabyte, then MongoDB allocates 1 gigabyte
of space.
Above via http://docs.mongodb.org/manual/core/replica-set-oplog/
Oplog is needed for replication (It's a capped collection of a fixed size) and this is created automatically when you create replica set. oplogSize can be set via configuration options (if you would like to just experiment with the setup and can't free up some more disk space).
Here's a doc on it: http://docs.mongodb.org/manual/reference/configuration-options/#oplogSize
However:
Once the mongod has created the oplog for the first time, changing
oplogSize will not affect the size of the oplog.
via http://docs.mongodb.org/manual/reference/configuration-options/#oplogSize
If you would like to change oplogSize after it has been already created you could use this tutorial: http://docs.mongodb.org/manual/tutorial/change-oplog-size/
However if this is your "playground" installation, it better to delete content of your old MongoDB data directory (/var/lib/mongodb), change config file /etc/mongodb.conf (or pass --oplogSize param to mongo when it starts) and just have a "fresh start" with smaller oplog or point your MongoDB dbpath directory to a place where it has more disk space.

cannot get mongodb connected with scrapy-linkedin

Mon Oct 31 18:40:34 [initandlisten] fd limit hard:1024 soft:1024 max conn: 819
Mon Oct 31 18:40:34 [initandlisten] waiting for connections on port 27017
Mon Oct 31 18:40:34 BackgroundJob starting: snapshot
Mon Oct 31 18:40:34 BackgroundJob starting: ClientCursorMonitor
Mon Oct 31 18:40:34 BackgroundJob starting: PeriodicTask::Runner
Mon Oct 31 18:40:34 [websvr] fd limit hard:1024 soft:1024 max conn: 819
Mon Oct 31 18:40:34 [websvr] admin web console waiting for connections on port 28017
the command prompt gets hung up for so much time as i start mongod.exe
i have made the directory data\db as well
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/#mongodb-as-a-windows-service