Created
October 8, 2015 10:20
-
-
Save strikeout/353bcc6a10d2320d50c4 to your computer and use it in GitHub Desktop.
Adds own host to a mongo replica-set. Runs on server-startup
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
#!/usr/bin/env bash | |
#get own hostname | |
ME=$(hostname); | |
# find replica-set master, we think its the first in the array | |
MASTER=`mongo --quiet --eval "cfg=rs.config(); print( cfg.members[0].host );"` | |
# connect to master, add ME | |
mongo --host $MASTER --eval "print( rs.add('"$ME"') );" | |
# make ME queryable | |
mongo --eval "rs.slaveOk();" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment