mongodbsshapache-kafkaapache-kafka-connectdebezium

How to connect to a MongoDB over SSH from Debezium


I want to connect to a MongoDB instance over ssh in my Debezium.

Connection to MongoDB doesn't have a ssh required, and it is going through, but with SSH I am receiving a time out exception.

I am using regular kafka-connect properties as mentioned below.

name=XYZ 
connector.class=io.debezium.connector.mongodb.MongoDbConnector 
tasks.max=1 
database.list=XXXXXX:27017 
connection.url=xxxx:27017 
mongodb.hosts=xxxx:27017 
mongodb.name=xyz 
collection.whitelist=xyz.collection1 
database.whitelist=xyz 
converter.class=org.apache.kafka.connect.json.JsonConverter 
key.converter=org.apache.kafka.connect.json.JsonConverter 
value.converter=org.apache.kafka.connect.json.JsonConverter 
key.converter.schemas.enable=false 
value.converter.schemas.enable=false 

Solution

  • I believe you mean SSL, not SSH...

    The documentation for setting up TLS for Mongo is here, and I'm not immeadiately sure how Debezium handles that, but I do see the mongodb.ssl.enabled property on the Debezium docs


    If you did literally mean SSH, then you might be able to setup an SSH tunnel, to your database1, but this would be external to Kafka Connect process, and you would connect to 127.0.0.1:(tunnel_port)

    Copied from - how to connect to mongodb server via ssh tunnel

    Establish the tunnel on each connect worker.

    ssh -fN -l root -i path/to/id_rsa -L 9999:localhost:27017 mongo-host.com
    

    Then update your Connect config to use 127.0.0.1:9999

    1Disclaimer : Not tested