Top.Mail.Ru
Installing and Removing the ClickHouse DBMS
CTRL+K

Installing and Removing the ClickHouse DBMS

In this article
  • Installing and Removing the ClickHouse DBMS
  • Preparing SSL Certificate and Private Key for ClickHouse Server
  • Running Docker Service with ClickHouse
  • Environment Variables
  • Removing ClickHouse

To install the ClickHouse analytical DBMS, you need a server running a Linux-based OS with the capability to install the Docker software version 17.06 or higher.

Additionally, for Linux servers where ClickHouse will be installed, the kernel version must be:

  • 3.15 and higher when using the EXT4 file system
  • 4.0 and higher when using the XFS file system

If the OS kernel version does not meet the specified requirements, many system functions may be unavailable or operate unpredictably.

The server requirements depend on:

  • The number of employees being monitored
  • The complexity of analytical reports
  • The volume of additional data loaded for analysis

For recommendations on system requirements, refer to the Technical Requirements For The Server And Hardware section.

Preparing SSL Certificate and Private Key for ClickHouse Server

To ensure data transmission between your application and ClickHouse occurs over the secure HTTPS protocol, you need to prepare an SSL certificate and a private key for the server where ClickHouse will be installed. The certificate file must have the .cer extension, and the key file must have the .key extension.

To obtain the certificate, contact the Public Key Infrastructure (PKI) administrator in your organization.

Alternatively, you can use a self-signed certificate. Here is an example of the command for generating such a certificate using OpenSSL on a Linux-based OS:

# openssl req -x509 -nodes -newkey rsa:2048 -days 365 -keyout key.key -out cert.crt
-subj "/C=RU/ST=./L=./O=./OU=./CN=server-name.domain.com/emailAddress=." \
-addext "subjectAltName = IP:1.1.1.1,DNS:server-name.domain.com"

Running Docker Service with ClickHouse

ClickHouse distribution is provided as a container image for the Docker container virtualization system. To install the container with DBMS on a server running a Linux-based OS:

  1. Install the Docker software on the server
  2. Upload the provided archive with the container image to the server
  3. Unpack the archive and load the image to the local Docker repository
    # gunzip operavix-clickhouse-25.3.2.39.tar.gz
    
    # docker load < operavix-clickhouse-25.3.2.39.tar.gz
    
    [!NOTE] The version in the filename is provided as an example. Specify the file that corresponds to the version you are installing.
  4. Execute the command to run Docker Swarm (required to use secrets):
    # docker swarm init --advertise-addr 127.0.0.1:2377 --listen-addr 127.0.0.1:2377
    
  5. Create Docker secrets for secure storage of sensitive data:
    • Create Docker secrets with the user data (login and password) for ClickHouse administrator:
      # echo -n "operavix_user" | docker secret create operavix_app_user
      
      # echo -n "b5w4GDSg36" | sha256sum | awk '{print $1}' | docker secret create operavix_app_user_password_hash -
      
    • Create Docker secrets with the user data (login and password) of a regular ClickHouse DBMS user (with read-only rights):
      # echo -n "operavix_read_user" | docker secret create operavix_external_user -
      
      # echo -n "m26dhdhFdgj" | sha256sum | awk '{print $1}' | docker secret create operavix_external_user_password_hash -
      
    • Create Docker secrets with the SSL certificate and key:
      # docker secret create operavix_clickhouse.crt cert.crt
      
      # docker secret create operavix_clickhouse.key key.key
      
      # openssl dhparam 4096 - | docker secret create operavix_clickhouse_dhparam.pem -
      
  6. Create Docker volumes. They provide permanent storage for the container data:
    # docker volume create operavix-clickhouse
    
    # docker volume create operavix-clickhouse-log
    
  7. Create a service with the Docker command:
    # docker service create --name operavix-clickhouse \
    --secret operavix_app_user \
    --secret operavix_app_user_password_hash \
    --secret operavix_external_user \
    --secret operavix_external_user_password_hash \
    --secret operavix_clickhouse_dhparam.pem \
    --secret operavix_clickhouse.crt \
    --secret operavix_clickhouse.key \
    --publish published=8123,target=8123,mode=host \
    --mount type=volume,src=operavix-clickhouse,target=/var/lib/clickhouse/ \
    --mount type=volume,src=operavix-clickhouse-log,target=/var/log/clickhouse-server \
    --restart-max-attempts 5 \
    --restart-condition "on-failure" \
    dockerhub.office.operavix.com/operavix/operavix-clickhouse:25.3.2.39
    
    [!NOTE] The image name with version is provided as an example. Replace it with the version you are actually installing.

If the service starts successfully, the command should result in the message: verify: Service converged.

The service with the container should begin operating. To ensure that the DBMS is working properly, navigate to https://<server_address>:8123/ping in the browser or use the following command:

# curl https://<server_address>:8123/ping

If everything is set up correctly, the browser should display the message: ОК.

If the message does not appear:

  • Check that the container is running by executing the command:
    # docker ps
    
  • Refer to the application logs by executing the command::
    # docker service logs -f operavix-clickhouse
    
  • Ensure that network routes are open to the server

Check for any errors in the startup steps and try recreating the service.

To remove a non-functional service, use the command:

# docker service rm operavix-clickhouse

Environment Variables

When launching the container, you can pass environment variables that modify the application's configuration files. The available parameters are presented in the table below.

ParameterValueDescription
APP_USER_ACCESS_MANAGEMENT0 or 1
Default: 0
Disallows/allows ClickHouse administrator to create additional users and regulate access rights through SQL queries
LIMIT_MEMORYDefault: 0.9 (90%)The coefficient of maximum memory consumption by the server for processing all SQL queries
PROMETHEUStrue or false
Default: false
Enables the transmission of metrics for Prometheus.

To ensure proper operation, it is necessary to open port 9363 in the container. To do this, add the following to the service launch command:
--publish published=9363,target=9363
SIZE_LOG_FILELog size in megabytes. Default is 1000 (1 GB)Size of technical logs clickhouse-server.log and clickhouse-server.err.log
COUNT_LOG_FILEDefault is 10Number of retained technical log files

You can find more detailed information about Prometheus in the ClickHouse documentation.

Removing ClickHouse

To remove ClickHouse, execute the following commands on the server where it is installed:

# docker service rm operavix-clickhouse
# docker secret rm operavix_app_user operavix_app_user_password_hash operavix_clickhouse.crt operavix_clickhouse.key  operavix_clickhouse_dhparam.pem operavix_external_user operavix_external_user_password_hash
# docker volume rm operavix-clickhouse operavix-clickhouse-log
# docker swarm leave –force

You can find the commands to remove Docker for a specific Linux distribution in the official documentation.

Was the article helpful?

Yes
No
Previous
Differences Between Operavix on Linux and Windows Operating Systems
We use cookies to improve our website for you.