Created
April 15, 2014 09:49
-
-
Save William-Yeh/10718663 to your computer and use it in GitHub Desktop.
Simple tool to disable MongoDB balancer.
This file contains 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 | |
MONGODB_NAME=$1 | |
MONGODB_PASS=$2 | |
MONGODB_HOST=$3 | |
MONGODB_PORT=${4:-27017} | |
if [ $# -lt 3 ]; then | |
echo "Simple tool to disable MongoDB balancer." | |
echo "Usage: disable-mongodb-balancer.sh username password host [port]" | |
exit 1 | |
fi | |
echo -e "use admin\ndb.auth('$MONGODB_NAME','$MONGODB_PASS')\nuse config\nsh.setBalancerState(false)\nwhile (sh.getBalancerState() || sh.isBalancerRunning()) { print(false); sleep(5000); }\nprint(true)\n" | mongo --norc --host $MONGODB_HOST --port $MONGODB_PORT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment