[MongoDB]: bsondump – how it works !
[root@myhostname bin]# ./mongo
MongoDB shell version: 2.4.11
connecting to: test
>
> use mydb
switched to db mydb
>
>
> for(var i = 1; i <= 10000 ; i++){db.test_collection.insert({“_id” : i , “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : i }); sleep(1);} null >
>
>
> db.test_collection.count()
10000
>
>
>
>
>
>
bye
[root@myhostname bin]#
[root@myhostname bin]# cd –
/data/1/mongodb
[root@myhostname mongodb]# ll -lhtr
total 97M
-rwxr-xr-x 1 root root 5 May 28 08:38 mongod.lock
-rw——- 1 root root 16M May 28 08:38 local.ns
-rw——- 1 root root 16M May 28 08:38 local.0
-rw——- 1 root root 32M May 28 08:38 mydb.1
drwxr-xr-x 2 root root 4.0K May 28 08:38 _tmp
-rw——- 1 root root 16M May 28 08:39 mydb.ns
-rw——- 1 root root 16M May 28 08:39 mydb.0
[root@myhostname mongodb]#
[root@myhostname bin]# ps -ef | grep mongo
root 620 19357 0 08:58 pts/0 00:00:00 grep mongo
root 2516 19357 0 08:38 pts/0 00:00:05 ./mongod –dbpath /data/1/mongodb –nojournal –smallfiles –logpath /tmp/mongodlog.txt –quiet
[root@myhostname bin]#
[root@myhostname bin]# kill 2516
[root@myhostname bin]#
[1]+ Done ./mongod –dbpath /data/1/mongodb –nojournal –smallfiles –logpath /tmp/mongodlog.txt –quiet
[root@myhostname bin]#
[root@myhostname bin]# ./mongodump –dbpath /data/1/mongodb/ -d mydb -c test_collection -o dump
Thu May 28 08:58:38.531 [tools] DATABASE: mydb to dump/mydb
Thu May 28 08:58:38.551 [tools] info openExisting file size 16777216 but cmdLine.smallfiles false
Thu May 28 08:58:38.551 [tools] info openExisting file size 33554432 but cmdLine.smallfiles false
Thu May 28 08:58:38.563 [tools] mydb.test_collection to dump/mydb/test_collection.bson
Thu May 28 08:58:38.592 [tools] 10000 objects
Thu May 28 08:58:38.592 [tools] Metadata for mydb.test_collection to dump/mydb/test_collection.metadata.json
Thu May 28 08:58:38.592 dbexit:
Thu May 28 08:58:38.592 [tools] shutdown: going to close listening sockets…
Thu May 28 08:58:38.592 [tools] shutdown: going to flush diaglog…
Thu May 28 08:58:38.592 [tools] shutdown: going to close sockets…
Thu May 28 08:58:38.593 [tools] shutdown: waiting for fs preallocator…
Thu May 28 08:58:38.593 [tools] shutdown: closing all files…
Thu May 28 08:58:38.597 [tools] closeAllFiles() finished
Thu May 28 08:58:38.597 [tools] shutdown: removing fs lock…
Thu May 28 08:58:38.597 dbexit: really exiting now
[root@myhostname bin]#
[root@myhostname bin]#
[root@myhostname bin]# ll -lhtr
total 233M
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongodump
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongorestore
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongoexport
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongoimport
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongostat
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongotop
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongooplog
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongofiles
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 bsondump
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongoperf
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongosniff
-rwxr-xr-x 1 bob bob 18M Aug 22 2014 mongod
-rwxr-xr-x 1 bob bob 14M Aug 22 2014 mongos
-rwxr-xr-x 1 bob bob 9.1M Aug 22 2014 mongo
drwxr-xr-x 3 root root 4.0K May 28 08:58 dump
[root@myhostname bin]#
[root@myhostname bin]# cd dump
[root@myhostname dump]# ll -lhtr
total 4.0K
drwxr-xr-x 2 root root 4.0K May 28 08:58 mydb
[root@myhostname dump]# cd mydb/
[root@myhostname mydb]# ll -lhtr
total 1.2M
-rw-r–r– 1 root root 102 May 28 08:58 test_collection.metadata.json
-rw-r–r– 1 root root 1.2M May 28 08:58 test_collection.bson
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]# /opt/mongodb/bin/bsondump test_collection.bson | head
{ “_id” : 1, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 1 }
{ “_id” : 2, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 2 }
{ “_id” : 3, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 3 }
{ “_id” : 4, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 4 }
{ “_id” : 5, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 5 }
{ “_id” : 6, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 6 }
{ “_id” : 7, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 7 }
{ “_id” : 8, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 8 }
{ “_id” : 9, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9 }
{ “_id” : 10, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 10 }
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]# /opt/mongodb/bin/bsondump test_collection.bson | tail
10000 objects found
{ “_id” : 9991, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9991 }
{ “_id” : 9992, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9992 }
{ “_id” : 9993, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9993 }
{ “_id” : 9994, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9994 }
{ “_id” : 9995, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9995 }
{ “_id” : 9996, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9996 }
{ “_id” : 9997, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9997 }
{ “_id” : 9998, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9998 }
{ “_id” : 9999, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9999 }
{ “_id” : 10000, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 10000 }
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]# /opt/mongodb/bin/bsondump test_collection.bson | wc -l
10000 objects found
10000
[root@myhostname mydb]#
[root@myhostname mydb]# /opt/mongodb/bin/bsondump test_collection.bson > test_collection.json
10000 objects found
[root@myhostname mydb]#
[root@myhostname mydb]# head test_collection.json
{ “_id” : 1, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 1 }
{ “_id” : 2, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 2 }
{ “_id” : 3, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 3 }
{ “_id” : 4, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 4 }
{ “_id” : 5, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 5 }
{ “_id” : 6, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 6 }
{ “_id” : 7, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 7 }
{ “_id” : 8, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 8 }
{ “_id” : 9, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9 }
{ “_id” : 10, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 10 }
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]# /opt/mongodb/bin/bsondump –type=debug test_collection.bson | head -10
— new object —
size : 119
_id
type: 1 size: 13
title
type: 2 size: 77
Iteration no:
type: 1 size: 24
— new object —
size : 119
[root@myhostname mydb]#
[root@myhostname mydb]# /opt/mongodb/bin/bsondump –objcheck test_collection.bson | head
{ “_id” : 1, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 1 }
{ “_id” : 2, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 2 }
{ “_id” : 3, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 3 }
{ “_id” : 4, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 4 }
{ “_id” : 5, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 5 }
{ “_id” : 6, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 6 }
{ “_id” : 7, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 7 }
{ “_id” : 8, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 8 }
{ “_id” : 9, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9 }
{ “_id” : 10, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 10 }
[root@myhostname mydb]#
[root@myhostname mydb]#
[root@myhostname mydb]# /opt/mongodb/bin/bsondump –noobjcheck test_collection.bson | head
{ “_id” : 1, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 1 }
{ “_id” : 2, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 2 }
{ “_id” : 3, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 3 }
{ “_id” : 4, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 4 }
{ “_id” : 5, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 5 }
{ “_id” : 6, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 6 }
{ “_id” : 7, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 7 }
{ “_id” : 8, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 8 }
{ “_id” : 9, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 9 }
{ “_id” : 10, “title” : “How do I create manual workload i.e., Bulk inserts to Collection “, ” Iteration no:” : 10 }
[root@myhostname mydb]#