I've been writing a backup script for sharded replica-sets and it's almost done. Except I can't seem to get it to successfully start the balancer backup after everything's all said and done.
Here's the command I'm trying to use to start the balancer back up; keep in mind that this is being run on the actual mongos server via SSH.
sudo -s
mongo -u username -p password --authenticationDatabase db
use config
sh.setBalancerState(true)
exit
exit
exit
I keep getting the following error whenever the scripts hits the startBalancer
function, which runs the above code.
SyncClusterConnection::udpate prepare failed: mongo-conf-0.foo.bar.com:27019:10276
DBClientBase::findN: transport error: mongo-conf-0.foo.bar.com:27019
ns: admin.$cmd query: { resetError: 1 }
I've tried checking against the exit status of the mongo
shell process, using something like
if (code != 0) {
return next('repeat');
} else {
return next();
}
but regardless of what actually occurs in the mongo-shell, the exit code seems to always be 0.
Any ideas on how I can verify that the mongos process is actually connected to all three configs before I try to re-enable the balancer? I assume the problem is that the mongos server tries to connect to the config server before the mongod process had a chance to finish starting up (part of the backup process for sharded replica-sets is shutting down one of the config servers)