Skip to content

Instantly share code, notes, and snippets.

@robjens
Last active November 18, 2015 13:18
Show Gist options
  • Select an option

  • Save robjens/5e0f3527de2398d4e12f to your computer and use it in GitHub Desktop.

Select an option

Save robjens/5e0f3527de2398d4e12f to your computer and use it in GitHub Desktop.
MongoDb standalone initialization script
var hosts = [
'hostname.mongo.server'
];
for( var hosti in hosts ){
var hostname = hosts[hosti];
print(hostname);
var dbo = new Mongo(hostname + ":27017").getDB('test');
dbo.setSlaveOk();
var dbarray = dbo.adminCommand('listDatabases').databases
for( var dbi in dbarray ){
var dbname = dbarray[dbi].name;
print(dbname);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment