> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Set up any MongoDB instance as a source for ClickPipes

# Generic MongoDB source setup guide

<Info>
  If you use MongoDB Atlas, please refer to the specific guide [here](/integrations/clickpipes/mongodb/source/atlas).
</Info>

<h2 id="enable-oplog-retention">
  Enable oplog retention
</h2>

Minimum oplog retention of 24 hours is required for replication. We recommend setting the oplog retention to 72 hours or longer to ensure that the oplog isn't truncated before the initial snapshot is completed.

You can check your current oplog retention by running the following command in the MongoDB shell (you must have `clusterMonitor` role to run this command):

```javascript theme={null}
db.getSiblingDB("admin").serverStatus().oplogTruncation.oplogMinRetentionHours
```

To set the oplog retention to 72 hours, run the following command on each node in the replica set as an admin user:

```javascript theme={null}
db.adminCommand({
    "replSetResizeOplog" : 1,
    "minRetentionHours": 72
})
```

For more details on the `replSetResizeOplog` command and oplog retention, see [MongoDB documentation](https://www.mongodb.com/docs/manual/reference/command/replSetResizeOplog/).

<h2 id="configure-database-user">
  Configure a database user
</h2>

Connect to your MongoDB instance as an admin user and execute the following command to create a user for MongoDB CDC ClickPipes:

```javascript theme={null}
db.getSiblingDB("admin").createUser({
    user: "clickpipes_user",
    pwd: "some_secure_password",
    roles: ["readAnyDatabase", "clusterMonitor"],
})
```

<Note>
  Make sure to replace `clickpipes_user` and `some_secure_password` with your desired username and password.
</Note>

<h2 id="whats-next">
  What's next?
</h2>

You can now [create your ClickPipe](/integrations/clickpipes/mongodb/index) and start ingesting data from your MongoDB instance into ClickHouse Cloud.
Make sure to note down the connection details you used while setting up your MongoDB instance as you will need them during the ClickPipe creation process.
