Sometimes there is limited hardware resources, so we have to do some recycling, we have just enabled Shard server recycling, the system first will be removed on the Shard server data on the first evenly distributed on the other Shard server, And then finally kicking the Shard Server off the line, we need to keep calling Db.runcommand ({"Removeshard": "localhost:20002"}) to see where this removal is going:
>Use adminswitched to DB admin> Db.runcommand ({"Removeshard": "localhost:20002"}); {"MSG": "Draining started successfully","State": "Started","Shard": "shard0002","OK": 1}> Db.runcommand ({"Removeshard": "localhost:20002"}); {"MSG": "Draining ongoing","State": "ongoing","Remaining" : {"Chunks": Numberlong (44),"DBS": Numberlong (0)},"OK": 1} ...> Db.runcommand ({"Removeshard": "localhost:20002"}); {"MSG": "Draining ongoing","State": "ongoing","Remaining" : {"Chunks": Numberlong (1),"DBS": Numberlong (0)},"OK": 1}> Db.runcommand ({"Removeshard": "localhost:20002"}); {"MSG": "Removeshard completed successfully","State": "Completed","Shard": "shard0002","OK": 1}> Db.runcommand ({"Removeshard": "localhost:20002"}); {"Assertion": "Can ' t find Shard for:localhost:20002","Assertioncode": 13129,"ErrMsg": "DB assertion Failure","OK": 0}
View Code
After the final removal, when we call Db.runcommand again ({"Removeshard": "localhost:20002"}), the system will error, we have notified that there is no 20002 this port of the Shard Server, Because it has been removed.
>Use testswitched to DB test>db.users_2.stats () {"Sharded":true,"NS": "Test.users_2","Count": 500000,"Size": 48000000,"Avgobjsize": 96,"Storagesize": 95203584,"Nindexes": 1,"Nchunks": 92,"Shards" : {"shard0000" : {"NS": "Test.users_2","Count": 248749,"Size": 23879904,"Avgobjsize": 96,"Storagesize": 61875968,"Numextents": 11,"Nindexes": 1,"Lastextentsize": 15001856,"Paddingfactor": 1,"Flags": 1,"Totalindexsize": 13033472,"Indexsizes" : {"_id_": 13033472},"OK": 1},"Shard0001" : {"NS": "Test.users_2","Count": 251251,"Size": 24120096,"Avgobjsize": 96,"Storagesize": 33327616,"Numextents": 8,"Nindexes": 1,"Lastextentsize": 12079360,"Paddingfactor": 1,"Flags": 1,"Totalindexsize": 10469376,"Indexsizes" : {"_id_": 10469376},"OK": 1}},"OK": 1}
View Code
You can see that the data has been evenly distributed on another 2 shard servers!
MongoDB Grooming Note Removal Shard Server