mongodb remove fragmentation delete the database and add a slice slice (rpm)

After the first slice after we added again to remove this case will be fragmented add failure occurs, you need to log in to add a slice of historical data before deleting this fragmentation of the database such as testdb, delete the database on the slices can be this fragment was added again to the mongos




1, execute the command RemoveShard
db.runCommand ({removeshard: "your_shard_name"})
{MSG: "draining Started successfully", State: "Started", Shard: "mongodb0", OK: 1}
"Note: this command is executed at least twice to successfully remove, execution is completed to the state really deleted, otherwise it is useless to delete is successful, the fragment is in" draining ": true state, not only the fragmentation delete useless in this state success, but also affect subsequent removal of other slicing, met the state can perform another removeshard, the best is to remove fragmentation delete command is repeated until the state is completed;

where there is a need to pay attention : successfully deleted slice if you want to re-join the cluster data directory data must be cleaned before they can re-join Clusters, or even success will not be able to join the stored data, the collection will not be created

in addition: There may be deleted when the whole process of fragmentation of an infinite "draining": true state, such as how long or so, and slice above a block are not moved to another slice, the solution is: the information found in the fragment of the shard config database config set, and the field of draining True to False,





db.runCommand ({removeshard: "your_shard_name" }) {msg: "draining ongoing", state: "ongoing", remaining: {chunks: 42, dbs: 1}, ok: 1}
can be seen from the above, migrating , leaving 42 did not finish the migration.
When remain to 0, this step is over.

3, removal of non-Shard data (if the start that this is the primary can perform steps 3 and 4 to 1 and 2 do not need to perform direct)
if you want to delete slice Shard happens to be primary, so this step, otherwise jump too!
db.runCommand ({movePrimary: "Database name", to: "slice name"})

This is not immediately return a need for a long time, and then will return the following:
{ "Primary": "mongodb1", "the ok": 1}

4, the final clean-up
after the above steps are completed, still need to perform a RemoveShard, cleaning residual data.
db.runCommand ({removeshard: "mongodb0" })
after successful execution, the result will be as follows:
{MSG: "Remove Shard succesfully Completed", Stage: "Completed", Host: "mongodb0", OK:

1} After the show completed, you can ease off in the process mongod.
---------------------
Author: snow Love Qi trace
Source: CSDN
Original: https: //blog.csdn.net/liqi_q/article/details/79047361
Copyright: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/zping/p/11209034.html