Skip to content

Instantly share code, notes, and snippets.

@cb-v4s
Last active January 27, 2021 17:36
Show Gist options
  • Select an option

  • Save cb-v4s/0305385a6ea1e5ee537406fc7bd3c392 to your computer and use it in GitHub Desktop.

Select an option

Save cb-v4s/0305385a6ea1e5ee537406fc7bd3c392 to your computer and use it in GitHub Desktop.
setup a replica set cluster for mongodb
; 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