Skip to content

Instantly share code, notes, and snippets.

@iworkforthem
Created February 14, 2017 05:28
Show Gist options
  • Select an option

  • Save iworkforthem/b4a11bcd35b486564abf0ccfde555d66 to your computer and use it in GitHub Desktop.

Select an option

Save iworkforthem/b4a11bcd35b486564abf0ccfde555d66 to your computer and use it in GitHub Desktop.
mongodb replicate set
# mongod --port 27017 --dbpath /var/lib/mongo --replSet rs0
# sudo service mongod start
# nano /etc/mongod.conf
mongod --port 27017 --dbpath /data/db/rs0 --replSet rs0
mongod --port 27018 --dbpath /data/db/rs1 --replSet rs0
mongod --port 27019 --dbpath /data/db/rs2 --replSet rs0
rsconf = {
_id: "rs0",
members: [
{
_id: 0,
host: "127.0.0.1:27017"
},
{
_id: 1,
host: "127.0.0.1:27018"
},
{
_id: 2,
host: "127.0.0.1:27019"
}
]
}
rs.initiate(rsconf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment