NoSQL Document-Oriented Databases : Performance and High Availability with Mongo DB
db.createCollection("lastUpdatedQuiz", {capped: true, size: 100000, max: 10})
find()
method? How to display it in the reverse direction?in your mongodb executable folder:
mkdir ./mongoA ./mongoB ./mongoC
then :
mongod --replSet quiz --dbpath ./mongoA --port 27001 --rest
mongod --replSet quiz --dbpath ./mongoB --port 27002 --rest
mongod --replSet quiz --dbpath ./mongoC --port 27003 --rest
Then
mongo localhost:27001
rs.initiate({
_id: 'quiz',
members: [
{_id: 1, host: 'localhost:27001'},
{_id: 2, host: 'localhost:27002'},
{_id: 3, host: 'localhost:27003'}
]
})
Try out the following on each server
db.isMaster()
db.tests.insertOne({insertTest:"sample text"})
mongod --shardsvr --dbpath ./mongoD --port 27004
mongod --shardsvr --dbpath ./mongoE --port 27005
mongod --configsvr --dbpath ./config --port 27006
mongos --configdb localhost:27006 --chunkSize 1 --port 27010
mongo localhost:27010/admin
db.runCommand( { addshard : "localhost:27004" } )
db.runCommand( { addshard : "localhost:27005" } )
db.runCommand( { enablesharding : "sampleDB" } )
db.runCommand( { shardcollection : "sampleDB.questions", key : {title : 1} }