Docs Menu
Docs Home
/
MongoDB Kafka Connector
/

Connect to MongoDB

On this page

  • Overview
  • How to Connect
  • How to Configure Your Connection
  • Authentication

Learn how to connect the MongoDB Kafka Connector to MongoDB using a connection Uniform Resource Identifier (URI). A connection URI is a string that contains the following information:

  • The address of your MongoDB deployment required

  • Connection settings optional

  • Authentication settings optional

  • Authentication credentials optional

The following is an example of a connection URI for a MongoDB replica set:

mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?replicaSet=myRepl

To learn more about the connection URI format, see Connection String URI Format in the MongoDB Manual.

Specify a connection URI with the following configuration option in both a source and sink connector:

connection.uri=<your connection uri>

To learn more about this configuration option, see the following resources:

  • Source connector configuration options

  • Sink connector configuration options

The MongoDB Kafka Connector uses the MongoDB Java driver to parse your connection URI. The MongoDB Java driver is an artifact that enables Java applications like Kafka Connect to interact with MongoDB.

Important

Driver Version

Version 1.13 of the MongoDB Kafka Connector uses version 4.7 of the MongoDB Java driver.

To learn what connection URI options are available in the connector, see the MongoDB Java driver Connection guide.

All authentication mechanisms available in the MongoDB Java driver are available in the MongoDB Kafka Connector.

The following is an example of a connection URI that authenticates with MongoDB using SCRAM-SHA-256 authentication:

mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=<authenticationDb>&authMechanism=SCRAM-SHA-256

Important

Load Secrets

To avoid storing your authentication secrets as plain text in your connection.uri setting, load your secrets from a secure location as your connector starts. To learn how to load your secrets as your connector starts, see the Externalize Secrets guide from Confluent.

To learn what authentication mechanisms are available, see the MongoDB Java driver Authentication Mechanisms guide.

To learn more about authentication in the connector, see the Security and Authentication guide.

Back

Install the Connector