# Configuring sharding with mongo psmdb

**URL:** <https://forums.percona.com/t/configuring-sharding-with-mongo-psmdb/17173>\
**Category:** Percona Operator for MongoDB\
**Tags:** mysql, percona, mongodb\
**Created:** [August 26, 2022, 7:58pm UTC](https://forums.percona.com/t/configuring-sharding-with-mongo-psmdb/17173 "2022-08-26T19:58:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mialy\_Tatienne\_RAJAO](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mialy_tatienne_rajao/32/7294_2.png) [@Mialy\_Tatienne\_RAJAO](https://forums.percona.com/u/Mialy_Tatienne_RAJAO)\
**Post date:** [August 26, 2022, 7:58pm UTC](https://forums.percona.com/t/configuring-sharding-with-mongo-psmdb/17173/1 "2022-08-26T19:58:47Z")

</div>

Hi all,  
I am trying to configure sharding on my mongodb cluster. I plan to have two or three shards.  
I have understand that I have to add more replicas in the **replsets section** as the number of shards that I need.  
However , there is another parameters under the sharding section: **sharding.configrs.size** , what value should I put on it then ? what is it for ?  
I post here part of my config , thanks for your answer 🙂

```auto
lab-psmdb-db:
  enabled: true
  replsets:
    - name: rs0
      size: 3
      antiAffinityTopologyKey: "kubernetes.io/hostname"
      expose:
        enabled: false
        exposeType: ClusterIP
      podDisruptionBudget:
        maxUnavailable: 1
      arbiter:
        enabled: false
        size: 0
        antiAffinityTopologyKey: "kubernetes.io/hostname"
      resources:
        requests:
          cpu: "500m"
          memory: 1G
      volumeSpec:
        pvc:
          resources:
            requests:
              storage: 5Gi
    - name: rs1
      size: 3
      antiAffinityTopologyKey: "kubernetes.io/hostname"
      expose:
        enabled: false
        exposeType: ClusterIP
      podDisruptionBudget:
        maxUnavailable: 1
      arbiter:
        enabled: false
        size: 0
        antiAffinityTopologyKey: "kubernetes.io/hostname"
      resources:
        requests:
          cpu: "500m"
          memory: 1G
      volumeSpec:
        pvc:
          resources:
            requests:
              storage: 5Gi
  sharding:
    enabled: true
    configrs:
      size: 2
      antiAffinityTopologyKey: "kubernetes.io/hostname"
    configsvrReplSet:
      size: 3
    mongos:
      size: 2
      antiAffinityTopologyKey: "kubernetes.io/hostname"

```

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [August 29, 2022, 9:01am UTC](https://forums.percona.com/t/configuring-sharding-with-mongo-psmdb/17173/2 "2022-08-29T09:01:02Z")

</div>

Hello @Mialy_Tatienne_RAJAO ,

your understanding is correct, if you need two shards - you need 2 replica sets in `spec.replsets`:

```auto
replsets:
  - name: rs0
    ...
  - name: rs1
    ...

```

As for `sharding.configsvrReplSet` - it is the section for [Config Servers] replica set ([https://www.mongodb.com/docs/v5.0/core/sharded-cluster-config-servers/](https://www.mongodb.com/docs/v5.0/core/sharded-cluster-config-servers/)) - they hold metadata for your sharded cluster. `mongos` uses them to route queries.

I’m not sure what `configrs` is and where is it coming from in your snippet. We don’t have it.

Please let me know if it helps.

---

<div class="post-metadata">

**Author:** ![Mialy\_Tatienne\_RAJAO](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mialy_tatienne_rajao/32/7294_2.png) [@Mialy\_Tatienne\_RAJAO](https://forums.percona.com/u/Mialy_Tatienne_RAJAO)\
**Post date:** [September 21, 2022, 8:51am UTC](https://forums.percona.com/t/configuring-sharding-with-mongo-psmdb/17173/3 "2022-09-21T08:51:36Z")

</div>

Thanks for your feedback, very clear 🙂
