File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,8 @@ use the following procedure as a quick starting point:
146
146
:term:`primary shard` for that database, where MongoDB stores all data
147
147
before sharding begins.
148
148
149
+ .. _sharding-administration-shard-collection:
150
+
149
151
#. Enable sharding on a per-collection basis.
150
152
151
153
Finally, you must explicitly specify collections to shard. The
Original file line number Diff line number Diff line change @@ -36,6 +36,34 @@ How does sharding work with replication?
36
36
To use replication with sharding, deploy each :term:`shard` as a
37
37
:term:`replica set`.
38
38
39
+ Can I change the shard key after sharding a collection?
40
+ -------------------------------------------------------
41
+
42
+ No.
43
+
44
+ There is no automatic support in MongoDB for changing a shard key
45
+ after :ref:`sharding a collection
46
+ <sharding-administration-shard-collection>`. This reality underscores
47
+ the important of choosing a good :ref:`shard key <shard-key>`. If you
48
+ *must* change a shard key after sharding a collection, the best option
49
+ is to:
50
+
51
+ - dump all data from MongoDB into an external format.
52
+
53
+ - drop the original sharded collection.
54
+
55
+ - configure sharding using a more ideal shard key.
56
+
57
+ - :ref:`pre-split <sharding-administration-pre-splitting>` the shard
58
+ key range to ensure initial even distribution.
59
+
60
+ - restore the dumped data into MongoDB.
61
+
62
+ See :dbcommand:`shardCollection`, :method:`sh.shardCollection()`,
63
+ :doc:`/administration/sharding`, :ref:`sharding-internals-shard-key`
64
+ :doc:`/tutorial/deploy-shard-cluster`, and :issue:`SERVER-4000` for
65
+ more information.
66
+
39
67
What happens to unsharded collections in sharded databases?
40
68
-----------------------------------------------------------
41
69
You can’t perform that action at this time.
0 commit comments