Fetching contributors…
Cannot retrieve contributors at this time
128 lines (84 sloc) 3.67 KB
Convert a Replica Set to a Sharded Cluster
.. default-domain:: mongodb
.. contents:: On this page
:backlinks: none
:depth: 1
:class: singlecol
This tutorial converts a single three-member replica set to a sharded
cluster with two shards. Each shard is an independent three-member
replica set. This tutorial is specific to MongoDB |version|. For other
versions of MongoDB, refer to the corresponding version of the MongoDB
The procedure is as follows:
#. Create the initial three-member replica set and insert data into a
collection. See :ref:`convert-setup-initial-set`.
#. Start the config servers and a :program:`mongos`. See
#. Add the initial replica set as a shard. See
#. Create a second shard and add to the cluster. See
#. Shard the desired collection. See :ref:`convert-shard-collection`.
This tutorial uses a total of ten servers: one server for the
:program:`mongos` and three servers each for the first :term:`replica
set`, the second replica set, and the :doc:`config server replica set
Each server must have a resolvable domain, hostname, or IP address
within your system.
The tutorial uses the default data directories (e.g. ``/data/db`` and
``/data/configdb``). Create the appropriate directories with
appropriate permissions. To use different paths, see
:doc:`/reference/configuration-options` .
.. _convert-setup-initial-set:
Set Up Initial Replica Set
This procedure creates the initial three-member replica set ``rs0``.
The replica set members are on the following hosts:
````, ````, and
.. include:: /includes/steps/convert-replica-set-shard-deploy-test-data.rst
For more information on deploying a replica set, see
Restart the Replica Set as a Shard
.. versionchanged:: 3.4
.. include:: /includes/fact-3.4-shardsvr-required.rst
.. include:: /includes/steps/convert-replica-set-shard-aware.rst
.. _convert-deploy-sharding-infrastructure:
Deploy Config Server Replica Set and ``mongos``
This procedure deploys the three-member replica set for the :doc:`config
servers </core/sharded-cluster-config-servers>` and the
- The config servers use the following hosts: ````,
````, and ````.
- The :program:`mongos` uses ````.
.. include:: /includes/steps/convert-replica-set-shard-deploy-infrastructure.rst
.. _convert-add-initial-shard:
Add Initial Replica Set as a Shard
The following procedure adds the initial replica set ``rs0`` as a shard.
.. include:: /includes/steps/convert-replica-set-add-shards.rst
.. _convert-add-second-shard:
Add Second Shard
The following procedure deploys a new replica set ``rs1`` for the
second shard and adds it to the cluster. The replica set members are on
the following hosts: ````,
````, and ````.
.. versionchanged:: 3.4
.. include:: /includes/fact-3.4-shardsvr-required.rst
.. include:: /includes/steps/convert-replica-set-add-new-shard.rst
.. _convert-shard-collection:
Shard a Collection
.. include:: /includes/steps/convert-replica-set-enable-sharding.rst