Databases Azure

ClickHouse 26.8 LTS on Ubuntu 26.04 on Azure User Guide

| Product: ClickHouse 26.8 LTS on Ubuntu 26.04 LTS on Azure

Overview

This image runs ClickHouse 26.8.53.10, the 26.8 long term support (LTS) release, on Ubuntu 26.04 LTS. ClickHouse is an open source column-oriented database built for real-time analytics: it stores data by column, compresses it heavily and answers aggregations over millions or billions of rows in a fraction of a second, using SQL. The server, clickhouse-client and the Play web UI come from ClickHouse's own signed apt repository (the lts channel), held to the 26.8 series by an apt pin.

ClickHouse's default user has an empty password out of the box. This image never ships it that way. On the first boot of every virtual machine:

  • the default user gets a password unique to that virtual machine, which ClickHouse keeps only as a SHA-256 hash
  • the password is written to /root/clickhouse-credentials.txt (readable by root only)
  • the server starts only after that, so it never answers with an empty or shared password

ClickHouse answers on two ports: 8123, the HTTP interface, which also serves the Play web UI at /play, and 9000, the native protocol that clickhouse-client and most drivers use. Both are unencrypted (see step 7). The MySQL and PostgreSQL compatibility ports and the interserver replication port are switched off. ClickHouse's data path, /var/lib/clickhouse, is its own 32 GiB managed data disk. Ubuntu's unattended security upgrades are switched on.

The default operating system user is the administrator account you choose when you create the virtual machine (azureuser in the examples below).

Prerequisites

  • A Microsoft Azure subscription in which you can create resource groups, virtual networks and virtual machines
  • An SSH key pair for the administrator account
  • A network security group that allows inbound TCP 22 from your own network, and TCP 8123 and 9000 only from the addresses that will query ClickHouse
  • The Azure CLI (az) if you deploy from the command line

The recommended size is Standard_B2ms (2 vCPUs, 8 GiB memory) for evaluation and small data sets. ClickHouse uses every core and as much memory as you give it, so for production analytics choose a memory optimised size such as Standard_E4s_v6 or larger, and grow the data disk to fit your data.

Step 1: Deploy the Virtual Machine

Option A: the Azure Portal

  1. Sign in to the Azure Portal, open Marketplace, search for ClickHouse 26.8 LTS on Ubuntu 26.04 LTS by cloudimg and select Create.
  2. On Basics choose your subscription, a resource group, a region and a name, and pick Standard_B2ms or larger. Under Administrator account choose SSH public key and enter your user name and key.
  3. Under Inbound port rules allow SSH (22). On the Networking tab, after creation, add rules for TCP 8123 and 9000 with your own address or network as the source (step 7). The data disk is on the Disks tab.
  4. Select Review + create, then Create.

First boot finishes a minute or so after the virtual machine shows Running.

Option B: the Azure CLI

Accept the Marketplace terms once per subscription, then create the virtual machine. Replace <your-mgmt-cidr> with the network you connect from, for example 203.0.113.0/24.

az vm image terms accept --urn cloudimg1647283583153:clickhouse-ubuntu-26-04:default:latest

RG=clickhouse-rg
az group create --name $RG --location eastus
az vm create \
  --resource-group $RG \
  --name clickhouse-01 \
  --image cloudimg1647283583153:clickhouse-ubuntu-26-04:default:latest \
  --size Standard_B2ms \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_rsa.pub \
  --public-ip-sku Standard \
  --nsg-rule NONE
az network nsg rule create --resource-group $RG --nsg-name clickhouse-01NSG \
  --name AllowSSHFromMgmt --priority 1000 --access Allow --protocol Tcp \
  --direction Inbound --source-address-prefixes <your-mgmt-cidr> --destination-port-ranges 22
az network nsg rule create --resource-group $RG --nsg-name clickhouse-01NSG \
  --name AllowClickHouseFromMgmt --priority 1010 --access Allow --protocol Tcp \
  --direction Inbound --source-address-prefixes <your-mgmt-cidr> --destination-port-ranges 8123 9000

Step 2: Connect to the Virtual Machine

Find the public IP address, then connect over SSH:

