Created
May 24, 2020 18:04
-
-
Save autoize/bb3ebc7389b248c9c8cffa08326d99a6 to your computer and use it in GitHub Desktop.
mongo_setup.sh
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 | |
sleep 10 | |
echo SETUP.sh time now: `date +"%T" ` | |
mongo --host mongo1:27017 <<EOF | |
var cfg = { | |
"_id": "rs0", | |
"version": 1, | |
"members": [ | |
{ | |
"_id": 0, | |
"host": "mongo1:27017", | |
"priority": 2 | |
}, | |
{ | |
"_id": 1, | |
"host": "mongo2:27017", | |
"priority": 0 | |
}, | |
{ | |
"_id": 2, | |
"host": "mongo3:27017", | |
"priority": 0 | |
} | |
] | |
}; | |
rs.initiate(cfg, { force: true }); | |
rs.reconfig(cfg, { force: true }); | |
db.getMongo().setReadPref('nearest'); | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment