Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
47a43c4
PCSM-283 Skip sharding operations for replica set
rasika-chivate Sep 1, 2026
542e25e
Create sharded-source-to-replica-set-target.md
rasika-chivate Sep 1, 2026
b789c70
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 1, 2026
b43c0bc
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 1, 2026
ed44f22
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 1, 2026
8cadb85
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 2, 2026
7a02a06
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 3, 2026
bccb242
examples before and after cross topology support
rasika-chivate Sep 3, 2026
675429f
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 3, 2026
ba79a33
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 3, 2026
9a972b7
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 3, 2026
15dd913
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 3, 2026
9266ff8
Potential fix for pull request finding
rasika-chivate Sep 3, 2026
e84e92c
Potential fix for pull request finding
rasika-chivate Sep 3, 2026
003e8e2
Potential fix for pull request finding
rasika-chivate Sep 3, 2026
f67df55
Potential fix for pull request finding
rasika-chivate Sep 3, 2026
5a290f0
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 3, 2026
d608fcc
Merge branch 'PCSM-283-Skip-sharding-operations-for-replica-set' of h…
rasika-chivate Sep 3, 2026
090cd53
Potential fix for pull request finding
rasika-chivate Sep 3, 2026
6cd6e66
Address documentation review feedback
Copilot Sep 3, 2026
2d56962
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 3, 2026
a993af9
Merge branch 'PCSM-283-Skip-sharding-operations-for-replica-set' of h…
rasika-chivate Sep 3, 2026
895a309
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 3, 2026
b63a5ff
Potential fix for pull request finding
rasika-chivate Sep 3, 2026
3f8f690
Potential fix for pull request finding
rasika-chivate Sep 3, 2026
db72be9
Update docs/sharded-source-to-replica-set-target.md
rasika-chivate Sep 7, 2026
19e103e
PCSM-335 Use RFC 3339 format for log timestamps
rasika-chivate Sep 7, 2026
bc7fde8
Merge branch 'PCSM-283-Skip-sharding-operations-for-replica-set' of h…
rasika-chivate Sep 7, 2026
91c9e95
Update docs/sharded-source-to-replica-set-target.md
rasika-chivate Sep 7, 2026
271c764
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 7, 2026
4ff0fcb
Merge branch 'PCSM-283-Skip-sharding-operations-for-replica-set' of h…
rasika-chivate Sep 7, 2026
5465fc3
implement feedback from dev
rasika-chivate Sep 7, 2026
d8a7af0
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 7, 2026
3196536
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 7, 2026
2b9c87e
Potential fix for pull request finding
rasika-chivate Sep 7, 2026
644794e
Clarify sharded-target vs replica-set-target guidance in sharding docs
Copilot Sep 7, 2026
ea37bd1
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 7, 2026
8589625
Merge branch 'PCSM-283-Skip-sharding-operations-for-replica-set' of h…
rasika-chivate Sep 7, 2026
470c43d
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 7, 2026
5ef5a00
Potential fix for pull request finding
rasika-chivate Sep 7, 2026
4453888
Split sharding prerequisites by target topology
Copilot Sep 7, 2026
5438446
implement feedback
rasika-chivate Sep 7, 2026
929cde3
Merge branch 'PCSM-283-Skip-sharding-operations-for-replica-set' of h…
rasika-chivate Sep 7, 2026
7421f62
Update sharded-source-to-replica-set-target.md
rasika-chivate Sep 7, 2026
d43e402
Addressed remaining review wording fixes
Copilot Sep 7, 2026
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
1 change: 1 addition & 0 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* **Replica Set to Replica Set**: The source and target replica sets can have different numbers of nodes.
* **Sharded cluster to Sharded cluster**: The source and target sharded clusters can have different numbers of shards. This functionality is in tech preview stage. See [Sharding support in {{pcsm.full_name}}](sharding.md) for details.
* **Sharded cluster to Replica Set**: A sharded source cluster can replicate to a replica set target. Collections that are sharded on the source are created as regular collections on the target. See [Replicate from a sharded cluster to a replica set](sharded-source-to-replica-set-target.md) for details.

## Version requirements

Expand Down
178 changes: 178 additions & 0 deletions docs/sharded-source-to-replica-set-target.md
Comment thread
rasika-chivate marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Replicate from a sharded cluster to a replica set

!!! admonition "Version added: 0.10.0"

{{pcsm.full_name}} (PCSM) supports replication from a sharded MongoDB cluster to a replica set. This lets you migrate data from a sharded deployment without having to recreate the source sharding configuration on the target.

For example, you can use this topology when moving data from a sharded MongoDB Atlas or MongoDB Enterprise deployment to a Percona Server for MongoDB replica set.

For information about sharded cluster support, see [Sharding support in Percona ClusterSync for MongoDB](sharding.md).

## Overview

When the PCSM server starts, it detects that the source is sharded and the target is a replica set.

During the initial sync, PCSM creates every source collection on the target, including the sharded ones, as a regular collection. It doesn't carry over the source shard key, because a replica set has no shards to distribute documents across and doesn't support [`shardCollection` :octicons-link-external-16:](https://www.mongodb.com/docs/manual/reference/command/shardCollection/){:target="_blank"}.

During change replication, PCSM skips `shardCollection` events coming from the source [change stream :octicons-link-external-16:](https://www.mongodb.com/docs/manual/changeStreams/){:target="_blank"} and keeps applying the data changes it supports. No additional configuration is required.

!!! note
A collection that is sharded on the source is created as a regular collection on the replica set target. The collection data is copied, but the target collection isn't sharded.

## What is replicated

| **On the source** | **On the replica set target** |
|---|---|
| Sharded collection | Created as a regular collection. All documents are copied. The shard key isn't applied because it doesn't apply to a replica set. |
Comment thread
rasika-chivate marked this conversation as resolved.
| Unsharded collection | Created and copied as in a replica set to replica set sync. |
| Chunk distribution and primary shard | Not preserved. PCSM replicates data, not cluster metadata. |

## Before you start

* Ensure the source and target MongoDB versions meet the version requirements.
* Configure authentication for both deployments.
* Configure the source connection string with the `mongos` hostname and port. Configure the target connection string with the replica set members.
* Verify that PCSM can connect to both the source sharded cluster and the target replica set.

## Connection string format

Point the source URI at the `mongos` hostname and port. Point the target URI at the replica set members and name the replica set:

**Example**

```sh
PCSM_SOURCE_URI="mongodb://source-user:password@mongos-source:27017/admin"

PCSM_TARGET_URI="mongodb://target-user:password@target1:27017,target2:27017,target3:27017/admin?replicaSet=rs0"
```

## usage

The commands and API endpoints are the same as for any other topology. See, [Percona ClusterSync for MongoDB commands](pcsm-commands.md) for the command reference.

??? example "Walkthrough: sharded source to replica set target"

Follow these steps:
{.power-number}

1. Create two clusters: one sharded source cluster and one target replica set.

2. Create two collections on the sharded cluster:

1. `sharded_coll` (sharded)
2. `plain_collection` (unsharded)

3. Add documents to both the collections.

4. Start replication:

```sh
pcsm start
```

5. Check the replication status. `clonedSizeBytes` matches `estimatedCloneSizeBytes`, and the state is `running`:

```{.text .no-copy}
pcsm status
{
"ok": true,
"state": "running",
"info": "Replicating Changes",
"lagTimeSeconds": 0,
"eventsRead": 0,
"eventsApplied": 0,
"lastReplicatedOpTime": {
"ts": "1787645813.1",
"isoDate": "2026-08-25T08:16:53Z"
},
"initialSync": {
"estimatedCloneSizeBytes": 7490,
"clonedSizeBytes": 7490,
"completed": true,
"cloneCompleted": true
}
}
```

6. Run the same query against both deployments and compare the results to confirm that both collections are present and that document counts match:

```javascript
db.sharded_coll.countDocuments()
db.plain_collection.countDocuments()
```

The collection that was sharded on the source appears here as a regular collection. That is expected.

7. Finalize the sync:

```{.bash data-prompt="$"}
$ pcsm finalize
```

8. Check the status again until the state is `finalized`:

```{.bash data-prompt="$"}
$ pcsm status
```

```{.json .no-copy}
{
"ok": true,
"state": "finalized",
"info": "Finalized",
"lagTimeSeconds": 1,
"eventsRead": 0,
"eventsApplied": 0,
"lastReplicatedOpTime": {
"ts": "1787645817.1",
"isoDate": "2026-08-25T08:16:57Z"
},
"initialSync": {
"estimatedCloneSizeBytes": 7490,
"clonedSizeBytes": 7490,
"completed": true,
"cloneCompleted": true
},
"finalization": {
"completed": true,
"startedAt": "2026-08-25T08:16:57.539447026Z",
"completedAt": "2026-08-25T08:16:57.539557888Z"
}
}
```

9. Check the replication logs and confirm that no errors were recorded. For details, see [Logging in Percona ClusterSync for MongoDB](logging.md).

10. Confirm that the documents for both `plain_collection` and `sharded_coll` got copied to the destination cluster.


## Next steps

* [Install {{pcsm.full_name}}](installation.md)
* [Configure authentication](install/authentication.md)
* [Start replication](install/usage.md)
* [Monitor replication status](install/usage.md#check-the-replication-status)
* [Monitor PCSM performance with Percona Monitoring and Management](pmm-setup.md)


## Learn more

[Shard Keys :octicons-link-external-16:](https://www.mongodb.com/docs/manual/core/sharding-shard-key/){:target="_blank"}


















20 changes: 13 additions & 7 deletions docs/sharding.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,37 @@

Sharding support is available starting with {{pcsm.full_name}} 0.7.0 and is currently in technical preview stage. We encourage you to try it out and share your feedback. This will help us improve the feature in future releases.

{{pcsm.full_name}} supports replication between sharded MongoDB clusters, enabling you to migrate or synchronize data from one sharded deployment to another. This capability allows you to migrate sharded clusters with minimal downtime and synchronize data between sharded clusters for testing or development purposes.
{{pcsm.full_name}} supports replication from a sharded MongoDB cluster to another sharded cluster or to a replica set.

With a sharded target, you can migrate or synchronize data between sharded deployments with minimal downtime. With a replica set target, {{pcsm.full_name}} copies the data and skips the source sharding configuration.
Comment thread
rasika-chivate marked this conversation as resolved.

For details about using a replica set as the target, see [Replicate from a sharded cluster to a replica set](sharded-source-to-replica-set-target.md).

## Overview

The workflow for sharded clusters is similar to replica sets. See [How {{pcsm.full_name}} works](intro.md#replication-workflows) for the complete workflow overview. The key difference is that {{pcsm.short}} connects to `mongos` instances on both the source and target clusters instead of replica set members.
The workflow for sharded clusters is similar to replica sets. See [How {{pcsm.full_name}} works](intro.md#replication-workflows) for the complete workflow overview. The key difference is the target topology: when the target is a sharded cluster, {{pcsm.short}} connects through `mongos` on both the source and target. When the target is a replica set, it connects through the source `mongos` and then the target replica set members instead of a target `mongos`.

Since {{pcsm.short}} connects through `mongos`, the cluster topology doesn't matter. This means the source and target clusters can have different numbers of shards.
In both cases, the source must be a sharded MongoDB deployment. When the target is a sharded cluster, the source and target can have different numbers of shards. A replica set target does not require a target `mongos` instance.

Also, {{pcsm.short}} replicates data and not metadata. This means chunk distribution as well as the primary shard name for a collection may differ on source and target clusters.

## Prerequisites

* {{pcsm.full_name}} version 0.7.0 or later
* Source and target clusters must be sharded MongoDB deployments
* If the target is a sharded MongoDB deployment, {{pcsm.full_name}} version 0.7.0 or later.
* If the target is a replica set, {{pcsm.full_name}} version 0.10.0 or later.
* The source must be a sharded MongoDB deployment.
* The target can be either a sharded MongoDB deployment or a replica set.
Comment thread
rasika-chivate marked this conversation as resolved.
* Both clusters must be running the same MongoDB version. Check [Version requirements](deployment.md#version-requirements) for more information about supported versions.

## Connection string format

When connecting to sharded clusters, use the standard MongoDB connection string format but specify `mongos` hostname and port instead of replica set members:
When connecting to a sharded source or a sharded target, use the standard MongoDB connection string format but specify the `mongos` hostname and port instead of replica set members:

```{.text .no-copy}
mongodb://user:pwd@mongos-host:port/[authdb]?[options]
```

Since {{pcsm.short}} connects through `mongos`, you don't need to specify individual shard members or config servers in the connection string. The `mongos` router handles routing to the appropriate shards.
When the target is a replica set, specify the target replica set members in the target connection string instead of a `mongos` URI. {{pcsm.short}} does not require a target `mongos` instance in that topology.

For detailed information about authentication and connection string configuration, see [Configure authentication in MongoDB](install/authentication.md).

Expand Down
1 change: 1 addition & 0 deletions mkdocs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ nav:
- compare.md
- deployment.md
- sharding.md
- sharded-source-to-replica-set-target.md
- limitations.md
- Get started:
- Quickstart: installation.md
Expand Down