az vm show --resource-group clickhouse-rg --name clickhouse-01 --show-details --query publicIps -o tsv
ssh azureuser@<public-ip>

Check that ClickHouse is running, that first boot has finished, and which version you have:

systemctl status clickhouse-server --no-pager | grep -E '^●|Active:'
test -f /var/lib/cloudimg/clickhouse-firstboot.done && echo 'first boot finished'
clickhouse-server --version
clickhouse-client --version
curl -s http://127.0.0.1:8123/ping
● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)
     Active: active (running) since Thu 2026-12-03 03:23:00 UTC; 2min 22s ago
first boot finished
ClickHouse server version 26.8.53.10 (official build).
ClickHouse client version 26.8.53.10 (official build).
Ok.

ClickHouse 26.8.53.10 active, first boot finished, listening on 8123 and 9000, data on its own disk

Step 3: Read the Password

The password for ClickHouse's default user is in a file only root can read. Show it with:

sudo cat /root/clickhouse-credentials.txt
# ClickHouse 26.8 LTS on Ubuntu 26.04 LTS (cloudimg Azure Marketplace image)
# These credentials are unique to THIS VM, made on its first boot. Store them safely.

CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=******************************** (unique to this VM)
CLICKHOUSE_HOST=<public-ip>
CLICKHOUSE_HTTP_PORT=8123
CLICKHOUSE_NATIVE_PORT=9000
CLICKHOUSE_PLAY_URL=http://<public-ip>:8123/play
...

Your file shows your virtual machine's address and its real password; it is masked here. The file belongs to root and nobody else can read it:

sudo stat -c '%a %U:%G %n' /root/clickhouse-credentials.txt
600 root:root /root/clickhouse-credentials.txt

Step 4: Query with clickhouse-client

clickhouse-client reads the password from the CLICKHOUSE_PASSWORD environment variable, so it never appears on a command line. Load it from the credentials file and run a query:

export CLICKHOUSE_PASSWORD="$(sudo grep -m1 '^CLICKHOUSE_PASSWORD=' /root/clickhouse-credentials.txt | cut -d= -f2-)"
clickhouse-client --user default --query "SELECT version(), currentUser(), (SELECT path FROM system.disks WHERE name = 'default') AS data_path FORMAT PrettyCompactMonoBlock"
   ┌─version()──┬─currentUser()─┬─data_path────────────┐
1. │ 26.8.53.10 │ default       │ /var/lib/clickhouse/ │
   └────────────┴───────────────┴──────────────────────┘

The credentials file with the password masked, and clickhouse-client signed in as default

Run clickhouse-client with no --query for an interactive session. Now create a table, load a million rows and aggregate them:

export CLICKHOUSE_PASSWORD="$(sudo grep -m1 '^CLICKHOUSE_PASSWORD=' /root/clickhouse-credentials.txt | cut -d= -f2-)"
clickhouse-client --user default --multiquery <<'SQL'
CREATE DATABASE IF NOT EXISTS demo;
CREATE TABLE IF NOT EXISTS demo.events
(
    ts DateTime,
    kind LowCardinality(String),
    value UInt32
)
ENGINE = MergeTree
ORDER BY (kind, ts);
TRUNCATE TABLE demo.events;
INSERT INTO demo.events
SELECT now() - number, ['view', 'click', 'purchase'][(number % 3) + 1], number % 1000
FROM numbers(1000000);
SELECT kind, count() AS events, sum(value) AS total, round(avg(value), 1) AS average
FROM demo.events
GROUP BY kind
ORDER BY kind
FORMAT PrettyCompactMonoBlock;
SQL
   ┌─kind─────┬─events─┬─────total─┬─average─┐
1. │ click    │ 333333 │ 166499667 │   499.5 │
2. │ purchase │ 333333 │ 166500000 │   499.5 │
3. │ view     │ 333334 │ 166500333 │   499.5 │
   └──────────┴────────┴───────────┴─────────┘

A million rows loaded and aggregated with clickhouse-client, and the table's size on disk

Step 5: Use the Play Web UI

ClickHouse serves a query editor, the Play web UI, on its HTTP port. Browse to http://<public-ip>:8123/play (after opening 8123 to your address in step 7, or through the SSH tunnel shown there). In the fields at the top enter the user default and the password from step 3, type a query and select Run. The result appears in a table under the editor, with the rows read, the time taken and the memory used.

The Play web UI signed in as default, showing ClickHouse 26.8.53.10, the user, the uptime and the data path /var/lib/clickhouse/

Several statements separated by semicolons run one after another with Run all. Here a MergeTree table is created and 5 million generated rows are inserted with one INSERT ... SELECT:

A table created and 5 million rows loaded from the Play web UI

An aggregation over the 5 million rows by country, with exact distinct counts, averages and the 95th percentile:

An aggregation by country over 5 million rows, answered in a fraction of a second

The system tables describe the server itself. system.parts shows how much space the table takes on the data disk and how well it compresses:

Rows, uncompressed and on-disk size and the compression ratio from system.parts

Once a query has run, the server, user and password fields fold into the key button at the top right.

Step 6: Query over HTTP

Anything that can make an HTTP request can query ClickHouse on port 8123. Send the credentials in a curl config read from standard input, so the password stays off the command line:

CLICKHOUSE_PASSWORD="$(sudo grep -m1 '^CLICKHOUSE_PASSWORD=' /root/clickhouse-credentials.txt | cut -d= -f2-)"
printf 'user = "default:%s"\n' "$CLICKHOUSE_PASSWORD" \
  | curl -s -K - --data-binary 'SELECT kind, count() FROM demo.events GROUP BY kind ORDER BY kind FORMAT JSONCompact' \
    http://127.0.0.1:8123/ | jq -c '.data'
[["click",333333],["purchase",333333],["view",333334]]

From your own machine, use the virtual machine's address instead of 127.0.0.1. To connect clickhouse-client from your machine (it asks for the password):

clickhouse-client --host <public-ip> --port 9000 --user default --ask-password

Step 7: Check the Security Settings and Lock Down the Ports

Apart from SSH on 22, the virtual machine listens on 8123 and 9000 only (on every address, and on the IPv6 loopback); ClickHouse's MySQL (9004), PostgreSQL (9005) and interserver (9009) ports are off. The port 53 lines are Ubuntu's local DNS resolver, on the virtual machine itself:

sudo ss -tlnH | awk '{print $4}' | sort -u
0.0.0.0:22
0.0.0.0:8123
0.0.0.0:9000
127.0.0.53%lo:53
127.0.0.54:53
[::1]:8123
[::1]:9000
[::]:22

Every request needs this virtual machine's password: no password, an empty password and a wrong one are all refused, over HTTP and over the native protocol:

curl -s --data-binary 'SELECT 1' http://127.0.0.1:8123/ | grep -o 'Authentication failed'
printf 'user = "default:not-the-password"\n' | curl -s -K - --data-binary 'SELECT 1' http://127.0.0.1:8123/ | grep -o 'Authentication failed'
clickhouse-client --user default --password '' --query 'SELECT 1' 2>&1 | grep -o 'Authentication failed'
sudo grep -c '<password_sha256_hex>' /etc/clickhouse-server/users.d/cloudimg-default-password.xml
systemctl cat clickhouse-server | grep -E '^ConditionPathExists'
Authentication failed
Authentication failed
Authentication failed
1
ConditionPathExists=/var/lib/cloudimg/clickhouse-bootstrap-ready

No password, a wrong password and an empty password refused; only the password hash stored; the first boot start condition

The fourth line counts the SHA-256 hash that ClickHouse keeps instead of the password. The last line is the setting that keeps the server from starting before first boot has made your password.

Both ports are unencrypted. HTTP on 8123 and the native protocol on 9000 carry your password and your data in plain text, so never open them to the whole internet. Either:

  • allow 8123 and 9000 in the network security group only from your own addresses or virtual network (the AllowClickHouseFromMgmt rule in step 1), or
  • keep 8123 and 9000 closed and reach ClickHouse through an SSH tunnel. From your machine run the line below, then browse to http://localhost:8123/play or point clickhouse-client --host 127.0.0.1 at port 9000:
ssh -L 8123:127.0.0.1:8123 -L 9000:127.0.0.1:9000 azureuser@<public-ip>

For applications in the same virtual network, use the virtual machine's private address and allow 8123 or 9000 from that network only.

Step 8: Change the Password and Add Users

