Skip to content

DOCS-1775: Add some caution notes regarding creating a new hashed collec... #1212

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
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
29 changes: 19 additions & 10 deletions source/tutorial/shard-collection-with-a-hashed-shard-key.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Shard a Collection Using a Hashed Shard Key

.. default-domain:: mongodb

.. contents::
:backlinks: none
:local:

.. versionadded:: 2.4

:ref:`Hashed shard keys <sharding-hashed-sharding>` use a :ref:`hashed
Expand All @@ -14,11 +18,15 @@ For tips on choosing the right field as your hashed shard key, see
:ref:`sharding-hashed-sharding`. For limitations on hashed indexes, see
:ref:`index-hashed-index`.

Basic Procedure
---------------
.. note:: If chunk migrations are in progress while creating a hashed shard key
collection, the initial chunk distribution may be unbalanced until the
balancer automatically balances the collection.

Shard the Collection
--------------------

To shard a collection using a hashed shard key, issue an operation in
the :program:`mongo` shell that resembles the following:
Do an operation in the :program:`mongo` shell that resembles the
following:

.. code-block:: javascript

Expand All @@ -31,14 +39,15 @@ Specify the Initial Number of Chunks
------------------------------------

If you shard an empty collection using a hashed shard key, MongoDB
automatically creates and migrate chunks so that each shard has two
chunks. You can control how many chunks MongoDB creates sharding the
collection using :dbcommand:`shardCollection` with the
automatically creates and migrates empty chunks so that each shard
has two chunks. To control how many chunks MongoDB creates when
sharding the collection, use :dbcommand:`shardCollection` with the
``numInitialChunks`` parameter.

.. include:: /includes/warning-hashed-index-floating-point.rst

.. important:: MongoDB 2.4 add support for hashed shard keys. After
.. important:: MongoDB 2.4 adds support for hashed shard keys. After
sharding a collection with a hashed shard key, you must use the
MongoDB 2.4 or higher :program:`mongos` and :program:`mongod`
instances in your sharded cluster.

.. include:: /includes/warning-hashed-index-floating-point.rst