|
To see if this is still an issue on recent versions, I created a sharded cluster (2 shards), made 4 databases:
MongoDB Enterprise mongos> sh.status()
|
--- Sharding Status ---
|
sharding version: {
|
"_id" : 1,
|
"minCompatibleVersion" : 5,
|
"currentVersion" : 6,
|
"clusterId" : ObjectId("5dc481fcf8e17bc595a56e87")
|
}
|
shards:
|
{ "_id" : "rs0", "host" : "rs0/192.168.103.100:27001,192.168.103.100:27002,192.168.103.100:27003", "state" : 1 }
|
{ "_id" : "rs1", "host" : "rs1/192.168.103.100:27004", "state" : 1 }
|
active mongoses:
|
"3.6.15" : 1
|
autosplit:
|
Currently enabled: yes
|
balancer:
|
Currently enabled: yes
|
Currently running: no
|
Failed balancer rounds in last 5 attempts: 0
|
Migration Results for the last 24 hours:
|
No recent migrations
|
databases:
|
{ "_id" : "config", "primary" : "config", "partitioned" : true }
|
{ "_id" : "shardTest0", "primary" : "rs1", "partitioned" : true }
|
shardTest0.products
|
shard key: { "sku" : 1 }
|
unique: false
|
balancing: true
|
chunks:
|
rs1 1
|
{ "sku" : { "$minKey" : 1 } } -->> { "sku" : { "$maxKey" : 1 } } on : rs1 Timestamp(1, 0)
|
{ "_id" : "shardTest1", "primary" : "rs0", "partitioned" : true }
|
shardTest1.products
|
shard key: { "sku" : 1 }
|
unique: false
|
balancing: true
|
chunks:
|
rs0 1
|
{ "sku" : { "$minKey" : 1 } } -->> { "sku" : { "$maxKey" : 1 } } on : rs0 Timestamp(1, 0)
|
{ "_id" : "shardTest2", "primary" : "rs0", "partitioned" : true }
|
shardTest2.products
|
shard key: { "sku" : 1 }
|
unique: false
|
balancing: true
|
chunks:
|
rs0 1
|
{ "sku" : { "$minKey" : 1 } } -->> { "sku" : { "$maxKey" : 1 } } on : rs0 Timestamp(1, 0)
|
{ "_id" : "shardTest3", "primary" : "rs1", "partitioned" : true }
|
shardTest3.products
|
shard key: { "sku" : 1 }
|
unique: false
|
balancing: true
|
chunks:
|
rs1 1
|
{ "sku" : { "$minKey" : 1 } } -->> { "sku" : { "$maxKey" : 1 } } on : rs1 Timestamp(1, 0)
|
And got the expected error "you need to drop or movePrimary" for the databases:
MongoDB Enterprise mongos> db.adminCommand( { removeShard: "rs1" } )
|
{
|
"msg" : "draining started successfully",
|
"state" : "started",
|
"shard" : "rs1",
|
"note" : "you need to drop or movePrimary these databases",
|
"dbsToMove" : [
|
"shardTest0",
|
"shardTest3"
|
],
|
"ok" : 1,
|
"operationTime" : Timestamp(1573159656, 3),
|
"$clusterTime" : {
|
"clusterTime" : Timestamp(1573159656, 3),
|
"signature" : {
|
"hash" : BinData(0,"3OMeRkCfZkaGl3UlrF/cfDH+siQ="),
|
"keyId" : NumberLong("6756668260294328346")
|
}
|
}
|
}
|
|