This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Don't have mtools? The easiest way to install mtools is via pip | |
# pip install mtools | |
mlaunch init --auth --replicaset --port 28000 | |
# output | |
# launching: "mongod" on port 28000 | |
# launching: "mongod" on port 28001 | |
# launching: "mongod" on port 28002 | |
# replica set 'replset' initialized. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongo admin --port 28000 -u user -p password --authenticationDatabase admin <<EOF | |
db.createUser({user: 'app_user', pwd: 'password', roles: [{role: 'readWrite', db: 'social'}]}) | |
EOF | |
# The output of above command | |
# MongoDB shell version v3.6.2 | |
# connecting to: mongodb://127.0.0.1:28000/ | |
# MongoDB server version: 3.6.2 | |
# Successfully added user: { | |
# "user" : "app_user", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongo social --port 28000 -u app_user -p password --authenticationDatabase admin | |
# output of above command | |
# MongoDB shell version v3.6.2 | |
# connecting to: mongodb://127.0.0.1:28000/social | |
# MongoDB server version: 3.6.2 | |
# replset:PRIMARY> | |
# create a document in person collection | |
db.person.insert({"fname": "Shyam", "lname": "Arjarapu"}) | |
# output of above command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongo social --port 28000 -u human_user -p password --authenticationDatabase admin | |
# output of above command | |
# MongoDB shell version v3.6.2 | |
# connecting to: mongodb://127.0.0.1:28000/social | |
# MongoDB server version: 3.6.2 | |
# replset:PRIMARY> | |
# create a document in person collection | |
db.person.insert({"fname": "Shyam", "lname": "Arjarapu"}) | |
# output of above command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongo social --port 28000 -u user -p password --authenticationDatabase admin <<EOF | |
db.createRole({ | |
role: "readWriteMinusDropRole", | |
privileges: [ | |
{ | |
resource: { db: "social", collection: ""}, | |
actions: [ "collStats", "dbHash", "dbStats", "find", "killCursors", "listIndexes", "listCollections", "convertToCapped", "createCollection", "createIndex", "dropIndex", "insert", "remove", "renameCollectionSameDB", "update"]} ], | |
roles: [] | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -O https://downloads.mongodb.com/osx/mongodb-osx-x86_64-enterprise-4.0.0-rc0.tgz | |
tar -xvzf mongodb-osx-x86_64-enterprise-4.0.0-rc0.tgz | |
rm mongodb-osx-x86_64-enterprise-4.0.0-rc0.tgz | |
mv mongodb-osx-x86_64-enterprise-4.0.0-rc0 v4.0.0-rc0 | |
mkdir data | |
v4.0.0-rc0/bin/mongod --dbpath data --logpath data/mongod.log --fork --replSet rs0 --port 38000 | |
v4.0.0-rc0/bin/mongo --port 38000 --eval "rs.initiate()" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// v4.0.0-rc0/bin/mongo --port 38000 | |
// **************************************************** | |
// On a sample person collection with two documents _id 1, 2 | |
// Insert new document, _id 3, inside session1 scope | |
// Understand how the find operation on these scopes change | |
// from startTransaction to commitTransaction | |
// **************************************************** | |
// drop and recreate person collection with 2 documents _id 1, 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// v4.0.0-rc0/bin/mongo --port 38000 | |
// **************************************************** | |
// On a sample person collection with two documents _id 1, 2 | |
// Insert new document, _id 3, inside session1 scope | |
// Understand how the find operation on these scopes change | |
// from startTransaction to abortTransaction | |
// **************************************************** | |
// drop and recreate person collection with 2 documents _id 1, 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// v4.0.0-rc0/bin/mongo --port 38000 | |
// **************************************************** | |
// On a sample person collection with two documents _id 1, 2 | |
// Insert new document, _id 3, inside session1 scope | |
// Update a document, _id 1, in session2 scope | |
// Delete a document, _id 2, directly on collection | |
// Understand how the find operation on these scopes change | |
// from beginning of transaction till after commit | |
// **************************************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// v4.0.0-rc0/bin/mongo --port 38000 | |
// **************************************************** | |
// On a sample person collection with two documents _id 1, 2 | |
// Update a document, _id 1, in session1 scope | |
// Delete a document, _id 2, in session1 scope | |
// Delete a document, _id 2, in session2 scope | |
// Understand how the find operation on these scopes change | |
// **************************************************** |