Skip to main content
Connect to the cluster
Last update:

Connect to the cluster

The Kafka cluster can be connected to by DNS address and IP address.

We recommend connecting by DNS address because DNS addresses correspond to node roles and lead to the actual IP addresses of the master and replicas. IP addresses correspond to specific nodes. If the master is unavailable, one of the replicas will assume its role, the master's IP address will change, and the IP connection will stop working.

If the cluster is connected to a private subnet and you want to work with it via DNS, connect the cluster subnet to a cloud router with access to the external network. Use the following instructions Set up internet access via cloud router.

A public IP address cannot be used.

Ports

Use ports to connect to Kafka:

  • 9092 — port for connection without SSL certificate;
  • 9093 — port for connection with SSL certificate.

Ways of connection

View the address for connection

  1. В control panels go to Cloud platformDatabases.
  2. Open the Database Cluster page → tab Connection.
  3. In the block Addresses for connection check out the address.

Connect with SSL

Connecting using TLS/SSL encryption provides a secure connection between your server and the database cluster.

  1. Download the root certificate and place it in the folder ~/.kafka/:

    mkdir -p ~/.kafka/
    wget https://storage.dbaas.selcloud.ru/CA.pem -O ~/.kafka/root.crt
    chmod 600 ~/.kafka/root.crt
  2. Use the connection example for the concumer:

    kcat -C \
    -b <host>:9093 \
    -t <topic_name> \
    -X sasl.username=<user_name> \
    -X sasl.password=<password> \
    -X security.protocol=SASL_SSL \
    -X sasl.mechanisms=SCRAM-SHA-512 \
    -X ssl.ca.location=~/.kafka/root.crt

    Specify:

    • <host> — DNS address of the node;
    • <topic_name> — TOPIC NAME;
    • <user_name> — the name of the user with the role of concumer who has access to the topic;
    • <password> — user password.
  3. Use the connection example for the producer:

    kcat -C \
    -b <host>:9093 \
    -t <topic_name> \
    -X sasl.username=<user_name> \
    -X sasl.password=<password> \
    -X security.protocol=SASL_SSL \
    -X sasl.mechanisms=SCRAM-SHA-512 \
    -X ssl.ca.location=~/.kafka/root.crt

    Specify:

    • <host> — DNS address of the node;
    • <topic_name> — TOPIC NAME;
    • <user_name> — the name of the user with the producer role who has access to the topix;
    • <password> — user password.

Connect without SSL

  1. Open the CLI.

  2. Use the connection example for the concumer:

    kcat -C \
    -b <host>:9092 \
    -t <topic_name> \
    -X sasl.username=<user_name> \
    -X sasl.password=<password> \
    -X security.protocol=SASL_PLAINTEXT \
    -X sasl.mechanisms=SCRAM-SHA-512

    Specify:

    • <host> — DNS address of the node;
    • <topic_name> — TOPIC NAME;
    • <user_name> — the name of the user with the role of concumer who has access to the topic;
    • <password> — user password.
  3. Use the connection example for the producer:

    kcat -P \
    -b <host>:9092 \
    -t <topic_name> \
    -X sasl.username=<user> \
    -X sasl.password=<password> \
    -X security.protocol=SASL_PLAINTEXT \
    -X sasl.mechanisms=SCRAM-SHA-512

    Specify:

    • <host> — DNS address of the node;
    • <topic_name> — TOPIC NAME;
    • <user_name> — the name of the user with the producer role who has access to the topix;
    • <password> — user password.