[Yandex Cloud documentation](../../index.md) > [Yandex Data Transfer](../index.md) > [Tutorials](index.md) > Migration > MongoDB cluster

# Migrating MongoDB clusters


To migrate your MongoDB database to Yandex StoreDoc, follow these steps: transfer the data, switch the legacy database to read-only mode, transfer the workload over to the Yandex Cloud database cluster.

Using Data Transfer for migration allows you to:

* Migrate your database with zero downtime.
* Migrate from older to newer versions of MongoDB.
* Eliminate the need for an intermediate VM or for exposing your Yandex StoreDoc target cluster to the internet.

For more information, see [Problems addressed by Yandex Data Transfer](../concepts/use-cases.md).

To use this migration method, enable internet access to the source cluster.


## Required paid resources {#paid-resources}

* Yandex StoreDoc cluster: computing resources allocated to hosts, storage and backup size (see [Yandex StoreDoc pricing](../../storedoc/pricing.md)).
* Public IP addresses if public access is enabled for cluster hosts (see [Virtual Private Cloud pricing](../../vpc/pricing.md)).
* Each transfer: use of computing resources and the number of transferred data rows (see [Data Transfer pricing](../pricing.md)).


## Getting started {#before-you-begin}

[Create a Yandex StoreDoc target cluster](../../storedoc/operations/cluster-create.md) with computing capacity and storage size matching the source database’s environment.

The source and target database names must be the same.

## Transferring data {#data-transfer}

# Migrating data using Yandex Data Transfer {#data-transfer}

1. [Prepare the source cluster](../operations/prepare.md#source-mg).
1. [Prepare the target cluster](../operations/prepare.md#target-mg).
1. [Create a source endpoint](../operations/endpoint/index.md#create) with the following settings:
   
   * **Database type**: `MongoDB`.
   * **Endpoint parameters** → **Connection settings**: `Custom installation`.
   
       Configure the source cluster connection settings.
   
   {% note info %}
   
   Transferring of `Time Series` collections is not supported, so you should [exclude](../operations/endpoint/source/mongodb.md#additional-settings) such collections in the endpoint settings.
   
   {% endnote %}
1. [Create a target endpoint](../operations/endpoint/index.md#create) with the following settings:
   
   * **Database type**: `MongoDB`.
   * **Endpoint parameters** → **Connection settings**: `Yandex StoreDoc cluster`.
   
       Specify the target cluster ID.
1. [Create a transfer](../operations/transfer.md#create) of the _**Snapshot and increment**_ type that will use the new endpoints.
   
   To make large collections (over 1 GB) copy more quickly, enable [parallel copy](../concepts/sharded.md) in the transfer settings. Specify two or more [workers](../concepts/index.md#worker). The collection will be split into the specified number of parts that will be copied concurrently.
   
   For parallel copy to work, the `_id` fields in all documents within the collection must have the same data type. If a transfer detects a type mismatch, the collection will not be split but transferred in a single thread instead. If needed, remove documents with mismatched data types from the collection prior to transfer.
   
   {% note info %}
   
   If a document with a different data type is added to the collection after the transfer starts, the transfer will migrate it at the replication stage after parallel copying. However, when reactivated, the transfer will not be able to split the collection into parts, since the requirement for the same `_id` field type in all documents of the collection will not be met.
   
   {% endnote %}
1. [Activate the transfer](../operations/transfer.md#activate).
1. Wait for the transfer status to change to **Replicating**.
1. Switch the source cluster to "read-only" mode and move the workload to the target cluster.
1. On the [transfer monitoring](../operations/monitoring.md) page, wait until the **Maximum data transfer delay** value drops to zero. This means that all changes made in the source cluster after the initial data copy have been transferred to the target cluster.
1. [Deactivate](../operations/transfer.md#deactivate) the transfer and wait for its status to change to **Stopped**.

    For more information about transfer statuses, see [Transfer lifecycle](../concepts/transfer-lifecycle.md#statuses).

1. [Ensure the transfer is stopped, then delete it](../operations/transfer.md#delete).
1. [Delete the source and target endpoints](../operations/endpoint/index.md#delete).

## Useful links {#see-also}

For other migration methods, see [this Yandex StoreDoc guide](../../storedoc/tutorials/data-migration.md).