Skip to content

Instantly share code, notes, and snippets.

@gatesvp
Created March 22, 2011 20:44
Show Gist options
  • Select an option

  • Save gatesvp/882010 to your computer and use it in GitHub Desktop.

Select an option

Save gatesvp/882010 to your computer and use it in GitHub Desktop.
print(' ')
printShardingStatus()
db.runCommand({enablesharding : 'fred_sharded'})
db.runCommand({enablesharding : 'fred_sharded2'})
db.runCommand({shardcollection : 'fred_sharded.temp', key:{'_id':1}})
db.runCommand({shardcollection : 'fred_sharded2.temp', key:{'_id':1}})
db2 = db.getSisterDB('fred_sharded')
db3 = db.getSisterDB('fred_sharded2')
db4 = db.getSisterDB('fred_shardednot')
db2.temp.save({x:1})
db3.temp.save({x:1})
db4.temp.save({x:1})
print(' ')
print('Record Count - Should all be one')
print(db2.temp.count())
print(db3.temp.count())
print(db4.temp.count())
// Notice chunks data here
print(' ')
printShardingStatus()
// This command should only drop "fred_sharded"
// This command should not affect any other DB
print('Dropping Database')
printjson(db2.runCommand({dropDatabase:1}))
// Notice that chunks are no longer present
print(' ')
printShardingStatus()
db2 = db.getSisterDB('fred_sharded')
db3 = db.getSisterDB('fred_sharded2')
db4 = db.getSisterDB('fred_shardednot')
// What happened to db3? We didn't delete it
print(' ')
print('Record Count - Should be 0 1 1')
print(db2.temp.count())
print(db3.temp.count())
print(db4.temp.count())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment