Connect to your cluster using KSQL
This QuickStart assumes that you have created a StreamNative cluster with the Kafka protocol enabled, created a service account, and granted the service account produce
and consume
permissions to a namespace for the target topic.
If you are using a Ursa-Engine powered cluster, please note that KStreams and KSQLDB support in Ursa Engine has certain limitations. It doesn’t support functionalities that require transactions and topic compaction.
This document describes how to connect to your StreamNative cluster using KSQL with SASL/PLAIN authentication.
Before you begin
- Before using an API key, verify that the service account is authorized to access the resources, such as tenants, namespaces, and topics.
- The password for different utilities as
kcat
will be equal totoken:<API KEY>
.
You can follow the instructions to create an API key for the service account you choose to use.
Steps
-
Open the
etc/ksqldb/ksql-server.properties
file and configure the KSQL server with the following properties:bootstrap.servers
: the Kafka service URL of your StreamNative cluster.password
: an API key of your service account.
-
Start the KSQL server.
After the KSQL server is started, you should see the following output:
-
Start the KSQL CLI tool.
After the KSQL CLI tool is started, you should see the following output:
-
Create a stream and tables using the KSQL CLI tool.
a. Create a stream named
riderLocations
:b. Create two tables (
currentLocation
andridersNearMountainView
) to track the latest location of the riders using a materialized view. -
Insert and query data.
a. Open a terminal to run a push query over the stream.
b. Open another terminal to start another KSQL CLI tool and insert data into the stream.
You should see the following output in the first terminal: