This case covers making it easy for users to change a shard key.
In an abstract sense, this would be automation of something that can already be done by very laborious sets of work-by-hand.
db.runCommand() for this "changeShardKey" runs in config or admin database.
It would take as parameters:
- name of from-database
- name of to-database
- name of collection to be re-sharded
- new shard key
All other collections in the database would be copied as-is
The steps involved are:
1. shut down all operations on the from database, leaving only one mongos running.
2. Create new database with to-database name
3. For the collection to be resharded, create the collection in the new database and shard it according to the key provided.
4. Move sets of records in a parallel fashion so it doesn't take forever.
5. for each other collection in from-database, move sets of records.
This should be a fairly common use case and should not require dumping the entire database to disk with mongodump / mongoexport.
- duplicates
-
SERVER-4000 command to change shard key of a collection
- Closed