From a72d35c8a1865cb36b503fb80f54804bfa1d4ab6 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Thu, 11 Oct 2012 17:02:47 -0400 Subject: [PATCH] DOCS-599 change shard key page faq entry --- source/administration/sharding.txt | 2 ++ source/faq/sharding.txt | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/source/administration/sharding.txt b/source/administration/sharding.txt index 8da08131900..cb677741948 100644 --- a/source/administration/sharding.txt +++ b/source/administration/sharding.txt @@ -146,6 +146,8 @@ use the following procedure as a quick starting point: :term:`primary shard` for that database, where MongoDB stores all data before sharding begins. +.. _sharding-administration-shard-collection: + #. Enable sharding on a per-collection basis. Finally, you must explicitly specify collections to shard. The diff --git a/source/faq/sharding.txt b/source/faq/sharding.txt index fbe22371550..85365f3453a 100644 --- a/source/faq/sharding.txt +++ b/source/faq/sharding.txt @@ -36,6 +36,34 @@ How does sharding work with replication? To use replication with sharding, deploy each :term:`shard` as a :term:`replica set`. +Can I change the shard key after sharding a collection? +------------------------------------------------------- + +No. + +There is no automatic support in MongoDB for changing a shard key +after :ref:`sharding a collection +`. This reality underscores +the important of choosing a good :ref:`shard key `. If you +*must* change a shard key after sharding a collection, the best option +is to: + +- dump all data from MongoDB into an external format. + +- drop the original sharded collection. + +- configure sharding using a more ideal shard key. + +- :ref:`pre-split ` the shard + key range to ensure initial even distribution. + +- restore the dumped data into MongoDB. + +See :dbcommand:`shardCollection`, :method:`sh.shardCollection()`, +:doc:`/administration/sharding`, :ref:`sharding-internals-shard-key` +:doc:`/tutorial/deploy-shard-cluster`, and :issue:`SERVER-4000` for +more information. + What happens to unsharded collections in sharded databases? -----------------------------------------------------------