To give the default user a new random password, run the image's helper. It stores the new hash, writes the new password to /root/clickhouse-credentials.txt and prints the start of the hash; ClickHouse picks it up within a few seconds, with no restart:

sudo clickhouse-set-default-password --generate

To choose your own, pipe it in on standard input (it never goes on the command line): printf '%s\n' '<new-password>' | sudo clickhouse-set-default-password.

The default user can manage access with SQL, so create a user for each person or application, with only the rights it needs, rather than sharing default:

CREATE USER analyst IDENTIFIED WITH sha256_password BY '<new-password>';
GRANT SELECT ON demo.* TO analyst;

Step 9: Storage, Updates and Backups

ClickHouse's data is on its own data disk:

df -h --output=target,source,size,avail /var/lib/clickhouse
cat /etc/apt/preferences.d/clickhouse-26-8-lts
apt-cache policy clickhouse-server | sed -n '1,3p'
systemctl is-enabled apt-daily-upgrade.timer; apt-config dump APT::Periodic::Unattended-Upgrade
Mounted on          Filesystem      Size Avail
/var/lib/clickhouse /dev/sdc         32G   30G
# cloudimg: keep ClickHouse on the 26.8 LTS line. apt upgrade takes 26.8.x patch releases from the
# lts channel; moving to a newer LTS line is your choice (edit or remove this file first).
Package: clickhouse-server clickhouse-client clickhouse-common-static clickhouse-keeper
Pin: version 26.8.*
Pin-Priority: 990
clickhouse-server:
  Installed: 26.8.53.10
  Candidate: 26.8.53.10
enabled
APT::Periodic::Unattended-Upgrade "1";

To grow the data disk, stop the virtual machine, resize the disk in the Azure Portal (Disks, the data disk, Size + performance), start it again and grow the file system:

sudo resize2fs "$(findmnt -no SOURCE /var/lib/clickhouse)"

Ubuntu's unattended upgrades apply Ubuntu's security updates every day. ClickHouse itself comes from ClickHouse's apt repository, which unattended upgrades do not cover, so update it yourself. The apt pin keeps you on the 26.8 LTS series, which receives fixes until ClickHouse retires it; read the changelog at https://clickhouse.com/docs/whats-new/changelog, then:

sudo apt-get update
sudo apt-get install --only-upgrade clickhouse-server clickhouse-client clickhouse-common-static
sudo systemctl restart clickhouse-server

For backups, take snapshots of the data disk or use Azure Backup for the whole virtual machine and its data disk. To copy one table out, export it from clickhouse-client, for example SELECT * FROM demo.events INTO OUTFILE 'events.native.gz' FORMAT Native, and copy the file off the virtual machine, for example to Azure Blob Storage with azcopy.

Files and Services

What Where
ClickHouse server clickhouse-server.service
Server configuration /etc/clickhouse-server/config.xml, overrides in /etc/clickhouse-server/config.d/
Network settings (listen addresses, ports switched off) /etc/clickhouse-server/config.d/cloudimg-network.xml
User settings, the default user's password hash /etc/clickhouse-server/users.xml, /etc/clickhouse-server/users.d/cloudimg-default-password.xml
Data /var/lib/clickhouse (data disk)
Server logs /var/log/clickhouse-server/
Credentials file /root/clickhouse-credentials.txt (root only)
Password helper /usr/local/sbin/clickhouse-set-default-password
apt repository and pin /etc/apt/sources.list.d/clickhouse.sources, /etc/apt/preferences.d/clickhouse-26-8-lts
First boot clickhouse-firstboot.service

ClickHouse's configuration files belong to the clickhouse user, as the package sets them. Add your own settings as new files in config.d/ or users.d/ rather than editing config.xml or users.xml; most changes take effect without a restart.

Support

cloudimg's support team is on hand 24 hours a day by email at support@cloudimg.co.uk, with a guaranteed response within 24 hours. Include your subscription ID, the virtual machine name and a short description of the issue.

ClickHouse is open source software licensed under the Apache License 2.0. ClickHouse is a registered trademark of ClickHouse, Inc. This image is built and supported by cloudimg, which is not affiliated with, endorsed by or sponsored by ClickHouse, Inc.