This page describes how to configure a self-managed MongoDB instance to work with Datastream. You can configure Datastream for both replica sets and sharded clusters.
Replica set
For information about deploying a MongoDB replica set, see Deploy a self-managed replica set in the MongoDB documentation.
To configure Datastream for use with a self-managed MongoDB replica set, follow these steps:
- Install the MongoDB Shell. For information about installing the MongoDB Shell, see Install mongosh.
- Open a terminal window, and run the
mongoshcommand to connect to your replica set or primary node. Create a user for Datastream in the
admindatabase:use admin db.createUser({ user: "USERNAME", pwd: "PASSWORD", roles: [ "readAnyDatabase", {role: "read", db: "admin"} ] })Replace USERNAME and PASSWORD with your preferred username and password.
Sharded cluster
For information about deploying a sharded cluster, see Deploy a sharded cluster in the MongoDB documentation.
To configure Datastream for use with a self-managed MongoDB sharded cluster, follow these steps:
- Install the MongoDB Shell. For information about installing the MongoDB Shell, see Install mongosh.
- Open a terminal window, and run the
mongoshcommand to connect to your MongoDB sharded cluster. Create a Datastream user in every primary shard node and the
mongosquery router:use admin db.createUser({ user: "USERNAME", pwd: "PASSWORD", roles: [ "readAnyDatabase" ] })Replace USERNAME and PASSWORD with your username and password. You can choose any username and password, but they must be identical across all primary shard nodes and the
mongosquery router.To find out which shards are connected to the
mongosquery router, run the following command:db.adminCommand({ listShards: 1 })