Skip to content

Instantly share code, notes, and snippets.

@gousiosg
Created May 25, 2016 14:59
Show Gist options
  • Save gousiosg/8e735fb65a8d5666c502fabed8071c5d to your computer and use it in GitHub Desktop.
Save gousiosg/8e735fb65a8d5666c502fabed8071c5d to your computer and use it in GitHub Desktop.
Local MongoDB replica set
# start the replset nodes
$ mongod --dbpath mongodb/ --replSet ghtorrent
$ mongod --dbpath mongodb-repl1/ --port 27018 --replSet ghtorrent
$ mongod --dbpath mongodb-repl2/ --port 27019 --replSet ghtorrent
# connect to primary
$ mongo
# In mongo shell
ghtorrent:PRIMARY> rs.initiate()
ghtorrent:PRIMARY> rs.conf()
ghtorrent:PRIMARY> cfg = rs.conf()
ghtorrent:PRIMARY> cfg.members[0].host="localhost:27017"
ghtorrent:PRIMARY> rs.reconfig(cfg)
ghtorrent:PRIMARY> rs.add("localhost:27018")
ghtorrent:PRIMARY> rs.add("localhost:27019")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment