> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Install ClickHouse on Debian/Ubuntu Linux

# Install ClickHouse on Debian/Ubuntu

> It is recommended to use official pre-compiled `deb` packages for **Debian** or **Ubuntu**.

<Steps>
  <Step>
    <h2 id="review-recommendations">
      Review recommendations
    </h2>

    Before installing ClickHouse, review the following recommendations:

    * **Swap:** Disable the operating system's swap file in production environments.
    * **Disk space:** The ClickHouse binary requires at least 2.5 GB of disk space for installation.
    * **Network:** For distributed deployments (clustering), use at least 10 Gbit network connectivity. Network bandwidth is critical for processing distributed queries with large amounts of intermediate data, as well as for replication.

    **Estimating storage requirements**

    To estimate the disk space needed for your data:

    1. **Estimate data volume:** Take a sample of your data and calculate the average row size, then multiply by the number of rows you plan to store.
    2. **Apply the compression coefficient:** Load a sample into ClickHouse and compare the original data size with the stored table size. Clickstream data, for example, is typically compressed 6-10x.
    3. **Account for replicas:** If you plan to store data in multiple replicas, multiply the estimated volume by the number of replicas.

    For more detailed hardware requirements, see ["Sizing and hardware recommendations"](/guides/oss/best-practices/sizing-and-hardware-recommendations)
  </Step>

  <Step>
    <h2 id="setup-the-debian-repository">
      Set up the Debian repository
    </h2>

    To install ClickHouse run the following commands:

    ```bash theme={null}
    # Install prerequisite packages
    sudo apt-get install -y apt-transport-https ca-certificates curl gnupg

    # Download the ClickHouse GPG key and store it in the keyring
    curl -fsSL 'https://packages.clickhouse.com/rpm/lts/repodata/repomd.xml.key' | sudo gpg --dearmor -o /usr/share/keyrings/clickhouse-keyring.gpg

    # Get the system architecture
    ARCH=$(dpkg --print-architecture)

    # Add the ClickHouse repository to apt sources
    echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg arch=${ARCH}] https://packages.clickhouse.com/deb stable main" | sudo tee /etc/apt/sources.list.d/clickhouse.list

    # Update apt package lists
    sudo apt-get update
    ```

    * You can replace `stable` with `lts` to use different [release kinds](/resources/support-center/knowledge-base/setup-installation/production) based on your needs.
    * You can download and install packages manually from [packages.clickhouse.com](https://packages.clickhouse.com/deb/pool/main/c/).

    <br />

    <Accordion title="Old distributions method for installing the deb-packages">
      ```bash theme={null}
      # Install prerequisite packages
      sudo apt-get install apt-transport-https ca-certificates dirmngr

      # Add the ClickHouse GPG key to authenticate packages
      sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754

      # Add the ClickHouse repository to apt sources
      echo "deb https://packages.clickhouse.com/deb stable main" | sudo tee \
          /etc/apt/sources.list.d/clickhouse.list
          
      # Update apt package lists
      sudo apt-get update

      # Install ClickHouse server and client packages
      sudo apt-get install -y clickhouse-server clickhouse-client

      # Start the ClickHouse server service
      sudo service clickhouse-server start

      # Launch the ClickHouse command line client
      clickhouse-client # or "clickhouse-client --password" if you set up a password.
      ```
    </Accordion>
  </Step>

  <Step>
    <h2 id="install-clickhouse-server-and-client">
      Install ClickHouse server and client
    </h2>

    ```bash theme={null}
    sudo apt-get install -y clickhouse-server clickhouse-client
    ```
  </Step>

  <Step>
    <h2 id="start-clickhouse-server">
      Start ClickHouse
    </h2>

    To start the ClickHouse server, run:

    ```bash theme={null}
    sudo service clickhouse-server start
    ```

    To start ClickHouse client, run:

    ```bash theme={null}
    clickhouse-client
    ```

    If you set up a password for your server, then you will need to run:

    ```bash theme={null}
    clickhouse-client --password
    ```
  </Step>

  <Step>
    <h2 id="install-standalone-clickhouse-keeper">
      Install standalone ClickHouse Keeper
    </h2>

    <Tip>
      In production environments we strongly recommend running ClickHouse Keeper on dedicated nodes.
      In test environments, if you decide to run ClickHouse Server and ClickHouse Keeper on the same server,
      then you don't need to install ClickHouse Keeper as it is included with ClickHouse server.
    </Tip>

    To install `clickhouse-keeper` on standalone ClickHouse Keeper servers, run:

    ```bash theme={null}
    sudo apt-get install -y clickhouse-keeper
    ```
  </Step>

  <Step>
    <h2 id="enable-and-start-clickhouse-keeper">
      Enable and start ClickHouse Keeper
    </h2>

    ```bash theme={null}
    sudo systemctl enable clickhouse-keeper
    sudo systemctl start clickhouse-keeper
    sudo systemctl status clickhouse-keeper
    ```
  </Step>
</Steps>

<h2 id="packages">
  Packages
</h2>

The various deb packages available are detailed below:

| Package                        | Description                                                                                                                                                                                                                                                                          |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `clickhouse-common-static`     | Installs ClickHouse compiled binary files.                                                                                                                                                                                                                                           |
| `clickhouse-server`            | Creates a symbolic link for `clickhouse-server` and installs the default server configuration.                                                                                                                                                                                       |
| `clickhouse-client`            | Creates a symbolic link for `clickhouse-client` and other client-related tools, and installs client configuration files.                                                                                                                                                             |
| `clickhouse-common-static-dbg` | Installs ClickHouse compiled binary files with debug info.                                                                                                                                                                                                                           |
| `clickhouse-keeper`            | Used to install ClickHouse Keeper on dedicated ClickHouse Keeper nodes.  If you're running ClickHouse Keeper on the same server as ClickHouse server, then you don't need to install this package. Installs ClickHouse Keeper and the default ClickHouse Keeper configuration files. |

<br />

<Info>
  If you need to install a specific version of ClickHouse, you have to install all packages with the same version:
  `sudo apt-get install clickhouse-server=21.8.5.7 clickhouse-client=21.8.5.7 clickhouse-common-static=21.8.5.7`
</Info>
