Skip to content

Instantly share code, notes, and snippets.

@William-Yeh
Created April 15, 2014 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save William-Yeh/10718601 to your computer and use it in GitHub Desktop.
Save William-Yeh/10718601 to your computer and use it in GitHub Desktop.
Simple tool to enable MongoDB balancer.
#!/bin/bash
MONGODB_NAME=$1
MONGODB_PASS=$2
MONGODB_HOST=$3
MONGODB_PORT=${4:-27017}
if [ $# -lt 3 ]; then
echo "Simple tool to enable MongoDB balancer."
echo "Usage: enable-mongodb-balancer.sh username password host [port]"
exit 1
fi
echo -e "use admin\ndb.auth('$MONGODB_NAME','$MONGODB_PASS')\nuse config\nsh.setBalancerState(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