Created
August 10, 2011 20:47
-
-
Save JakubOboza/1138212 to your computer and use it in GitHub Desktop.
MongoDB ReplicaSet
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
#!/bin/bash | |
# My single node ReplicaSet quick test script | |
mkdir -p /tmp/rs1 | |
mkdir -p /tmp/rs2 | |
mongod --rest --replSet myset & | |
mongod --rest --replSet myset --dbpath /tmp/rs1 --port 30000 & | |
mongod --rest --replSet myset --dbpath /tmp/rs2 --port 40000 & | |
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
/* | |
Go to mongo and start replicaset | |
*/ | |
config = {_id: 'myset', members: [ | |
{_id: 0, host: 'localhost:27017'}, | |
{_id: 1, host: 'localhost:30000'}, | |
{_id: 2, host: 'localhost:40000'}] | |
} | |
rs.initiate(config) | |
rs.status() | |
rs.slaveOk() // reads from slaves |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment