I have a sharded cluster (mongo 3.2). I'm trying to set a Maximum Storage Size for a Given Shard, but it fails.
mongos> show dbs
DB_files 820.835GB
config 0.012GB
mongos> config = db.getSiblingDB("config")
config
mongos> config.shards.updateOne({ "_id": "shard0000"},{$set : { "maxSize": 4194304 }})
2016-12-21T15:47:00.467-0300 TypeError: Property 'updateOne' of object config.shards is not a function
So I tried something else:
mongos> use config
switched to db config
mongos> show collections
shards
actionlog
chunks
mongos
collections
lockpings
settings
version
locks
databases
tags
changelog
mongos> db.shards.updateOne({ "_id": "shard0000"},{$set : { "maxSize": 4194304 }})
2016-12-21T15:50:05.842-0300 TypeError: Property 'updateOne' of object config.shards is not a function
The shading is working, balancing, etc.
mongos> db.shards.find({ "_id": "shard0000"})
{ "_id" : "shard0000", "host" : "mongosh1:27017" }
mongos> sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"minCompatibleVersion" : 5,
"currentVersion" : 6,
"clusterId" : ObjectId("57cf4769b7dc19454fe95604")
}
shards:
{ "_id" : "shard0000", "host" : "mongosh1:27017" }
{ "_id" : "shard0001", "host" : "mongosh2:27017" }
databases:
{ "_id" : "DB_files", "primary" : "shard0000", "partitioned" : true }
DB_files.fs.chunks
shard key: { "files_id" : 1, "n" : 1 }
chunks:
shard0001 9136
shard0000 9136
too many chunks to print, use verbose if you want to force print
Any ideas?
Best Answer
Most likely you are using a different shell version than the db version. That is, the output of
db.version()
(the server version) andversion()
(the shell version) should be the same.For example:
Note the identical error message to the one you're seeing. This is because
updateOne
function doesn't exist in earlymongo
shell. However, using the correct version: