Saturday, November 24, 2018

Hadoop 3.0.1

Step by Step Apache Ambari Installation 

Installation/Configuration/Deployment of Ambari Clusters


Tuesday, October 30, 2018

PotgreSQL Architecture


PostgreSQL Physical Architecture


Shared Memory

hared Buffer

WAL Buffer

PostgreSQL has four process types.

  • Postmaster (Daemon) Process
  • Background Process
  • Backend Process
  • Client Process

Vacuum


Monday, October 29, 2018

MongoDB Sharding (Cluster)

Sharding Definition : 


Sharding in MongoDB is the process of storing data records across multiple machines. It is an approach to meet the demands of data growth. As the data size increases, a single machine might not be sufficient for storing the data nor provides an acceptable read and write throughput. Sharding can solve the problem with horizontal scaling. With sharding, you can add more machines for supporting data growth and the demands of read and write operations.

Sharding Cluster Configuration 




Config Servers − Config servers will store the cluster's metadata and this data contains a mapping of the cluster's data set to the shards. Query router will use this metadata to target operations for specific shards. In any production environment, sharded clusters will have exactly 3 config servers.
 
 Query Routers − Query routers are mainly mongo instances that interface with client applications and will direct operations to the appropriate shard. Query router will process and target the operations to shards and will then return results to the clients. A sharded cluster consists of more than one query router for dividing the client request load and a client will send requests to one query router. Basically, a sharded cluster can have many query routers.
Shards Shards are used for storing data and they provide high availability and data consistency. In the production environment, each shard will be a separate replica set.




Friday, October 26, 2018

MongoDB padding factor (Performance Tuning)

 



If you modify a document in such a way that it grows the document size, there is a chance that MongoDB will have to move the document to some other place in the physical file. There is fixed cost involved in the move and Mongo may decide to grow the size of your data files to accommodate the move.  

To account for this, Mongo maintains a discover on how often documents in each collection grow and then pads some extra space around the document in the physical file so that the document can grow a bit and not have to be moved. This discover is called the padding factor (or paddingFactor).

If the padding factor is higher for a collection, it indicates that the documents are growing.

Update/ReIndex to take care of the performance.




Friday, October 19, 2018

Performance Tuning Considerations

As per Performance Tuning concerns, we have below Components :- 

  • Secondary indexes - If you consider any NoSQL database, it will not support secondary indexes. But Mongodb will support many type of indexes, It can be single field index, multiple fields index, multi key index and index text index. Secondary index will use to use the improve the performance of the database.

  • Replication - You can have maximum 11 replication copies of nodes.
       Primary will act as master.
       Secondary will act as slave

       Normal Configuration with out replication : 
       Read and Write operation will happen in same database.

       Replication Configuration: 
       Primary for read but it can be used for read/write also. But primarily used           for read operation in primary. Secondary server used for write operations.

  • Sharding When ever the collection is having huge volume of data. Entire MongoDB can be shard with that only I/O will be distributed.
            When ever a collection is having huge volume of data we can make a          shard for individual database and sharding can be done for collection. The          rebalancing will happen automatically in Sharding that we have to care .

  • Storage Engine:
      Two types of Engine : WiredTiger,  MMAPv1 
Depending on operation we can choose the storage engine and we can  configure our storage engine. We have option flexibility of tuning in mongoDB

*Log Rotate:  Log-rotate command will be executed, the log file will be backed up and then it will be purged. So that your log-file will become smaller in size. So that process can write faster. When users will do very short transaction randomly, in that case the process taking time to perform an activity to write to log file will also affect the user performing activity in that case we can purge the log-file using log rotate option.



Steps: (logfile rotation activity)

[mdashok@MongoDB log]$ pwd
/data/log
[mdashok@MongoDB log]$

 [mdashok@MongoDB log]$ du -sh mongo.log
4.0K    mongo.log
[mdashok@MongoDB log]$

[mdashok@MongoDB log]$ du -sb monogo.log
1482    monogo.log
[mdashok@MongoDB log]$

# This below command will do the logRotate command activity

MongoDB Enterprise > db.runCommand ({ logRotate : 1 });
{ "ok" : 1 }    ----------------> true
MongoDB Enterprise >


# Logfile backup is generated with extension current date "2018-09-14T21-36-28"

[mdashok@MongoDB log]$ du -sb monogo.log*
1076    monogo.log                      -----------> original logfile
1551    monogo.log.2018-09-14T21-36-28  -----------> backup file
[mdashok@MongoDB log]$ date
Sun Oct 14 07:32:44 IST 2018     
[mdashok@MongoDB log]$

Statement Tuning 

1. Profile
For a mongod instance, the command enables, disables, or configures the Database Profiler. The profiler captures and records data on the performance of write operations, cursors, and database commands on a running mongod instance. If the profiler is disabled, the command sets the slowms and sampleRate for logging slow operations to the diagnostic log.

MongoDB Enterprise > db.getProfilingStatus()
{ "was" : 0, "slowms" : 100, "sampleRate" : 1 }
MongoDB Enterprise > show profile
db.system.profile is empty
Use db.setProfilingLevel(2) will enable profiling
Use db.system.profile.find() to show raw profile entries
MongoDB Enterprise >

MongoDB Enterprise > db.setProfilingLevel(2,50);
{ "was" : 0, "slowms" : 100, "sampleRate" : 1, "ok" : 1 }


MongoDB Enterprise > db.getProfilingStatus();
{ "was" : 2, "slowms" : 50, "sampleRate" : 1 }
MongoDB Enterprise >




MongoDB Enterprise > show profile
db.system.profile is empty
Use db.setProfilingLevel(2) will enable profiling
Use db.system.profile.find() to show raw profile entries
MongoDB Enterprise >


MongoDB Enterprise > db.system.profile.find();
MongoDB Enterprise > db.system.profile.find()
MongoDB Enterprise > db.setProfilingLevel(2);
{ "was" : 0, "slowms" : 50, "sampleRate" : 1, "ok" : 1 }
MongoDB Enterprise > db.system.profile.find();
MongoDB Enterprise > show collections
MongoDB Enterprise > db
test
MongoDB Enterprise >


Profile is saved in capped collection#

MongoDB Enterprise > db.system.profile.stats()
{
        "ns" : "test.system.profile",
        "size" : 749,
        "count" : 1,
        "avgObjSize" : 749,
        "storageSize" : 16384,
        "capped" : true,
        "max" : -1,
        "maxSize" : 1048576,
        "sleepCount" : 0,
        "sleepMS" : 0,
        "wiredTiger" : {
                "metadata" : {
                        "formatVersion" : 1
                },


Drop profile#

MongoDB Enterprise > db.systen.profile.drop()
false
MongoDB Enterprise >

We need to set the profile first.

MongoDB Enterprise > db.getProfilingStatus()
{ "was" : 2, "slowms" : 50, "sampleRate" : 1 }
MongoDB Enterprise >

MongoDB Enterprise > db.setProfilingLevel(0,50);
{ "was" : 2, "slowms" : 50, "sampleRate" : 1, "ok" : 1 }
MongoDB Enterprise >


MongoDB Enterprise > db.system.profile.drop()
true
MongoDB Enterprise >

MongoDB Enterprise > show collections
MongoDB Enterprise >

MongoDB Enterprise > db.createCollection("system.profile", { capped: true,size: 20 * 1024 * 1024} );
{ "ok" : 1 }


MongoDB Enterprise >

{
        "ns" : "test.system.profile",
        "size" : 0,
        "count" : 0,
        "storageSize" : 4096,
        "capped" : true,
        "max" : -1,
        "maxSize" : 20971520,
        "sleepCount" : 0,
        "sleepMS" : 0,
        "wiredTiger" : {
                "metadata" : {
                        "formatVersion" : 1
                },


MongoDB Enterprise >
MongoDB Enterprise > db.getProfilingStatus()
{ "was" : 0, "slowms" : 50, "sampleRate" : 1 }
MongoDB Enterprise >


MongoDB Enterprise > db.system.profile.stats();
{
        "ns" : "test.system.profile",
        "size" : 0,

       "count" : 0, -------------------> no query is exectuted




I )

MongoDB Enterprise > db.system.profile.aggregate ({$group: {_id: "$op", count: {$sum:1}, "max response time" : {$max: "$millis"}, "avg response time": {$avg: "$millis"}}}) ;

{ "_id" : "query", "count" : 2, "max response time" : 0, "avg response time" : 0 }
{ "_id" : "command", "count" : 3, "max response time" : 0, "avg response time" : 0 }
MongoDB Enterprise >


MongoDB Enterprise > db.createCollection("doccollect");
{ "ok" : 1 }
MongoDB Enterprise > for (var i=1; i <=500; i++) db.docccollect.insert ( { SL_No: i})
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise > for (var i=1; i <=500; i++) db.docccollect.insert ( { SL_No: i})
WriteResult({ "nInserted" : 1 })

MongoDB Enterprise > db.docccollect.find().count();
1000
MongoDB Enterprise >

II)

MongoDB Enterprise > db.docccollect.find();
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6a"), "SL_No" : 1 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6b"), "SL_No" : 2 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6c"), "SL_No" : 3 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6d"), "SL_No" : 4 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6e"), "SL_No" : 5 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6f"), "SL_No" : 6 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a70"), "SL_No" : 7 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a71"), "SL_No" : 8 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a72"), "SL_No" : 9 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a73"), "SL_No" : 10 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a74"), "SL_No" : 11 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a75"), "SL_No" : 12 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a76"), "SL_No" : 13 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a77"), "SL_No" : 14 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a78"), "SL_No" : 15 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a79"), "SL_No" : 16 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7a"), "SL_No" : 17 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7b"), "SL_No" : 18 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7c"), "SL_No" : 19 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7d"), "SL_No" : 20 }
Type "it" for more
MongoDB Enterprise > db.system.profile.aggregate ({$group: {_id: "$op", count: {$sum:1}, "max response time" : {$max: "$millis"}, "avg response time": {$avg: "$millis"}}}) ;
{ "_id" : "insert", "count" : 1000, "max response time" : 27, "avg response time" : 0.027 }
{ "_id" : "query", "count" : 4, "max response time" : 0, "avg response time" : 0 }
{ "_id" : "command", "count" : 8, "max response time" : 29, "avg response time" : 3.625 }
MongoDB Enterprise >


MongoDB Enterprise > db.docccollect.find();
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6a"), "SL_No" : 1 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6b"), "SL_No" : 2 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6c"), "SL_No" : 3 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6d"), "SL_No" : 4 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6e"), "SL_No" : 5 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6f"), "SL_No" : 6 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a70"), "SL_No" : 7 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a71"), "SL_No" : 8 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a72"), "SL_No" : 9 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a73"), "SL_No" : 10 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a74"), "SL_No" : 11 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a75"), "SL_No" : 12 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a76"), "SL_No" : 13 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a77"), "SL_No" : 14 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a78"), "SL_No" : 15 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a79"), "SL_No" : 16 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7a"), "SL_No" : 17 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7b"), "SL_No" : 18 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7c"), "SL_No" : 19 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7d"), "SL_No" : 20 }
Type "it" for more
MongoDB Enterprise > db.docccollect.find();
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6a"), "SL_No" : 1 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6b"), "SL_No" : 2 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6c"), "SL_No" : 3 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6d"), "SL_No" : 4 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6e"), "SL_No" : 5 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6f"), "SL_No" : 6 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a70"), "SL_No" : 7 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a71"), "SL_No" : 8 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a72"), "SL_No" : 9 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a73"), "SL_No" : 10 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a74"), "SL_No" : 11 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a75"), "SL_No" : 12 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a76"), "SL_No" : 13 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a77"), "SL_No" : 14 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a78"), "SL_No" : 15 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a79"), "SL_No" : 16 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7a"), "SL_No" : 17 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7b"), "SL_No" : 18 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7c"), "SL_No" : 19 }
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7d"), "SL_No" : 20 }
Type "it" for more

MongoDB Enterprise > db.system.profile.aggregate ({$group: {_id: "$op", count: {$sum:1}, "max response time" : {$max: "$millis"}, "avg response time": {$avg: "$millis"}}}) ;

{ "_id" : "insert", "count" : 1000, "max response time" : 27, "avg response time" : 0.027 }
{ "_id" : "query", "count" : 7, "max response time" : 0, "avg response time" : 0 }
{ "_id" : "command", "count" : 9, "max response time" : 29, "avg response time" : 3.4444444444444446 }
MongoDB Enterprise >

Total response time is 0 . Average response time is 0

III)

MongoDB Enterprise > db.docccollect.find ( { "SL_No" : 20 } );
{ "_id" : ObjectId("5bc2b77dec41e927c4064a7d"), "SL_No" : 20 }
{ "_id" : ObjectId("5bc2b7baec41e927c4064c71"), "SL_No" : 20 }
MongoDB Enterprise > db.docccollect.find ( { "SL_No" : 9 } );
{ "_id" : ObjectId("5bc2b77dec41e927c4064a72"), "SL_No" : 9 }
{ "_id" : ObjectId("5bc2b7baec41e927c4064c66"), "SL_No" : 9 }
MongoDB Enterprise > db.docccollect.find ( { "SL_No" : 6 } );
{ "_id" : ObjectId("5bc2b77dec41e927c4064a6f"), "SL_No" : 6 }
{ "_id" : ObjectId("5bc2b7baec41e927c4064c63"), "SL_No" : 6 }

MongoDB Enterprise > db.system.profile.aggregate ({$group: {_id: "$op", count: {$sum:1}, "max response time" : {$max: "$millis"}, "avg response time": {$avg: "$millis"}}}) ;
{ "_id" : "insert", "count" : 1000, "max response time" : 27, "avg response time" : 0.027 }
{ "_id" : "query", "count" : 19, "max response time" : 0, "avg response time" : 0 }
{ "_id" : "command", "count" : 10, "max response time" : 29, "avg response time" : 3.3 }
MongoDB Enterprise >




Current number of document in the profile

MongoDB Enterprise > db.system.profile.count();
1030
MongoDB Enterprise >


Slow performing query

The below query will show the sql query which is greater than 10milli seconds .

MongoDB Enterprise > db.system.profile.find( { "millis" : { $gt:10}} )

{ "op" : "command", "ns" : "admin.doccollect", "command" : { "create" : "doccollect", "$db" : "admin" }, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1), "w" : NumberLong(1) } }, "Database" : { "acquireCount" : { "W" : NumberLong(1) } } }, "responseLength" : 38, "protocol" : "op_msg", "millis" : 29, "ts" : ISODate("2018-10-14T03:26:48.352Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "insert", "ns" : "admin.docccollect", "command" : { "insert" : "docccollect", "ordered" : true, "$db" : "admin" }, "ninserted" : 1, "keysInserted" : 1, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(3), "w" : NumberLong(3) } }, "Database" : { "acquireCount" : { "W" : NumberLong(3) } }, "Collection" : { "acquireCount" : { "w" : NumberLong(2) } } }, "responseLength" : 45, "protocol" : "op_msg", "millis" : 27, "ts" : ISODate("2018-10-14T03:26:53.671Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
MongoDB Enterprise >



MongoDB Enterprise > db.system.profile.find().sort( { millis: -1}). limit(1)

{ "op" : "command", "ns" : "admin.doccollect", "command" : { "create" : "doccollect", "$db" : "admin" }, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1), "w" : NumberLong(1) } }, "Database" : { "acquireCount" : { "W" : NumberLong(1) } } }, "responseLength" : 38, "protocol" : "op_msg", "millis" : 29, "ts" : ISODate("2018-10-14T03:26:48.352Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
MongoDB Enterprise >




Listing Top 10 slow queries :


MongoDB Enterprise > db.system.profile.find().sort( { natural:-1}). limit(10);

{ "op" : "command", "ns" : "admin.system.profile", "command" : { "count" : "system.profile", "query" : {  }, "fields" : {  }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 0, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 45, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COUNT", "execStats" : { "stage" : "COUNT", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 1, "advanced" : 0, "needTime" : 0, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "nCounted" : 0, "nSkipped" : 0 }, "ts" : ISODate("2018-10-14T02:28:59.248Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "command", "ns" : "admin.system.profile", "command" : { "count" : "system.profile", "query" : {  }, "fields" : {  }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 0, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 45, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COUNT", "execStats" : { "stage" : "COUNT", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 1, "advanced" : 0, "needTime" : 0, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "nCounted" : 1, "nSkipped" : 0 }, "ts" : ISODate("2018-10-14T02:29:37.614Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.system.profile", "command" : { "find" : "system.profile", "filter" : { "millis" : { "$gt" : 0 } }, "limit" : 5, "singleBatch" : false, "sort" : { "$natural" : -1 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 2, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 109, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COLLSCAN", "execStats" : { "stage" : "LIMIT", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 4, "advanced" : 0, "needTime" : 3, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "limitAmount" : 5, "inputStage" : { "stage" : "COLLSCAN", "filter" : { "millis" : { "$gt" : 0 } }, "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 4, "advanced" : 0, "needTime" : 3, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "direction" : "backward", "docsExamined" : 2 } }, "ts" : ISODate("2018-10-14T02:29:37.615Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "command", "ns" : "admin.system.profile", "command" : { "count" : "system.profile", "query" : {  }, "fields" : {  }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 0, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 45, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COUNT", "execStats" : { "stage" : "COUNT", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 1, "advanced" : 0, "needTime" : 0, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "nCounted" : 3, "nSkipped" : 0 }, "ts" : ISODate("2018-10-14T02:29:51.799Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.system.profile", "command" : { "find" : "system.profile", "filter" : { "millis" : { "$gt" : 0 } }, "limit" : 5, "singleBatch" : false, "sort" : { "$natural" : -1 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 4, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 109, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COLLSCAN", "execStats" : { "stage" : "LIMIT", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 6, "advanced" : 0, "needTime" : 5, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "limitAmount" : 5, "inputStage" : { "stage" : "COLLSCAN", "filter" : { "millis" : { "$gt" : 0 } }, "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 6, "advanced" : 0, "needTime" : 5, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0, "direction" : "backward", "docsExamined" : 4 } }, "ts" : ISODate("2018-10-14T02:29:51.800Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "command", "ns" : "admin.system.profile", "command" : { "aggregate" : "system.profile", "pipeline" : [ { "$group" : { "_id" : "$op", "count" : { "$sum" : 1 }, "max response time" : { "$max" : "$millis" }, "avg response time" : { "$avg" : "$millis" } } } ], "cursor" : {  }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 5, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 2, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(2) } }, "Database" : { "acquireCount" : { "r" : NumberLong(2) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(2) } } }, "responseLength" : 287, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COLLSCAN", "ts" : ISODate("2018-10-14T03:22:26.783Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "command", "ns" : "admin.doccollect", "command" : { "create" : "doccollect", "$db" : "admin" }, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1), "w" : NumberLong(1) } }, "Database" : { "acquireCount" : { "W" : NumberLong(1) } } }, "responseLength" : 38, "protocol" : "op_msg", "millis" : 29, "ts" : ISODate("2018-10-14T03:26:48.352Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "insert", "ns" : "admin.docccollect", "command" : { "insert" : "docccollect", "ordered" : true, "$db" : "admin" }, "ninserted" : 1, "keysInserted" : 1, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(3), "w" : NumberLong(3) } }, "Database" : { "acquireCount" : { "W" : NumberLong(3) } }, "Collection" : { "acquireCount" : { "w" : NumberLong(2) } } }, "responseLength" : 45, "protocol" : "op_msg", "millis" : 27, "ts" : ISODate("2018-10-14T03:26:53.671Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "insert", "ns" : "admin.docccollect", "command" : { "insert" : "docccollect", "ordered" : true, "$db" : "admin" }, "ninserted" : 1, "keysInserted" : 1, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1), "w" : NumberLong(1) } }, "Database" : { "acquireCount" : { "W" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "w" : NumberLong(1) } } }, "responseLength" : 45, "protocol" : "op_msg", "millis" : 0, "ts" : ISODate("2018-10-14T03:26:53.672Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "insert", "ns" : "admin.docccollect", "command" : { "insert" : "docccollect", "ordered" : true, "$db" : "admin" }, "ninserted" : 1, "keysInserted" : 1, "numYield" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1), "w" : NumberLong(1) } }, "Database" : { "acquireCount" : { "W" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "w" : NumberLong(1) } } }, "responseLength" : 45, "protocol" : "op_msg", "millis" : 0, "ts" : ISODate("2018-10-14T03:26:53.673Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
MongoDB Enterprise >

List only queries

MongoDB Enterprise > db.system.profile.find().sort ( { $natural: -1}). limit(10)

{ "op" : "command", "ns" : "admin.system.profile", "command" : { "aggregate" : "system.profile", "pipeline" : [ { "$group" : { "_id" : "$op", "count" : { "$sum" : 1 }, "max response time" : { "$max" : "$millis" }, "avg response time" : { "$avg" : "$millis" } } } ], "cursor" : {  }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 1029, "cursorExhausted" : true, "numYield" : 8, "nreturned" : 3, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(10) } }, "Database" : { "acquireCount" : { "r" : NumberLong(10) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(10) } } }, "responseLength" : 376, "protocol" : "op_msg", "millis" : 1, "planSummary" : "COLLSCAN", "ts" : ISODate("2018-10-14T03:35:09.032Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.docccollect", "command" : { "find" : "docccollect", "filter" : { "SL_No" : 6 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 1000, "cursorExhausted" : true, "numYield" : 7, "nreturned" : 2, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(8) } }, "Database" : { "acquireCount" : { "r" : NumberLong(8) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(8) } } }, "responseLength" : 186, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COLLSCAN", "execStats" : { "stage" : "COLLSCAN", "filter" : { "SL_No" : { "$eq" : 6 } }, "nReturned" : 2, "executionTimeMillisEstimate" : 0, "works" : 1002, "advanced" : 2, "needTime" : 999, "needYield" : 0, "saveState" : 7, "restoreState" : 7, "isEOF" : 1, "invalidates" : 0, "direction" : "forward", "docsExamined" : 1000 }, "ts" : ISODate("2018-10-14T03:35:02.745Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.docccollect", "command" : { "find" : "docccollect", "filter" : { "SL_No" : 9 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 1000, "cursorExhausted" : true, "numYield" : 7, "nreturned" : 2, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(8) } }, "Database" : { "acquireCount" : { "r" : NumberLong(8) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(8) } } }, "responseLength" : 186, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COLLSCAN", "execStats" : { "stage" : "COLLSCAN", "filter" : { "SL_No" : { "$eq" : 9 } }, "nReturned" : 2, "executionTimeMillisEstimate" : 0, "works" : 1002, "advanced" : 2, "needTime" : 999, "needYield" : 0, "saveState" : 7, "restoreState" : 7, "isEOF" : 1, "invalidates" : 0, "direction" : "forward", "docsExamined" : 1000 }, "ts" : ISODate("2018-10-14T03:34:56.815Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.docccollect", "command" : { "find" : "docccollect", "filter" : { "SL_No" : 20 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 1000, "cursorExhausted" : true, "numYield" : 7, "nreturned" : 2, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(8) } }, "Database" : { "acquireCount" : { "r" : NumberLong(8) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(8) } } }, "responseLength" : 186, "protocol" : "op_msg", "millis" : 0, "planSummary" : "COLLSCAN", "execStats" : { "stage" : "COLLSCAN", "filter" : { "SL_No" : { "$eq" : 20 } }, "nReturned" : 2, "executionTimeMillisEstimate" : 0, "works" : 1002, "advanced" : 2, "needTime" : 999, "needYield" : 0, "saveState" : 7, "restoreState" : 7, "isEOF" : 1, "invalidates" : 0, "direction" : "forward", "docsExamined" : 1000 }, "ts" : ISODate("2018-10-14T03:34:45.520Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.docccolect", "command" : { "find" : "docccolect", "filter" : { " SL_No " : 17 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 0, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 105, "protocol" : "op_msg", "millis" : 0, "planSummary" : "EOF", "execStats" : { "stage" : "EOF", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 0, "advanced" : 0, "needTime" : 0, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0 }, "ts" : ISODate("2018-10-14T03:34:20.706Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.docccolect", "command" : { "find" : "docccolect", "filter" : { " SL_No " : 1 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 0, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 105, "protocol" : "op_msg", "millis" : 0, "planSummary" : "EOF", "execStats" : { "stage" : "EOF", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 0, "advanced" : 0, "needTime" : 0, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0 }, "ts" : ISODate("2018-10-14T03:34:11.094Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.docccolect", "command" : { "find" : "docccolect", "filter" : { "SL_No" : 1 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 0, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 105, "protocol" : "op_msg", "millis" : 0, "planSummary" : "EOF", "execStats" : { "stage" : "EOF", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 0, "advanced" : 0, "needTime" : 0, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0 }, "ts" : ISODate("2018-10-14T03:34:06.717Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.docccolect", "command" : { "find" : "docccolect", "filter" : { "SL_No" : 1 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 0, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 105, "protocol" : "op_msg", "millis" : 0, "planSummary" : "EOF", "execStats" : { "stage" : "EOF", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 0, "advanced" : 0, "needTime" : 0, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0 }, "ts" : ISODate("2018-10-14T03:33:58.759Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.docccolect", "command" : { "find" : "docccolect", "filter" : { "SL_No" : 8 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 0, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 105, "protocol" : "op_msg", "millis" : 0, "planSummary" : "EOF", "execStats" : { "stage" : "EOF", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 0, "advanced" : 0, "needTime" : 0, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0 }, "ts" : ISODate("2018-10-14T03:33:53.087Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }
{ "op" : "query", "ns" : "admin.docccolect", "command" : { "find" : "docccolect", "filter" : { "SL_No" : 8 }, "$db" : "admin" }, "keysExamined" : 0, "docsExamined" : 0, "cursorExhausted" : true, "numYield" : 0, "nreturned" : 0, "locks" : { "Global" : { "acquireCount" : { "r" : NumberLong(1) } }, "Database" : { "acquireCount" : { "r" : NumberLong(1) } }, "Collection" : { "acquireCount" : { "r" : NumberLong(1) } } }, "responseLength" : 105, "protocol" : "op_msg", "millis" : 0, "planSummary" : "EOF", "execStats" : { "stage" : "EOF", "nReturned" : 0, "executionTimeMillisEstimate" : 0, "works" : 0, "advanced" : 0, "needTime" : 0, "needYield" : 0, "saveState" : 0, "restoreState" : 0, "isEOF" : 1, "invalidates" : 0 }, "ts" : ISODate("2018-10-14T03:33:25.562Z"), "client" : "127.0.0.1", "appName" : "MongoDB Shell", "allUsers" : [ ], "user" : "" }

MongoDB Enterprise >


2. Explain



Sunday, October 14, 2018

Upload a file in S3 bucket using awscli command


Upload files in S3 bucket using awscli command line utility

Steps:
1.   Install awscli command utility in windows OS

AWSCLI64PY3.msi  (windows_64bit os)

2.   You must mention the path of the aws bin folder in %PATH% variable set

C:\Program Files\Amazon\AWSCLI\bin;

3.   Now check the aws version

C:\>AWS --version
aws-cli/1.16.33 Python/3.6.0 Windows/7 botocore/1.12.23

C:\Users\mkumar8>aws s3 ls
2018-10-15 16:06:50 ashokbc
Directory of C:\Users\mkumar8\Documents\aws work
10/15/2018  04:11 PM    <DIR>          .
10/15/2018  04:11 PM    <DIR>          ..
03/07/2018  05:17 PM           150,621 car1.jpeg
10/15/2018  04:11 PM                90 rootkey.csv
               2 File(s)        150,711 bytes
               2 Dir(s)  52,962,304,000 bytes free

C:\Users\mkumar8\Documents\aws work>aws s3 cp car1.jpeg s3://ashokbc/
upload: .\car1.jpeg to s3://ashokbc/car1.jpeg
C:\Users\mkumar8\Documents\aws work>

4.   List the uploaded files from s3 bucket:

C:\Users\mkumar8\Documents\aws work>aws s3 ls s3://ashokbc/
2018-10-15 16:20:42     150621 car1.jpeg
2018-10-15 16:22:48         90 rootkey.csv

C:\Users\mkumar8\Documents\aws work>

5.   Delete the rootkey.csv file from bucket
C:\Users\mkumar8\Documents\aws work>aws s3 rm s3://ashokbc/rootkey.csv
delete: s3://ashokbc/rootkey.csv

C:\Users\mkumar8\Documents\aws work>

6.   Synchronization the local folder with aws s3 bucket : ashokbc

C:\Users\mkumar8\Documents\aws work>aws s3 sync . s3://ashokbc/
upload: .\mountain.jpg to s3://ashokbc/mountain.jpg
C:\Users\mkumar8\Documents\aws work>


















Thursday, October 04, 2018

MongoDB Backup and Recovery


MONGODUMP


To back up whole mongoDB server backup



[mdashok@nosqlDB ~]$ mongodump -h localhost:27017

2018-09-30T17:45:22.873+0530    writing admin.system.users to
2018-09-30T17:45:22.874+0530    done dumping admin.system.users (1 document)
2018-09-30T17:45:22.874+0530    writing admin.system.version to
2018-09-30T17:45:22.875+0530    done dumping admin.system.version (2 documents)
2018-09-30T17:45:22.875+0530    writing ashokdb.users to
2018-09-30T17:45:22.875+0530    writing ashokdb.doccollect to
2018-09-30T17:45:22.875+0530    writing ashokdb.doccollect4 to
2018-09-30T17:45:22.876+0530    writing ashokdb.mycoll to
2018-09-30T17:45:22.878+0530    done dumping ashokdb.doccollect (4 documents)
2018-09-30T17:45:22.878+0530    done dumping ashokdb.users (40 documents)
2018-09-30T17:45:22.879+0530    done dumping ashokdb.mycoll (0 documents)
2018-09-30T17:45:22.881+0530    done dumping ashokdb.doccollect4 (0 documents)




[mdashok@nosqlDB ashokdb]$ ls -ltr
total 24
-rw-r--r--. 1 mdashok mongodb  127 Sep 30 17:45 users.metadata.json
-rw-r--r--. 1 mdashok mongodb  155 Sep 30 17:45 mycoll.metadata.json
-rw-r--r--. 1 mdashok mongodb  132 Sep 30 17:45 doccollect.metadata.json
-rw-r--r--. 1 mdashok mongodb  160 Sep 30 17:45 doccollect4.metadata.json
-rw-r--r--. 1 mdashok mongodb    0 Sep 30 17:45 doccollect4.bson
-rw-r--r--. 1 mdashok mongodb    0 Sep 30 17:45 mycoll.bson
-rw-r--r--. 1 mdashok mongodb 3622 Sep 30 17:45 users.bson
-rw-r--r--. 1 mdashok mongodb  699 Sep 30 17:45 doccollect.bson
[mdashok@nosqlDB ashokdb]$



#Backup a Whole Database


MongoDB Enterprise > use ashokdb
switched to db ashokdb
MongoDB Enterprise > db.stats().dataSize;
4321
MongoDB Enterprise >




[mdashok@nosqlDB ~]$ date
Sun Sep 30 17:49:58 IST 2018

[mdashok@nosqlDB ~]$ mongodump -d ashokdb -o mongodb_dump

2018-09-30T17:50:12.100+0530    writing ashokdb.users to
2018-09-30T17:50:12.118+0530    writing ashokdb.doccollect to
2018-09-30T17:50:12.118+0530    writing ashokdb.doccollect4 to
2018-09-30T17:50:12.118+0530    writing ashokdb.mycoll to
2018-09-30T17:50:12.120+0530    done dumping ashokdb.users (40 documents)
2018-09-30T17:50:12.120+0530    done dumping ashokdb.doccollect (4 documents)
2018-09-30T17:50:12.121+0530    done dumping ashokdb.mycoll (0 documents)
2018-09-30T17:50:12.121+0530    done dumping ashokdb.doccollect4 (0 documents)
[mdashok@nosqlDB ~]$



yis/mdashok/mongodb_dump
[mdashok@nosqlDB mongodb_dump]$ ll
total 4
drwxr-xr-x. 2 mdashok mongodb 4096 Sep 30 17:50 ashokdb


[mdashok@nosqlDB mongodb_dump]$

# Backup a Single Collection


Backup collections from database

[mdashok@nosqlDB ~]$ mongodump -d ashokdb -o mongodbBackup --collection mycoll

2018-09-30T18:05:39.365+0530    writing ashokdb.mycoll to
2018-09-30T18:05:39.365+0530    done dumping ashokdb.mycoll (0 documents)

[mdashok@nosqlDB ~]$ mongodump -d ashokdb -o mongodbBackup --collection users

2018-09-30T18:05:50.688+0530    writing ashokdb.users to
2018-09-30T18:05:50.689+0530    done dumping ashokdb.users (40 documents)
[mdashok@nosqlDB ~]$

/yis/mdashok/mongodbBackup/ashokdb
[mdashok@nosqlDB ashokdb]$ ls -ltr
total 12
-rw-r--r--. 1 mdashok mongodb  155 Sep 30 18:05 mycoll.metadata.json
-rw-r--r--. 1 mdashok mongodb    0 Sep 30 18:05 mycoll.bson
-rw-r--r--. 1 mdashok mongodb  127 Sep 30 18:05 users.metadata.json
-rw-r--r--. 1 mdashok mongodb 3622 Sep 30 18:05 users.bson
[mdashok@nosqlDB ashokdb]$


# Take a backup of database with -excludeCollection

[mdashok@nosqlDB ~]$ mongodump -d ashokdb -o mongodbBackup --excludeCollection=doccollect4

2018-09-30T19:17:48.898+0530    writing ashokdb.users to
2018-09-30T19:17:48.898+0530    writing ashokdb.doccollect to
2018-09-30T19:17:48.898+0530    writing ashokdb.mycoll to
2018-09-30T19:17:48.900+0530    done dumping ashokdb.users (40 documents)
2018-09-30T19:17:48.901+0530    done dumping ashokdb.doccollect (4 documents)
2018-09-30T19:17:48.901+0530    done dumping ashokdb.mycoll (0 documents)

[mdashok@nosqlDB ~]$ cd mongodbBackup/ashokdb
[mdashok@nosqlDB ashokdb]$ ls -ltr
total 20
-rw-r--r--. 1 mdashok mongodb  127 Sep 30 19:17 users.metadata.json
-rw-r--r--. 1 mdashok mongodb  155 Sep 30 19:17 mycoll.metadata.json
-rw-r--r--. 1 mdashok mongodb    0 Sep 30 19:17 mycoll.bson
-rw-r--r--. 1 mdashok mongodb  132 Sep 30 19:17 doccollect.metadata.json
-rw-r--r--. 1 mdashok mongodb 3622 Sep 30 19:17 users.bson
-rw-r--r--. 1 mdashok mongodb  699 Sep 30 19:17 doccollect.bson
[mdashok@nosqlDB ashokdb]$

# Take a collection backup with excludeCollectionWithPrefix option:

[mdashok@nosqlDB ~]$ mongodump -d ashokdb -o mongodbBackup --excludeCollectionsWithPrefix=d

2018-09-30T19:20:49.703+0530    writing ashokdb.users to
2018-09-30T19:20:49.704+0530    writing ashokdb.mycoll to
2018-09-30T19:20:49.706+0530    done dumping ashokdb.users (40 documents)
2018-09-30T19:20:49.707+0530    done dumping ashokdb.mycoll (0 documents)

We excluded the collection, which name starts with "d" prefix

[mdashok@nosqlDB mongodbBackup]$ cd ashokdb
[mdashok@nosqlDB ashokdb]$ ls -ltr
total 12
-rw-r--r--. 1 mdashok mongodb  127 Sep 30 19:20 users.metadata.json
-rw-r--r--. 1 mdashok mongodb  155 Sep 30 19:20 mycoll.metadata.json
-rw-r--r--. 1 mdashok mongodb    0 Sep 30 19:20 mycoll.bson
-rw-r--r--. 1 mdashok mongodb 3622 Sep 30 19:20 users.bson
[mdashok@nosqlDB ashokdb]$

#To check database version before starting mongodb 


[mdashok@nosqlDB mongodbBackup]$ mongodump -d ashokdb -o mongodbBackup --version

mongodump version: r4.0.0
git version: 3b07af3d4f471ae89e8186d33bbb1d5259597d51
Go version: go1.8.5
   os: linux
   arch: amd64
   compiler: gc
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
[mdashok@nosqlDB mongodbBackup]$


#Take a Backup of whole server from Primary of  Replication servers

$mongodump -h localhost:6666 -o /usr/repl_server_bkpdump/ 
-vvvv

















#server backup location









#Restore a collection from primary node:

Restore a collection Failover_test_doc from FOver_Test backup directory from primary server (port : 6666)

$mongorestore -h localhost:6666 -d FOver_Test repl_server_bkpdump/FOver_Test/Failover_test_doc.bson -c Failover_test_doc -vvvv








Backup a database using specific user who is having access to take a backup.


[mdashok@MongoDB ~]$ mongodump --db ashokdb -u "reportsUser" -p "user123" --out ReportsUserbkp

2018-10-04T17:51:45.193+0530    writing ashokdb.users to
2018-10-04T17:51:45.194+0530    writing ashokdb.doccollect to
2018-10-04T17:51:45.195+0530    writing ashokdb.Today to
2018-10-04T17:51:45.195+0530    writing ashokdb.doccollect4 to
2018-10-04T17:51:45.310+0530    done dumping ashokdb.users (40 documents)
2018-10-04T17:51:45.310+0530    writing ashokdb.mycoll to
2018-10-04T17:51:45.332+0530    done dumping ashokdb.doccollect (5 documents)
2018-10-04T17:51:45.332+0530    writing ashokdb.indx-doc1 to
2018-10-04T17:51:45.364+0530    done dumping ashokdb.Today (1 document)
2018-10-04T17:51:45.399+0530    done dumping ashokdb.doccollect4 (0 documents)
2018-10-04T17:51:45.417+0530    done dumping ashokdb.mycoll (0 documents)
2018-10-04T17:51:45.420+0530    done dumping ashokdb.indx-doc1 (0 documents)


[mdashok@MongoDB ~]$

#Backup Users and Roles:

mdashok@MongoDB ~]$ mongodump --db ashokdb -h localhost:27017 -u "reportsUser" -p "user123" --out Backuproles --dumpDbUsersAndRoles -vvvvv

2018-10-04T17:57:14.169+0530    will listen for SIGTERM, SIGINT, and SIGKILL
2018-10-04T17:57:14.339+0530    using auth schema version 5
2018-10-04T17:57:14.424+0530    enqueued collection 'ashokdb.doccollect4'
2018-10-04T17:57:14.456+0530    enqueued collection 'ashokdb.mycoll'
2018-10-04T17:57:14.493+0530    enqueued collection 'ashokdb.indx-doc1'
2018-10-04T17:57:14.533+0530    enqueued collection 'ashokdb.users'
2018-10-04T17:57:14.573+0530    enqueued collection 'ashokdb.doccollect'
2018-10-04T17:57:14.616+0530    enqueued collection 'ashokdb.Today'
2018-10-04T17:57:14.616+0530    enqueued collection 'ashokdb.$admin.system.users'
2018-10-04T17:57:14.616+0530    enqueued collection 'ashokdb.$admin.system.roles'
2018-10-04T17:57:14.616+0530    enqueued collection 'ashokdb.$admin.system.version'
2018-10-04T17:57:14.616+0530    dump phase I: metadata, indexes, users, roles, version
2018-10-04T17:57:14.616+0530            reading indexes for `ashokdb.indx-doc1`
2018-10-04T17:57:14.659+0530            reading indexes for `ashokdb.users`
2018-10-04T17:57:14.704+0530            reading indexes for `ashokdb.doccollect`
2018-10-04T17:57:14.737+0530            reading indexes for `ashokdb.Today`
2018-10-04T17:57:14.778+0530            reading indexes for `ashokdb.doccollect4`
2018-10-04T17:57:14.814+0530            reading indexes for `ashokdb.mycoll`
2018-10-04T17:57:14.851+0530    dumping users and roles for ashokdb
2018-10-04T17:57:14.890+0530    counted 1 document in ashokdb.$admin.system.users
2018-10-04T17:57:14.891+0530    counted 0 documents in ashokdb.$admin.system.roles
2018-10-04T17:57:14.892+0530    counted 2 documents in ashokdb.$admin.system.version
2018-10-04T17:57:14.892+0530    dump phase II: regular collections
2018-10-04T17:57:14.892+0530    finalizing intent manager with longest task first prioritizer
2018-10-04T17:57:14.892+0530    dumping up to 4 collections in parallel
2018-10-04T17:57:14.892+0530    starting dump routine with id=3
2018-10-04T17:57:14.893+0530    writing ashokdb.users to
2018-10-04T17:57:14.893+0530    starting dump routine with id=0
2018-10-04T17:57:14.893+0530    writing ashokdb.doccollect to
2018-10-04T17:57:14.894+0530    starting dump routine with id=1
2018-10-04T17:57:14.894+0530    writing ashokdb.Today to
2018-10-04T17:57:14.895+0530    starting dump routine with id=2
2018-10-04T17:57:14.895+0530    writing ashokdb.doccollect4 to
2018-10-04T17:57:14.956+0530    counted 5 documents in ashokdb.doccollect
2018-10-04T17:57:14.970+0530    done dumping ashokdb.doccollect (5 documents)
2018-10-04T17:57:14.970+0530    writing ashokdb.mycoll to
2018-10-04T17:57:14.977+0530    counted 40 documents in ashokdb.users
2018-10-04T17:57:14.977+0530    done dumping ashokdb.users (40 documents)
2018-10-04T17:57:14.977+0530    writing ashokdb.indx-doc1 to
2018-10-04T17:57:15.038+0530    counted 0 documents in ashokdb.doccollect4
2018-10-04T17:57:15.086+0530    counted 0 documents in ashokdb.mycoll
2018-10-04T17:57:15.087+0530    done dumping ashokdb.doccollect4 (0 documents)
2018-10-04T17:57:15.087+0530    ending dump routine with id=2, no more work to do
2018-10-04T17:57:15.103+0530    counted 0 documents in ashokdb.indx-doc1
2018-10-04T17:57:15.116+0530    done dumping ashokdb.mycoll (0 documents)
2018-10-04T17:57:15.116+0530    ending dump routine with id=0, no more work to do
2018-10-04T17:57:15.116+0530    done dumping ashokdb.indx-doc1 (0 documents)
2018-10-04T17:57:15.116+0530    ending dump routine with id=3, no more work to do
2018-10-04T17:57:15.117+0530    counted 1 document in ashokdb.Today
2018-10-04T17:57:15.117+0530    done dumping ashokdb.Today (1 document)
2018-10-04T17:57:15.117+0530    ending dump routine with id=1, no more work to do
2018-10-04T17:57:15.117+0530    dump phase III: the oplog
2018-10-04T17:57:15.117+0530    finishing dump
[mdashok@MongoDB ~]$

 

#Backup a collection by Filtering Data

[mdashok@MongoDB ~]$ mongodump --db ashokdb -h localhost:27017 --out Backup_filter_data_dump --collection doccollect --query '{by:"ashok"}' -vvvv

2018-10-04T17:21:27.790+0530    will listen for SIGTERM, SIGINT, and SIGKILL
2018-10-04T17:21:27.792+0530    enqueued collection 'ashokdb.doccollect'
2018-10-04T17:21:27.792+0530    dump phase I: metadata, indexes, users, roles, version
2018-10-04T17:21:27.792+0530            reading indexes for `ashokdb.doccollect`
2018-10-04T17:21:27.793+0530    dump phase II: regular collections
2018-10-04T17:21:27.793+0530    finalizing intent manager with legacy prioritizer
2018-10-04T17:21:27.793+0530    dumping up to 1 collections in parallel
2018-10-04T17:21:27.793+0530    starting dump routine with id=0
2018-10-04T17:21:27.793+0530    writing ashokdb.doccollect to
2018-10-04T17:21:27.793+0530    not counting query on ashokdb.doccollect
2018-10-04T17:21:27.794+0530    done dumping ashokdb.doccollect (2 documents)
2018-10-04T17:21:27.794+0530    ending dump routine with id=0, no more work to do
2018-10-04T17:21:27.794+0530    dump phase III: the oplog
2018-10-04T17:21:27.794+0530    finishing dump
[mdashok@MongoDB ~]$



MONGORESTORE

Restore Section


Restore Whole Database



First drop a database name : ashokdb

MongoDB Enterprise > show dbs
admin    0.000GB
ashokdb  0.000GB
config   0.000GB
local    0.000GB
MongoDB Enterprise > use ashokdb
switched to db ashokdb
MongoDB Enterprise > db
ashokdb
MongoDB Enterprise > db.dropDatabase()
{ "dropped" : "ashokdb", "ok" : 1 }
MongoDB Enterprise > show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
MongoDB Enterprise >


Now restore ashokdb database from backup

[mdashok@nosqlDB mongodb_dump]$ pwd
/yis/mdashok/mongodb_dump
[mdashok@nosqlDB mongodb_dump]$ ll
total 4
drwxr-xr-x. 2 mdashok mongodb 4096 Sep 30 17:50 ashokdb
[mdashok@nosqlDB mongodb_dump]$

[mdashok@nosqlDB ashokdb]$ pwd
/yis/mdashok/mongodb_dump/ashokdb
[mdashok@nosqlDB ashokdb]$ cd ..

backup location :-

[mdashok@nosqlDB mongodb_dump]$ pwd
/yis/mdashok/mongodb_dump
[mdashok@nosqlDB mongodb_dump]$ ll
total 4
drwxr-xr-x. 2 mdashok mongodb 4096 Sep 30 17:50 ashokdb

[mdashok@nosqlDB mongodb_dump]$ mongorestore -d ashokdb /yis/mdashok/mongodb_dump/ashokdb

2018-09-30T18:10:13.892+0530    the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead
2018-09-30T18:10:13.892+0530    building a list of collections to restore from /yis/mdashok/mongodb_dump/ashokdb dir
2018-09-30T18:10:13.893+0530    reading metadata for ashokdb.users from /yis/mdashok/mongodb_dump/ashokdb/users.metadata.json
2018-09-30T18:10:13.943+0530    reading metadata for ashokdb.doccollect from /yis/mdashok/mongodb_dump/ashokdb/doccollect.metadata.json
2018-09-30T18:10:13.944+0530    reading metadata for ashokdb.doccollect4 from /yis/mdashok/mongodb_dump/ashokdb/doccollect4.metadata.json
2018-09-30T18:10:13.944+0530    reading metadata for ashokdb.mycoll from /yis/mdashok/mongodb_dump/ashokdb/mycoll.metadata.json
2018-09-30T18:10:13.945+0530    restoring ashokdb.users from /yis/mdashok/mongodb_dump/ashokdb/users.bson
2018-09-30T18:10:13.989+0530    restoring ashokdb.doccollect from /yis/mdashok/mongodb_dump/ashokdb/doccollect.bson
2018-09-30T18:10:14.025+0530    restoring ashokdb.doccollect4 from /yis/mdashok/mongodb_dump/ashokdb/doccollect4.bson
2018-09-30T18:10:14.027+0530    no indexes to restore
2018-09-30T18:10:14.027+0530    finished restoring ashokdb.doccollect4 (0 documents)
2018-09-30T18:10:14.061+0530    no indexes to restore
2018-09-30T18:10:14.061+0530    finished restoring ashokdb.doccollect (4 documents)
2018-09-30T18:10:14.081+0530    no indexes to restore
2018-09-30T18:10:14.081+0530    finished restoring ashokdb.users (40 documents)
2018-09-30T18:10:14.081+0530    restoring ashokdb.mycoll from /yis/mdashok/mongodb_dump/ashokdb/mycoll.bson
2018-09-30T18:10:14.082+0530    no indexes to restore
2018-09-30T18:10:14.082+0530    finished restoring ashokdb.mycoll (0 documents)
2018-09-30T18:10:14.082+0530    done
[mdashok@nosqlDB mongodb_dump]$

now check the db:

MongoDB Enterprise > show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
MongoDB Enterprise >
MongoDB Enterprise >
MongoDB Enterprise >
MongoDB Enterprise > show dbs
admin    0.000GB
ashokdb  0.000GB
config   0.000GB
local    0.000GB
MongoDB Enterprise > use ashokdb
switched to db ashokdb
MongoDB Enterprise > show collections
doccollect
doccollect4
mycoll
users
MongoDB Enterprise >


Restore Single Collection



MongoDB Enterprise > show collections
doccollect
doccollect4
mycoll
users

drop docollect4

MongoDB Enterprise > db.doccollect4.drop()
true

MongoDB Enterprise > show collections
doccollect
mycoll
users
MongoDB Enterprise >

Backup location#

[mdashok@nosqlDB ashokdb]$ pwd
/yis/mdashok/mongodb_dump/ashokdb
[mdashok@nosqlDB ashokdb]$ ls -ltr doccollect*
-rw-r--r--. 1 mdashok mongodb 132 Sep 30 17:50 doccollect.metadata.json
-rw-r--r--. 1 mdashok mongodb 160 Sep 30 17:50 doccollect4.metadata.json
-rw-r--r--. 1 mdashok mongodb   0 Sep 30 17:50 doccollect4.bson
-rw-r--r--. 1 mdashok mongodb 699 Sep 30 17:50 doccollect.bson
[mdashok@nosqlDB ashokdb]$


Now restore collection from backup

[mdashok@nosqlDB ashokdb]$ mongorestore -d ashokdb -c doccollect4 /yis/mdashok/mongodb_dump/ashokdb/doccollect4.bson

2018-09-30T18:17:41.276+0530    checking for collection data in /yis/mdashok/mongodb_dump/ashokdb/doccollect4.bson
2018-09-30T18:17:41.276+0530    reading metadata for ashokdb.doccollect4 from /yis/mdashok/mongodb_dump/ashokdb/doccollect4.metadata.json
2018-09-30T18:17:41.322+0530    restoring ashokdb.doccollect4 from /yis/mdashok/mongodb_dump/ashokdb/doccollect4.bson
2018-09-30T18:17:41.384+0530    no indexes to restore
2018-09-30T18:17:41.384+0530    finished restoring ashokdb.doccollect4 (0 documents)
2018-09-30T18:17:41.384+0530    done
[mdashok@nosqlDB ashokdb]$

Now check the collection stats from db:

MongoDB Enterprise > db
ashokdb
MongoDB Enterprise > show collections
doccollect
doccollect4
mycoll
users


# restore a collection to new database from backup .

$mongorestore --db docdb -h localhost:27017 --dir /yis/mdashok/mongodb_whole_server_bkp/ashokdb/doccollect --collection doccollect








#Backup and restore using specific user "reportsUser"

Take a full database backup of ashokdb(db name) using reportsUser 


[mdashok@MongoDB ~]$ mongodump --db ashokdb -u "reportsUser" -p "user123" -- full_db_ashokdb_user_reportsUser
2018-10-13T18:36:13.180+0530    positional arguments not allowed: [-- full_db_ashokdb_user_reportsUser]
2018-10-13T18:36:13.180+0530    try 'mongodump --help' for more information
[mdashok@MongoDB ~]$ mongodump --db ashokdb -u "reportsUser" -p "user123" --out full_db_ashokdb_user_reportsUser
2018-10-13T18:36:26.263+0530    writing ashokdb.users to
2018-10-13T18:36:26.294+0530    writing ashokdb.doccollect to
2018-10-13T18:36:26.295+0530    writing ashokdb.Today to
2018-10-13T18:36:26.295+0530    writing ashokdb.doccollect4 to
2018-10-13T18:36:26.360+0530    done dumping ashokdb.users (40 documents)
2018-10-13T18:36:26.360+0530    writing ashokdb.mycoll to
2018-10-13T18:36:26.423+0530    done dumping ashokdb.doccollect (5 documents)
2018-10-13T18:36:26.423+0530    writing ashokdb.indx-doc1 to
2018-10-13T18:36:26.464+0530    done dumping ashokdb.doccollect4 (0 documents)
2018-10-13T18:36:26.476+0530    done dumping ashokdb.Today (1 document)
2018-10-13T18:36:26.476+0530    done dumping ashokdb.mycoll (0 documents)
2018-10-13T18:36:26.502+0530    done dumping ashokdb.indx-doc1 (0 documents)


Restore fulldb backup with new name "newdb1" by using user= reportsUser

[mdashok@MongoDB ~]$ mongorestore --db newdb1 -u "reportsUser" -p "user123" --authenticationDatabase ashokdb --dir  /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb

2018-10-13T18:46:27.480+0530    the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead
2018-10-13T18:46:27.480+0530    building a list of collections to restore from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb dir
2018-10-13T18:46:27.520+0530    reading metadata for newdb1.users from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/users.metadata.json
2018-10-13T18:46:27.615+0530    restoring newdb1.users from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/users.bson
2018-10-13T18:46:27.616+0530    reading metadata for newdb1.doccollect from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/doccollect.metadata.json
2018-10-13T18:46:27.616+0530    reading metadata for newdb1.Today from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/Today.metadata.json
2018-10-13T18:46:27.617+0530    reading metadata for newdb1.doccollect4 from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/doccollect4.metadata.json
2018-10-13T18:46:27.760+0530    restoring newdb1.doccollect from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/doccollect.bson
2018-10-13T18:46:27.779+0530    no indexes to restore
2018-10-13T18:46:27.779+0530    finished restoring newdb1.users (40 documents)
2018-10-13T18:46:27.779+0530    reading metadata for newdb1.indx-doc1 from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/indx-doc1.metadata.json
2018-10-13T18:46:27.779+0530    restoring newdb1.Today from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/Today.bson
2018-10-13T18:46:27.839+0530    no indexes to restore
2018-10-13T18:46:27.839+0530    finished restoring newdb1.doccollect (5 documents)
2018-10-13T18:46:27.839+0530    reading metadata for newdb1.mycoll from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/mycoll.metadata.json
2018-10-13T18:46:27.854+0530    restoring newdb1.doccollect4 from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/doccollect4.bson
2018-10-13T18:46:27.875+0530    no indexes to restore
2018-10-13T18:46:27.875+0530    finished restoring newdb1.doccollect4 (0 documents)
2018-10-13T18:46:27.896+0530    no indexes to restore
2018-10-13T18:46:27.896+0530    finished restoring newdb1.Today (1 document)
2018-10-13T18:46:27.942+0530    restoring newdb1.indx-doc1 from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/indx-doc1.bson
2018-10-13T18:46:27.974+0530    no indexes to restore
2018-10-13T18:46:27.974+0530    finished restoring newdb1.indx-doc1 (0 documents)
2018-10-13T18:46:28.010+0530    restoring newdb1.mycoll from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/mycoll.bson
2018-10-13T18:46:28.013+0530    no indexes to restore
2018-10-13T18:46:28.013+0530    finished restoring newdb1.mycoll (0 documents)
2018-10-13T18:46:28.013+0530    done
[mdashok@MongoDB ~]$



Restore a collection without index for faster reloading the collection and we can rebuild the index later#


[mdashok@MongoDB ashokdb]$ mongorestore --db docdb --collection doccollect --dir doccollect.bson --noIndexRestore -vvvvv

2018-10-13T19:02:58.839+0530    using --dir flag instead of arguments
2018-10-13T19:02:58.839+0530    checking options
2018-10-13T19:02:58.839+0530            dumping with object check disabled
2018-10-13T19:02:58.840+0530    will listen for SIGTERM, SIGINT, and SIGKILL
2018-10-13T19:02:58.843+0530    connected to node type: standalone
2018-10-13T19:02:58.843+0530    standalone server: setting write concern w to 1
2018-10-13T19:02:58.843+0530    using write concern: w='1', j=false, fsync=false, wtimeout=0
2018-10-13T19:02:58.843+0530    mongorestore target is a file, not a directory
2018-10-13T19:02:58.843+0530    setting number of insertions workers to number of parallel collections (4)
2018-10-13T19:02:58.843+0530    checking for collection data in doccollect.bson
2018-10-13T19:02:58.843+0530    reading collection doccollect for database docdb from doccollect.bson
2018-10-13T19:02:58.843+0530    scanning directory doccollect.bson for metadata
2018-10-13T19:02:58.843+0530    found metadata for collection at doccollect.metadata.json
2018-10-13T19:02:58.843+0530    enqueued collection 'docdb.doccollect'
2018-10-13T19:02:58.843+0530    finalizing intent manager with multi-database longest task first prioritizer
2018-10-13T19:02:58.843+0530    restoring up to 4 collections in parallel
2018-10-13T19:02:58.843+0530    starting restore routine with id=3
2018-10-13T19:02:58.872+0530    starting restore routine with id=0
2018-10-13T19:02:58.872+0530    ending restore routine with id=0, no more work to do
2018-10-13T19:02:58.872+0530    starting restore routine with id=1
2018-10-13T19:02:58.872+0530    ending restore routine with id=1, no more work to do
2018-10-13T19:02:58.872+0530    starting restore routine with id=2
2018-10-13T19:02:58.872+0530    ending restore routine with id=2, no more work to do
2018-10-13T19:02:58.872+0530    reading metadata for docdb.doccollect from doccollect.metadata.json
2018-10-13T19:02:58.873+0530    collection docdb.doccollect already exists - skipping collection create
2018-10-13T19:02:58.873+0530    restoring docdb.doccollect from doccollect.bson
2018-10-13T19:02:58.875+0530    using 4 insertion workers
2018-10-13T19:02:58.907+0530    error: multiple errors in bulk operation:
  - E11000 duplicate key error collection: docdb.doccollect index: _id_ dup key: { : ObjectId('5bb0bd9aaf35aafba1581136') }
  - E11000 duplicate key error collection: docdb.doccollect index: _id_ dup key: { : ObjectId('5bb0bd9eaf35aafba1581137') }
  - E11000 duplicate key error collection: docdb.doccollect index: _id_ dup key: { : ObjectId('5bb0bda4af35aafba1581138') }
  - E11000 duplicate key error collection: docdb.doccollect index: _id_ dup key: { : ObjectId('5bb0bda7af35aafba1581139') }

2018-10-13T19:02:58.938+0530    no indexes to restore
2018-10-13T19:02:58.938+0530    finished restoring docdb.doccollect (5 documents)
2018-10-13T19:02:58.939+0530    ending restore routine with id=3, no more work to do
2018-10-13T19:02:58.939+0530    done

[mdashok@MongoDB ashokdb]$


#Using Parallel processes option for restore the database

[mdashok@MongoDB ashokdb]$ mongorestore --db docdb1013 --dir /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb -vvvvv --numParallelCollections 2


2018-10-13T19:06:40.433+0530    using --dir flag instead of arguments
2018-10-13T19:06:40.433+0530    checking options
2018-10-13T19:06:40.433+0530            dumping with object check disabled
2018-10-13T19:06:40.433+0530    will listen for SIGTERM, SIGINT, and SIGKILL
2018-10-13T19:06:40.434+0530    connected to node type: standalone
2018-10-13T19:06:40.434+0530    standalone server: setting write concern w to 1
2018-10-13T19:06:40.434+0530    using write concern: w='1', j=false, fsync=false, wtimeout=0
2018-10-13T19:06:40.434+0530    the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead
2018-10-13T19:06:40.434+0530    mongorestore target is a directory, not a file
2018-10-13T19:06:40.434+0530    building a list of collections to restore from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb dir
2018-10-13T19:06:40.434+0530    reading collections for database docdb1013 in ashokdb
2018-10-13T19:06:40.435+0530    found collection docdb1013.Today bson to restore to docdb1013.Today
2018-10-13T19:06:40.435+0530    found collection metadata from docdb1013.Today to restore to docdb1013.Today
2018-10-13T19:06:40.435+0530    found collection docdb1013.doccollect bson to restore to docdb1013.doccollect
2018-10-13T19:06:40.435+0530    found collection metadata from docdb1013.doccollect to restore to docdb1013.doccollect
2018-10-13T19:06:40.435+0530    found collection docdb1013.doccollect4 bson to restore to docdb1013.doccollect4
2018-10-13T19:06:40.435+0530    found collection metadata from docdb1013.doccollect4 to restore to docdb1013.doccollect4
2018-10-13T19:06:40.435+0530    found collection docdb1013.indx-doc1 bson to restore to docdb1013.indx-doc1
2018-10-13T19:06:40.435+0530    found collection metadata from docdb1013.indx-doc1 to restore to docdb1013.indx-doc1
2018-10-13T19:06:40.435+0530    found collection docdb1013.mycoll bson to restore to docdb1013.mycoll
2018-10-13T19:06:40.435+0530    found collection metadata from docdb1013.mycoll to restore to docdb1013.mycoll
2018-10-13T19:06:40.435+0530    found collection docdb1013.users bson to restore to docdb1013.users
2018-10-13T19:06:40.435+0530    found collection metadata from docdb1013.users to restore to docdb1013.users
2018-10-13T19:06:40.435+0530    finalizing intent manager with multi-database longest task first prioritizer
2018-10-13T19:06:40.435+0530    restoring up to 2 collections in parallel
2018-10-13T19:06:40.435+0530    starting restore routine with id=1
2018-10-13T19:06:40.435+0530    starting restore routine with id=0
2018-10-13T19:06:40.435+0530    reading metadata for docdb1013.users from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/users.metadata.json
2018-10-13T19:06:40.435+0530    creating collection docdb1013.users using options from metadata
2018-10-13T19:06:40.435+0530    using collection options: bson.D{bson.DocElem{Name:"idIndex", Value:mongorestore.IndexDocument{Options:bson.M{"name":"_id_", "ns":"docdb1013.users"}, Key:bson.D{bson.DocElem{Name:"_id", Value:1}}, PartialFilterExpression:bson.D(nil)}}}
2018-10-13T19:06:40.460+0530    reading metadata for docdb1013.doccollect from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/doccollect.metadata.json
2018-10-13T19:06:40.461+0530    creating collection docdb1013.doccollect using options from metadata
2018-10-13T19:06:40.461+0530    using collection options: bson.D{bson.DocElem{Name:"idIndex", Value:mongorestore.IndexDocument{Options:bson.M{"name":"_id_", "ns":"docdb1013.doccollect"}, Key:bson.D{bson.DocElem{Name:"_id", Value:1}}, PartialFilterExpression:bson.D(nil)}}}
2018-10-13T19:06:40.462+0530    restoring docdb1013.users from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/users.bson
2018-10-13T19:06:40.463+0530    using 1 insertion workers
2018-10-13T19:06:40.504+0530    no indexes to restore
2018-10-13T19:06:40.504+0530    finished restoring docdb1013.users (40 documents)
2018-10-13T19:06:40.504+0530    reading metadata for docdb1013.Today from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/Today.metadata.json
2018-10-13T19:06:40.505+0530    creating collection docdb1013.Today using options from metadata
2018-10-13T19:06:40.505+0530    using collection options: bson.D{bson.DocElem{Name:"idIndex", Value:mongorestore.IndexDocument{Options:bson.M{"name":"_id_", "ns":"docdb1013.Today"}, Key:bson.D{bson.DocElem{Name:"_id", Value:1}}, PartialFilterExpression:bson.D(nil)}}}
2018-10-13T19:06:40.505+0530    restoring docdb1013.doccollect from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/doccollect.bson
2018-10-13T19:06:40.506+0530    using 1 insertion workers
2018-10-13T19:06:40.535+0530    no indexes to restore
2018-10-13T19:06:40.535+0530    finished restoring docdb1013.doccollect (5 documents)
2018-10-13T19:06:40.535+0530    reading metadata for docdb1013.doccollect4 from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/doccollect4.metadata.json
2018-10-13T19:06:40.535+0530    creating collection docdb1013.doccollect4 using options from metadata
2018-10-13T19:06:40.535+0530    using collection options: bson.D{bson.DocElem{Name:"capped", Value:true}, bson.DocElem{Name:"size", Value:200192}, bson.DocElem{Name:"idIndex", Value:mongorestore.IndexDocument{Options:bson.M{"name":"_id_", "ns":"docdb1013.doccollect4"}, Key:bson.D{bson.DocElem{Name:"_id", Value:1}}, PartialFilterExpression:bson.D(nil)}}}
2018-10-13T19:06:40.536+0530    restoring docdb1013.Today from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/Today.bson
2018-10-13T19:06:40.542+0530    using 1 insertion workers
2018-10-13T19:06:40.563+0530    no indexes to restore
2018-10-13T19:06:40.563+0530    finished restoring docdb1013.Today (1 document)
2018-10-13T19:06:40.563+0530    reading metadata for docdb1013.indx-doc1 from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/indx-doc1.metadata.json
2018-10-13T19:06:40.563+0530    creating collection docdb1013.indx-doc1 using options from metadata
2018-10-13T19:06:40.563+0530    using collection options: bson.D{bson.DocElem{Name:"idIndex", Value:mongorestore.IndexDocument{Options:bson.M{"name":"_id_", "ns":"docdb1013.indx-doc1"}, Key:bson.D{bson.DocElem{Name:"_id", Value:1}}, PartialFilterExpression:bson.D(nil)}}}
2018-10-13T19:06:40.563+0530    restoring docdb1013.doccollect4 from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/doccollect4.bson
2018-10-13T19:06:40.582+0530    using 1 insertion workers
2018-10-13T19:06:40.583+0530    no indexes to restore
2018-10-13T19:06:40.583+0530    finished restoring docdb1013.doccollect4 (0 documents)
2018-10-13T19:06:40.583+0530    reading metadata for docdb1013.mycoll from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/mycoll.metadata.json
2018-10-13T19:06:40.583+0530    creating collection docdb1013.mycoll using options from metadata
2018-10-13T19:06:40.583+0530    using collection options: bson.D{bson.DocElem{Name:"capped", Value:true}, bson.DocElem{Name:"size", Value:100096}, bson.DocElem{Name:"idIndex", Value:mongorestore.IndexDocument{Options:bson.M{"name":"_id_", "ns":"docdb1013.mycoll"}, Key:bson.D{bson.DocElem{Name:"_id", Value:1}}, PartialFilterExpression:bson.D(nil)}}}
2018-10-13T19:06:40.602+0530    restoring docdb1013.indx-doc1 from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/indx-doc1.bson
2018-10-13T19:06:40.604+0530    using 1 insertion workers
2018-10-13T19:06:40.605+0530    no indexes to restore
2018-10-13T19:06:40.605+0530    finished restoring docdb1013.indx-doc1 (0 documents)
2018-10-13T19:06:40.605+0530    ending restore routine with id=1, no more work to do
2018-10-13T19:06:40.629+0530    restoring docdb1013.mycoll from /yis/mdashok/full_db_ashokdb_user_reportsUser/ashokdb/mycoll.bson
2018-10-13T19:06:40.632+0530    using 1 insertion workers
2018-10-13T19:06:40.632+0530    no indexes to restore
2018-10-13T19:06:40.632+0530    finished restoring docdb1013.mycoll (0 documents)
2018-10-13T19:06:40.632+0530    ending restore routine with id=0, no more work to do
2018-10-13T19:06:40.632+0530    done
[mdashok@MongoDB ashokdb]$


MONGOEXPORT

  • Take a backup of a collection using mongoexport command utility with csv format. we see the content of the backup file
  • But in *.bson format we cannot see the backup content.
[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ mongoexport --db docdb --out docdb_doccollect.csv --collection doccollect -vvvvvv
2018-10-13T19:22:13.428+0530    will listen for SIGTERM, SIGINT, and SIGKILL
2018-10-13T19:22:13.448+0530    connected to: localhost
2018-10-13T19:22:13.450+0530    exported 5 records
[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$


[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ ls -ltr
total 4
-rw-r--r--. 1 mdashok mongodb 862 Oct 13 19:22 docdb_doccollect.csv
[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$


[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ cat docdb_doccollect.csv
{"_id":{"$oid":"5bb0bd9aaf35aafba1581136"},"title":"MongoDB doc1","description":"MongoDB document 1","by":"Vimal","tags":["mongodb","NoSQLDB","DocDB","database"],"likes":100.0}
{"_id":{"$oid":"5bb0bd9eaf35aafba1581137"},"title":"MongoDB doc1","description":"MongoDB document 1","by":"ashok","tags":["mongodb","NoSQLDB","DocDB","database"],"likes":100.0}
{"_id":{"$oid":"5bb0bda4af35aafba1581138"},"title":"MongoDB doc1","description":"MongoDB document 1","by":"ashok","tags":["mongodb","NoSQLDB","DocDB","database"],"likes":100.0}
{"_id":{"$oid":"5bb0bda7af35aafba1581139"},"title":"casandra doc1","description":"NoSQLDB","by":"Ashok","tags":["NoSQL","DocDB","NotOnlySQL"],"likes":100.0}
{"_id":{"$oid":"5bb5f5deded3edb1e4b4f5a7"},"title":"indx-doc1","description":"MongoDB document 1","by":"Vimal","tags":["mongodb","NoSQLDB","DocDB","database"],"likes":100.0}
[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$

JSON format backup

[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ mongoexport --db docdb --out docdb_doccollect.json --collection doccollect -vvvvvv
2018-10-13T20:16:10.947+0530    will listen for SIGTERM, SIGINT, and SIGKILL
2018-10-13T20:16:10.950+0530    connected to: localhost
2018-10-13T20:16:10.951+0530    exported 5 records



[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ ls -ltr
-rw-r--r--. 1 mdashok mongodb 862 Oct 13 20:16 docdb_doccollect.json

[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$



JSON format backup with pretty option



[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ mongoexport --db docdb --out docdb_doccollect.json --collection doccollect -vvvvvv --jsonArray --pretty


2018-10-13T20:20:08.318+0530    will listen for SIGTERM, SIGINT, and SIGKILL
2018-10-13T20:20:08.320+0530    connected to: localhost
2018-10-13T20:20:08.321+0530    exported 5 records
[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$

[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ cat docdb_doccollect.json
[{
        "_id": {
                "$oid": "5bb0bd9aaf35aafba1581136"
        },
        "title": "MongoDB doc1",
        "description": "MongoDB document 1",
        "by": "Vimal",
        "tags": [
                "mongodb",
                "NoSQLDB",
                "DocDB",
                "database"
        ],
        "likes": 100.0
},
{
        "_id": {
                "$oid": "5bb0bd9eaf35aafba1581137"
        },
        "title": "MongoDB doc1",
        "description": "MongoDB document 1",
        "by": "ashok",
        "tags": [
                "mongodb",
                "NoSQLDB",
                "DocDB",
                "database"
        ],
        "likes": 100.0
},
{
        "_id": {
                "$oid": "5bb0bda4af35aafba1581138"
        },
        "title": "MongoDB doc1",
        "description": "MongoDB document 1",
        "by": "ashok",
        "tags": [
                "mongodb",
                "NoSQLDB",
                "DocDB",
                "database"
        ],
        "likes": 100.0
},
{
        "_id": {
                "$oid": "5bb0bda7af35aafba1581139"
        },
        "title": "casandra doc1",
        "description": "NoSQLDB",
        "by": "Ashok",
        "tags": [
                "NoSQL",
                "DocDB",
                "NotOnlySQL"
        ],
        "likes": 100.0
},
{
        "_id": {
                "$oid": "5bb5f5deded3edb1e4b4f5a7"
        },
        "title": "indx-doc1",
        "description": "MongoDB document 1",
        "by": "Vimal",
        "tags": [
                "mongodb",
                "NoSQLDB",
                "DocDB",
                "database"
        ],
        "likes": 100.0
}]
[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$

[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ mongoexport --db ashokdb --out ashokdb_doccollect_fields.json  --collection doccollect -vvvvvv  --jsonArray --pretty --fields title,by
2018-10-13T21:12:15.391+0530    will listen for SIGTERM, SIGINT, and SIGKILL
2018-10-13T21:12:15.393+0530    connected to: localhost
2018-10-13T21:12:15.394+0530    exported 5 records

[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$


mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ cat ashokdb_doccollect_fields.json
[{
        "_id": {
                "$oid": "5bb0bd9aaf35aafba1581136"
        },
        "title": "MongoDB doc1",
        "by": "Vimal"
},
{
        "_id": {
                "$oid": "5bb0bd9eaf35aafba1581137"
        },
        "title": "MongoDB doc1",
        "by": "ashok"
},
{
        "_id": {
                "$oid": "5bb0bda4af35aafba1581138"
        },
        "title": "MongoDB doc1",
        "by": "ashok"
},
{
        "_id": {
                "$oid": "5bb0bda7af35aafba1581139"
        },
        "title": "casandra doc1",
        "by": "Ashok"
},
{
        "_id": {
                "$oid": "5bb5f5deded3edb1e4b4f5a7"
        },
        "title": "indx-doc1",
        "by": "Vimal"
}]


mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ mongoexport --db ashokdb --out ashokdb_doccollect_fields.csv  --collection doccollect -vvvvvv  --jsonArray --pretty --fields title,by

[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ cat ashokdb_doccollect_fields.csv
[{
        "_id": {
                "$oid": "5bb0bd9aaf35aafba1581136"
        },
        "title": "MongoDB doc1",
        "by": "Vimal"
},
{
        "_id": {
                "$oid": "5bb0bd9eaf35aafba1581137"
        },
        "title": "MongoDB doc1",
        "by": "ashok"
},
{
        "_id": {
                "$oid": "5bb0bda4af35aafba1581138"
        },
        "title": "MongoDB doc1",
        "by": "ashok"
},
{
        "_id": {
                "$oid": "5bb0bda7af35aafba1581139"
        },
        "title": "casandra doc1",
        "by": "Ashok"
},
{
        "_id": {
                "$oid": "5bb5f5deded3edb1e4b4f5a7"
        },
        "title": "indx-doc1",
        "by": "Vimal"
}]

[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$



MONGOIMPORT


Restore a collection from backup using mongoimport 

Check the records count before delete it#

MongoDB Enterprise > db.doccollect.find();
{ "_id" : ObjectId("5bb0bd9aaf35aafba1581136"), "title" : "MongoDB doc1", "description" : "MongoDB document 1", "by" : "Vimal", "tags" : [ "mongodb", "NoSQLDB", "DocDB", "database" ], "likes" : 100 }
{ "_id" : ObjectId("5bb0bd9eaf35aafba1581137"), "title" : "MongoDB doc1", "description" : "MongoDB document 1", "by" : "ashok", "tags" : [ "mongodb", "NoSQLDB", "DocDB", "database" ], "likes" : 100 }
{ "_id" : ObjectId("5bb0bda4af35aafba1581138"), "title" : "MongoDB doc1", "description" : "MongoDB document 1", "by" : "ashok", "tags" : [ "mongodb", "NoSQLDB", "DocDB", "database" ], "likes" : 100 }
{ "_id" : ObjectId("5bb0bda7af35aafba1581139"), "title" : "casandra doc1", "description" : "NoSQLDB", "by" : "Ashok", "tags" : [ "NoSQL", "DocDB", "NotOnlySQL" ], "likes" : 100 }
{ "_id" : ObjectId("5bb5f5deded3edb1e4b4f5a7"), "title" : "indx-doc1", "description" : "MongoDB document 1", "by" : "Vimal", "tags" : [ "mongodb", "NoSQLDB", "DocDB", "database" ], "likes" : 100 }


remove the records from collection 

MongoDB Enterprise > db.doccollect.remove({});
WriteResult({ "nRemoved" : 5 })

MongoDB Enterprise >


MongoDB Enterprise > db.doccollect.find();
MongoDB Enterprise >


[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$ mongoimport --db docdb --file docdb_doccollect.csv --collection docollect -vvvvvv

2018-10-13T20:31:07.988+0530    using 1 decoding workers
2018-10-13T20:31:07.988+0530    using 1 insert workers
2018-10-13T20:31:07.988+0530    filesize: 862 bytes
2018-10-13T20:31:07.988+0530    using fields:
2018-10-13T20:31:08.003+0530    will listen for SIGTERM, SIGINT, and SIGKILL
2018-10-13T20:31:08.014+0530    connected to: localhost
2018-10-13T20:31:08.014+0530    ns: docdb.docollect
2018-10-13T20:31:08.014+0530    connected to node type: standalone
2018-10-13T20:31:08.021+0530    standalone server: setting write concern w to 1
2018-10-13T20:31:08.021+0530    using write concern: w='1', j=false, fsync=false, wtimeout=0
2018-10-13T20:31:08.021+0530    standalone server: setting write concern w to 1
2018-10-13T20:31:08.021+0530    using write concern: w='1', j=false, fsync=false, wtimeout=0
2018-10-13T20:31:08.028+0530    got line: [{_id [{$oid 5bb0bd9aaf35aafba1581136}]} {title MongoDB doc1} {description MongoDB document 1} {by Vimal} {tags [mongodb NoSQLDB DocDB database]} {likes 100}]
2018-10-13T20:31:08.028+0530    got extended line: bson.D{bson.DocElem{Name:"_id", Value:"[\xb0\xbd\x9a\xaf5\xaa\xfb\xa1X\x116"}, bson.DocElem{Name:"title", Value:"MongoDB doc1"}, bson.DocElem{Name:"description", Value:"MongoDB document 1"}, bson.DocElem{Name:"by", Value:"Vimal"}, bson.DocElem{Name:"tags", Value:[]interface {}{"mongodb", "NoSQLDB", "DocDB", "database"}}, bson.DocElem{Name:"likes", Value:100}}
2018-10-13T20:31:08.028+0530    got line: [{_id [{$oid 5bb0bd9eaf35aafba1581137}]} {title MongoDB doc1} {description MongoDB document 1} {by ashok} {tags [mongodb NoSQLDB DocDB database]} {likes 100}]
2018-10-13T20:31:08.028+0530    got extended line: bson.D{bson.DocElem{Name:"_id", Value:"[\xb0\xbd\x9e\xaf5\xaa\xfb\xa1X\x117"}, bson.DocElem{Name:"title", Value:"MongoDB doc1"}, bson.DocElem{Name:"description", Value:"MongoDB document 1"}, bson.DocElem{Name:"by", Value:"ashok"}, bson.DocElem{Name:"tags", Value:[]interface {}{"mongodb", "NoSQLDB", "DocDB", "database"}}, bson.DocElem{Name:"likes", Value:100}}
2018-10-13T20:31:08.028+0530    got line: [{_id [{$oid 5bb0bda4af35aafba1581138}]} {title MongoDB doc1} {description MongoDB document 1} {by ashok} {tags [mongodb NoSQLDB DocDB database]} {likes 100}]
2018-10-13T20:31:08.028+0530    got extended line: bson.D{bson.DocElem{Name:"_id", Value:"[\xb0\xbd\xa4\xaf5\xaa\xfb\xa1X\x118"}, bson.DocElem{Name:"title", Value:"MongoDB doc1"}, bson.DocElem{Name:"description", Value:"MongoDB document 1"}, bson.DocElem{Name:"by", Value:"ashok"}, bson.DocElem{Name:"tags", Value:[]interface {}{"mongodb", "NoSQLDB", "DocDB", "database"}}, bson.DocElem{Name:"likes", Value:100}}
2018-10-13T20:31:08.028+0530    got line: [{_id [{$oid 5bb0bda7af35aafba1581139}]} {title casandra doc1} {description NoSQLDB} {by Ashok} {tags [NoSQL DocDB NotOnlySQL]} {likes 100}]
2018-10-13T20:31:08.028+0530    got extended line: bson.D{bson.DocElem{Name:"_id", Value:"[\xb0\xbd\xa7\xaf5\xaa\xfb\xa1X\x119"}, bson.DocElem{Name:"title", Value:"casandra doc1"}, bson.DocElem{Name:"description", Value:"NoSQLDB"}, bson.DocElem{Name:"by", Value:"Ashok"}, bson.DocElem{Name:"tags", Value:[]interface {}{"NoSQL", "DocDB", "NotOnlySQL"}}, bson.DocElem{Name:"likes", Value:100}}
2018-10-13T20:31:08.028+0530    got line: [{_id [{$oid 5bb5f5deded3edb1e4b4f5a7}]} {title indx-doc1} {description MongoDB document 1} {by Vimal} {tags [mongodb NoSQLDB DocDB database]} {likes 100}]
2018-10-13T20:31:08.028+0530    got extended line: bson.D{bson.DocElem{Name:"_id", Value:"[\xb5\xf5\xde\xde\xd3\xed\xb1\xe4\xb4\xf5\xa7"}, bson.DocElem{Name:"title", Value:"indx-doc1"}, bson.DocElem{Name:"description", Value:"MongoDB document 1"}, bson.DocElem{Name:"by", Value:"Vimal"}, bson.DocElem{Name:"tags", Value:[]interface {}{"mongodb", "NoSQLDB", "DocDB", "database"}}, bson.DocElem{Name:"likes", Value:100}}
2018-10-13T20:31:08.072+0530    imported 5 documents
[mdashok@MongoDB EXPORT_IMPORT_BACKUP]$



MongoDB Enterprise > db
docdb
MongoDB Enterprise > db.doccollect.find();
{ "_id" : ObjectId("5bb0bd9aaf35aafba1581136"), "title" : "MongoDB doc1", "description" : "MongoDB document 1", "by" : "Vimal", "tags" : [ "mongodb", "NoSQLDB", "DocDB", "database" ], "likes" : 100 }
{ "_id" : ObjectId("5bb0bd9eaf35aafba1581137"), "title" : "MongoDB doc1", "description" : "MongoDB document 1", "by" : "ashok", "tags" : [ "mongodb", "NoSQLDB", "DocDB", "database" ], "likes" : 100 }
{ "_id" : ObjectId("5bb0bda4af35aafba1581138"), "title" : "MongoDB doc1", "description" : "MongoDB document 1", "by" : "ashok", "tags" : [ "mongodb", "NoSQLDB", "DocDB", "database" ], "likes" : 100 }
{ "_id" : ObjectId("5bb0bda7af35aafba1581139"), "title" : "casandra doc1", "description" : "NoSQLDB", "by" : "Ashok", "tags" : [ "NoSQL", "DocDB", "NotOnlySQL" ], "likes" : 100 }
{ "_id" : ObjectId("5bb5f5deded3edb1e4b4f5a7"), "title" : "indx-doc1", "description" : "MongoDB document 1", "by" : "Vimal", "tags" : [ "mongodb", "NoSQLDB", "DocDB", "database" ], "likes" : 100 }
MongoDB Enterprise >
MongoDB Enterprise >
MongoDB Enterprise >
MongoDB Enterprise >


Step by Step YugabyteDB 2.11 (Open Source) Distributed DB - Multi-node Cluster Setup on RHEL

Scope - ·        Infrastructure planning and requirement for installation of the multi-node cluster database ·        Prerequisites Software...