Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-30856

Create Easy Way to Change Shard Key

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 3.4.7
    • Fix Version/s: None
    • Component/s: Admin, Sharding
    • Labels:
      None

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: