Created
February 14, 2017 05:28
-
-
Save iworkforthem/b4a11bcd35b486564abf0ccfde555d66 to your computer and use it in GitHub Desktop.
mongodb replicate 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
| # 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