Standalone ClickHouse Deployment

Collector ClickHouse can run on a dedicated server.

The example uses IP address 10.0.0.10 and TCP port 9001 to connect to the ClickHouse server. Replace them with the server interface address and an available port. Both the collector and backend services must be able to reach this address. Allow access to the port only from the Collector host and protect the connection.

Run commands as root. Install the container runtime and Compose on the database server. On the Collector host, follow the main installation procedure.

Deploy ClickHouse

Create the working directory and download the Compose file on the database server:

mkdir -p /srv/collector-clickhouse && \
cd /srv/collector-clickhouse && \
wget https://docs.mitigator.ru/collector/master/dist/docker-compose.clickhouse-standalone.yml -O docker-compose.yml

Create .env in the same directory:

VERSION=vXX.XX.X
COLLECTOR_CLICKHOUSE_BIND_ADDRESS=10.0.0.10
COLLECTOR_CLICKHOUSE_NATIVE_PORT=9001

Use the same version as Collector. Set memory limits in this .env file according to the ClickHouse settings. Account for the memory required by other applications on the server.

Choose CPUs for ClickHouse

Set COLLECTOR_CLICKHOUSE_CPUS in .env to the CPUs allocated to the database. For example, if logical CPUs 2 and 3 are allocated to it:

COLLECTOR_CLICKHOUSE_CPUS=2-3

Create docker-compose.override.yml in the same directory:

services:
  clickhouse:
    cpuset: "${COLLECTOR_CLICKHOUSE_CPUS}"

The cpuset setting allows all container threads to run only on the selected CPUs.

Start the Database

On the ClickHouse server:

​
docker login docker.mitigator.ru && \
docker-compose up -d
podman login docker.mitigator.ru && \
podman-compose up -d

Connect Collector

On the Collector host, set the following values in /srv/collector/.env:

COLLECTOR_CLICKHOUSE_ADDRESS=10.0.0.10:9001
COLLECTOR_BACKEND_CLICKHOUSE_ADDRESS=10.0.0.10:9001

Both address variables refer to the TCP port of the standalone database. Create or update docker-compose.override.yml in the same directory to disable the embedded ClickHouse and its port mapping:

services:
  clickhouse:
    scale: 0

  gateway:
    ports: !override
    - "179:179"
    - "4567:4567/udp"

Apply the settings on the Collector host:

​
cd /srv/collector && \
docker-compose up -d
cd /srv/collector && \
podman-compose up -d