Created
December 10, 2014 18:23
-
-
Save yupadhyay/6cd1e79d74174e9d1fc3 to your computer and use it in GitHub Desktop.
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
cd <Mongo bin directory> | |
use admin | |
db.shutdownServer() | |
#Take Backup | |
./mongodump --dbpath ../data/<NAME OF DB> -o dataout | |
# Now set up new Mongo DB servers that you want to add in replica set Instruction above | |
# Now start your existing Mongo Using following command, Note that this time we are using replSet | |
# You can also do this using Mongo DB configuration file | |
./mongod --port 27017 --dbpath <your DB path> --replSet <Replica set Name> & | |
#Connect to the mongodb instance | |
./mongod --port 27107 | |
rs.initiate() | |
#Make sure that other MongoDB are are up you can now add them to replica set | |
rs.add("<HOST2>:<PORT2>") | |
# To make sure that you have odd number of instances | |
rs.add("<HOST3>:<PORT3>") | |
#If you don't have space or don't want third instance to store data then you can do something like | |
# rs.addArb("<HOST4>:<PORT4>") | |
# Check config again | |
rs.conf() | |
# Check status of Replica | |
rs.status() | |
#If something goes wrong you can do something like | |
cd <Mongo bin location> | |
mongorestore --dbpath <database path> <path to the backup> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment