Created
May 25, 2016 14:59
-
-
Save gousiosg/8e735fb65a8d5666c502fabed8071c5d to your computer and use it in GitHub Desktop.
Local MongoDB replica set
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
# 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