Last active
January 27, 2021 17:36
-
-
Save cb-v4s/0305385a6ea1e5ee537406fc7bd3c392 to your computer and use it in GitHub Desktop.
setup a replica set cluster for mongodb
This file contains hidden or 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
| ; setup replica sets | |
| mongod --port 27017 --dbpath ~/mongoc/db0 --replSet Replicante | |
| mongod --port 27027 --dbpath ~/mongoc/db1 --replSet Replicante | |
| mongod --port 27037 --dbpath ~/mongoc/db2 --replSet Replicante | |
| ; mongo --port 27017 | |
| rs.initiate() | |
| rs.add("localhost:27027") ; add second member | |
| rs.add("localhost:27037") ; add third member | |
| rs.status() ; check status for replica set | |
| rs.slaveOk() ; replicate | |
| ; connection string | |
| mongodb://localhost:27017,localhost:27027,localhost:27037?replicaSet=Replicante |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment