<a id="install-overview"></a>

# Install ksqlDB for Confluent Platform

ksqlDB is available as a component of Confluent Platform and Confluent Cloud. For Confluent Platform the ksqlDB binaries are located at
[https://www.confluent.io/download/](https://www.confluent.io/download/#confluent-platform) as a part of the Confluent Platform bundle.

ksqlDB must have access to a running Apache Kafka® cluster, which can be in your data center, in a public cloud, Confluent Cloud, etc.

<!-- WARNING: THIS IS A SHARED FILE AND THE SOURCE IS LOCATED IN DOCS-COMMON. DO NOT ADD TO ANY OTHER REPO. -->

Docker support
: You can deploy ksqlDB by using
  [Docker containers](operate-and-deploy/installation/install-ksqldb-with-docker.md#ksqldb-install-configure-with-docker). Starting
  with Confluent Platform 4.1.2, Confluent maintains images at
  [Docker Hub](https://hub.docker.com/r/confluentinc/cp-ksqldb-server/).

Watch the [screencast of Installing and Running KSQL](https://www.youtube.com/embed/icwHpPm-TCA) on YouTube.

## Supported versions and interoperability

For ksqlDB compatibility with Confluent Platform and Kafka Streams, see
[Supported Versions and Interoperability](../installation/versions-interoperability.md#confluent-ksqldb-cp-compatibility).

<a id="install-ksql-server"></a>

## Installation instructions

Follow the instructions at [Quick Start for Confluent Platform](../get-started/platform-quickstart.md#quickstart).

Also, you can install ksqlDB individually by using the
[confluent-ksql package](../installation/available_packages.md#confluent-ksql-package).
For more information, see [Confluent Platform Packages](../installation/available_packages.md#available-packages).

## Scale your ksqlDB server deployment

You can scale ksqlDB by adding more capacity per server (vertically) or by adding
more servers (horizontally). Also, you can scale ksqlDB clusters during live operations
without loss of data. For more information, see
[Scaling ksqlDB](operate-and-deploy/capacity-planning.md#ksqldb-operate-capacity-planning-scaling).

<a id="start-ksql-server"></a>

## Starting the ksqlDB server

The ksqlDB servers are run separately from the ksqlDB CLI client and Kafka brokers. You can deploy servers on remote machines,
VMs, or containers and then the CLI connects to these remote servers.

You can add or remove servers from the same resource pool during live operations, to elastically scale query processing. You
can use different resource pools to support workload isolation. For example, you could deploy separate pools for production
and for testing.

You can only connect to one ksqlDB server at a time. The ksqlDB CLI does not support automatic failover to another ksqlDB server.

![image](ksqldb/images/client-server.png)

Follow these instructions to start ksqlDB server using the `ksql-server-start` script.

1. Specify your ksqlDB server configuration parameters. You can also set any property for the Kafka Streams API, the Kafka
   producer, or the Kafka consumer. The required parameters are `bootstrap.servers` and `listeners`. You can specify
   the parameters in the ksqlDB properties file or the `KSQL_OPTS` environment variable. Properties set with `KSQL_OPTS`
   take precedence over those specified in the properties file.

   A recommended approach is to configure a common set of properties using the ksqlDB configuration file and override
   specific properties as needed, using the `KSQL_OPTS` environment variable.

   Here are the default settings:
   ```none
   bootstrap.servers=localhost:9092
   listeners=http://0.0.0.0:8088
   ```

   For more information, see
   [Configure ksqlDB Server](operate-and-deploy/installation/server-config.md#ksqldb-install-configure-server).
2. Start a server node with this command:
   ```bash
   ksql-server-start ${CONFLUENT_HOME}/etc/ksqldb/ksql-server.properties
   ```
3. Have a look at [this page](operate-and-deploy/installation/server-config.md#ksqldb-install-configure-server-non-interactive-usage)
   for instructions on running ksqlDB in non-interactive (aka headless) mode.

<a id="install-ksql-cli"></a>

## Starting the ksqlDB CLI

The ksqlDB CLI is a client that connects to the ksqlDB servers.

You can start the ksqlDB CLI by providing the connection information to the ksqlDB server.

```bash
LOG_DIR=./ksql_logs ${CONFLUENT_HOME}/bin/ksql http://localhost:8088
```

#### IMPORTANT
By default ksqlDB attempts to store its logs in a directory called `logs` that is relative to the location
of the `ksql` executable. For example, if `ksql` is installed at `/usr/local/bin/ksql`, then it would
attempt to store its logs in `/usr/local/logs`. If you are running `ksql` from the default Confluent Platform
location, `$CONFLUENT_HOME/bin`, you must override this default behavior by using the `LOG_DIR` variable.

<!-- log_limitations_mid -->

After ksqlDB is started, your terminal should resemble this.

```text
                  ===========================================
                  =       _              _ ____  ____       =
                  =      | | _____  __ _| |  _ \| __ )      =
                  =      | |/ / __|/ _` | | | | |  _ \      =
                  =      |   <\__ \ (_| | | |_| | |_) |     =
                  =      |_|\_\___/\__, |_|____/|____/      =
                  =                   |_|                   =
                  =        The Database purpose-built       =
                  =        for stream processing apps       =
                  ===========================================

Copyright 2017-2022 Confluent Inc.

CLI v8.3.1, Server v8.3.1 located at http://localhost:8088
Server Status: RUNNING

Having trouble? Type 'help' (case-insensitive) for a rundown of how things work!

ksql>
```

## Configuring ksqlDB for Confluent Cloud

You can use ksqlDB with a Kafka cluster in Confluent Cloud. For more information, see [Connecting ksqlDB to Confluent Cloud](/cloud/current/cp-component/ksql-cloud-config.html).
