How to install Clickhouse Server

This installation procedure is for Debian/Ubuntu

apt install curl
curl https://clickhouse.com/ | sh

this will download a clickhouse file, you need to run the following command to install

sudo ./clickhouse install

it will ask the following questions

Enter password for default user: 
Allow server to accept connections from the network (default is localhost only), [y/N]: 

and prompt with this

ClickHouse has been successfully installed. Start clickhouse-server with:

sudo clickhouse start

Start clickhouse-client with:

clickhouse-client --password

Now create a unit file

vim /etc/systemd/system/clickhouse-server.service

and add the following content

[Unit]
Description=ClickHouse Server (analytic DBMS for big data)
Requires=network-online.target
# NOTE: that After/Wants=time-sync.target is not enough, you need to ensure
# that the time was adjusted already, if you use systemd-timesyncd you are
# safe, but if you use ntp or some other daemon, you should configure it
# additionaly.
After=time-sync.target network-online.target
Wants=time-sync.target

[Service]
Type=notify

# NOTE: we leave clickhouse watchdog process enabled to be able to see OOM/SIGKILL traces in clickhouse-server.log files.
# If you wish to disable the watchdog and rely on systemd logs just add "Environment=CLICKHOUSE_WATCHDOG_ENABLE=0" line.
User=clickhouse
Group=clickhouse
Restart=always
RestartSec=30
# Since ClickHouse is systemd aware default 1m30sec may not be enough
TimeoutStartSec=0
# %p is resolved to the systemd unit name
RuntimeDirectory=%p
ExecStart=/usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=%t/%p/%p.pid
# Minus means that this file is optional.
EnvironmentFile=-/etc/default/%p
# Bring back /etc/default/clickhouse for backward compatibility
EnvironmentFile=-/etc/default/clickhouse
LimitCORE=infinity
LimitNOFILE=500000
CapabilityBoundingSet=CAP_NET_ADMIN CAP_IPC_LOCK CAP_SYS_NICE CAP_NET_BIND_SERVICE

[Install]
# ClickHouse should not start from the rescue shell (rescue.target).
WantedBy=multi-user.target

Start clickhouse server

systemctl restart clickhouse-server

Check Status

$ systemctl status clickhouse-server

● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)
     Loaded: loaded (/etc/systemd/system/clickhouse-server.service; disabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-12-27 14:01:00 PKT; 11s ago
   Main PID: 4548 (clickhouse-serv)
      Tasks: 673 (limit: 2323)
     Memory: 225.2M
        CPU: 956ms
     CGroup: /system.slice/clickhouse-server.service
             ├─4547 clickhouse-watchdog        --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickho>
             └─4548 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickho>

Dec 27 14:00:59 qryn-server clickhouse-server[4548]: Merging configuration file '/etc/clickhouse-server/config.d/data-paths.xml'.
Dec 27 14:00:59 qryn-server clickhouse-server[4548]: Merging configuration file '/etc/clickhouse-server/config.d/listen.xml'.
Dec 27 14:00:59 qryn-server clickhouse-server[4548]: Merging configuration file '/etc/clickhouse-server/config.d/logger.xml'.
Dec 27 14:00:59 qryn-server clickhouse-server[4548]: Merging configuration file '/etc/clickhouse-server/config.d/openssl.xml'.
Dec 27 14:00:59 qryn-server clickhouse-server[4548]: Merging configuration file '/etc/clickhouse-server/config.d/user-directories.x>
Dec 27 14:00:59 qryn-server clickhouse-server[4548]: Saved preprocessed configuration to '/var/lib/clickhouse/preprocessed_configs/>
Dec 27 14:00:59 qryn-server clickhouse-server[4548]: Processing configuration file '/etc/clickhouse-server/users.xml'.
Dec 27 14:00:59 qryn-server clickhouse-server[4548]: Merging configuration file '/etc/clickhouse-server/users.d/default-password.xm>
Dec 27 14:00:59 qryn-server clickhouse-server[4548]: Saved preprocessed configuration to '/var/lib/clickhouse/preprocessed_configs/>
Dec 27 14:01:00 qryn-server systemd[1]: Started ClickHouse Server (analytic DBMS for big data).

Connect to clickhouse-server with the following command

$ clickhouse-client -u default --password
ClickHouse client version 23.12.1.1214 (official build).
Password for user (default):
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 23.12.1.

Warnings:
 * Linux transparent hugepages are set to "always". Check /sys/kernel/mm/transparent_hugepage/enabled
 * Linux threads max count is too low. Check /proc/sys/kernel/threads-max
 * Available memory at server startup is too low (2GiB).
 * Maximum number of threads is lower than 30000. There could be problems with handling a lot of simultaneous queries.

qryn-server :)

Enjoy ;)

No comments:

Post a Comment

SIPp UAC Scenario to send RTP

Please install the latest sipp ( >=3.7.3 ) wget https://github.com/SIPp/sipp/releases/download/v3.7.3/sipp chmor +x sipp mv sipp /usr/bin...