Skip to content

DOCS-599 change shard key page faq entry #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/administration/sharding.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions source/faq/sharding.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
<sharding-administration-shard-collection>`. This reality underscores
the important of choosing a good :ref:`shard key <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 <sharding-administration-pre-splitting>` 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?
-----------------------------------------------------------

Expand Down