Skip to content

Commit

Permalink
Merge pull request #1 from CandisIO/ensure-db-with-port-27017-is-master
Browse files Browse the repository at this point in the history
Ensure the Mongo database running on port 27017 is the master
  • Loading branch information
grantwilliams authored Oct 7, 2020
2 parents 203dffb + 51fa756 commit 94b2cb3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions init-replica.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ DB3_PORT=27019

LOCAL_HOST="127.0.0.1"

RS_MEMBER_1="{ \"_id\": 0, \"host\": \"${LOCAL_HOST}:${DB1_PORT}\" }"
RS_MEMBER_2="{ \"_id\": 1, \"host\": \"${LOCAL_HOST}:${DB2_PORT}\" }"
RS_MEMBER_3="{ \"_id\": 2, \"host\": \"${LOCAL_HOST}:${DB3_PORT}\" }"
RS_MEMBER_1="{ \"_id\": 0, \"host\": \"${LOCAL_HOST}:${DB1_PORT}\", \"priority\": 2 }"
RS_MEMBER_2="{ \"_id\": 1, \"host\": \"${LOCAL_HOST}:${DB2_PORT}\", \"priority\": 0 }"
RS_MEMBER_3="{ \"_id\": 2, \"host\": \"${LOCAL_HOST}:${DB3_PORT}\", \"priority\": 0 }"

sleep 30
mongo --eval "rs.initiate({ \"_id\": \"rs0\", \"members\": [${RS_MEMBER_1}, ${RS_MEMBER_2}, ${RS_MEMBER_3}] });"

0 comments on commit 94b2cb3

Please sign in to comment.