CLOVER🍀

That was when it all began.

Ubuntu Linux 22.04 LTSに、オープンソースの列指向データベースClickHouseをインストールする

これは、なにをしたくて書いたもの?

ClickHouseに前々から少し興味があったので、まずはインストールをしてみようということで。

ClickHouse

ClickHouseのWebサイトはこちら。

Fast Open-Source OLAP DBMS - ClickHouse

ClickHouseは、OSSのOLAP(online analytical processing)用の高性能な列指向データベースとされています。

Real-Time Data Analytics Platform | ClickHouse

ClickHouse自体はOSS(Apache License Version 2.0)ですが、クラウドサービスとして使うこともできるようです。これはClickHouse Cloudと
呼ばれているようです。

ClickHouse Pricing

ClickHouseの特徴は以下とされています。

  • 高速
  • 水平方向、垂直方向に拡張可能
  • レプリケーションのサポート
  • シェアードナッシングおよびコンピューティングとストレージの分離が可能なアーキテクチャー
  • 他のデータソースとのインテグレーションやフェデレーションが可能

ドキュメントはこちら。

What Is ClickHouse? | ClickHouse Docs

今回はQuick Startとインストールのドキュメントを見ていきたいと思います。

ClickHouse Quick Start | ClickHouse Docs

Install ClickHouse | ClickHouse Docs

ちなみに、インストールドキュメントを見たところWindowsでは動かなさそうな気がしますね…。
Windowsで実行する場合は、WSLを使うことになるようです。

環境

今回の環境はこちら。Ubuntu Linux 22.04 LTSです。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:        22.04
Codename:       jammy


$ uname -srvmpio
Linux 5.15.0-112-generic #122-Ubuntu SMP Thu May 23 07:48:21 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

ClickHouseをシェルスクリプトでインストールする

Quick Startに載っているのはこちらの方法です。

ClickHouse Quick Start | ClickHouse Docs

ClickHouseをダウンロード。

$ curl https://clickhouse.com/ | sh

ダウンロードが完了すると、こんなメッセージが表示されます。

Successfully downloaded the ClickHouse binary, you can run it as:
    ./clickhouse

You can also install it:
    sudo ./clickhouse install

このまま実行もできるし、インストーラーにもなるようです。サイズはこれくらいですね。

$ ll -h clickhouse
-rwxrwxr-x 1 xxxxx xxxxx 110M  6月  9 22:56 clickhouse*

ひとまずヘルプを見てみます。

$ ./clickhouse --help
Decompressing the binary....
usage: clickhouse-local [initial table definition] [--query <query>]
clickhouse-local allows to execute SQL queries on your data files via single command line call. To do so, initially you need to define your data source and its format. After you can execute your SQL queries in usual manner.
There are two ways to define initial table keeping your data. Either just in first query like this:
    CREATE TABLE <table> (<structure>) ENGINE = File(<input-format>, <file>);
Either through corresponding command line parameters --table --structure --input-format and --file.
Main options:
  --help                             print usage summary, combine with --verbose to display all options
  --verbose                          print query and other debugging info
  -V [ --version ]                   print version information and exit
  --version-clean                    print version in machine-readable format and exit
  -C [ --config-file ] arg           config-file path
  -q [ --query ] arg                 query; can be specified multiple times (--query "SELECT 1" --query "SELECT 2"...)
  --queries-file arg                 file path with queries to execute; multiple files can be specified (--queries-file file1 file2...)
  -n [ --multiquery ]                If specified, multiple queries separated by semicolons can be listed after --query. For convenience, it is also possible to omit --query and pass the
                                     queries directly after --multiquery.
  -m [ --multiline ]                 If specified, allow multiline queries (do not send the query on Enter)
  -d [ --database ] arg              database
  --query_kind arg (=initial_query)  One of initial_query/secondary_query/no_query
  --query_id arg                     query_id
  --history_file arg                 path to history file
  --stage arg (=complete)            Request query processing up to specified stage: complete,fetch_columns,with_mergeable_state,with_mergeable_state_after_aggregation,with_mergeable_state_a
                                     fter_aggregation_and_limit
  --progress [=arg(=tty)] (=default) Print progress of queries execution - to TTY: tty|on|1|true|yes; to STDERR non-interactive mode: err; OFF: off|0|false|no; DEFAULT - interactive to TTY,
                                     non-interactive is off
  -A [ --disable_suggestion ]        Disable loading suggestion data. Note that suggestion data is loaded asynchronously through a second connection to ClickHouse server. Also it is
                                     reasonable to disable suggestion if you want to paste a query with TAB characters. Shorthand option -A is for those who get used to mysql client.
  --wait_for_suggestions_to_load     Load suggestion data synchonously.
  -t [ --time ]                      print query execution time to stderr in non-interactive mode (for benchmarks)
  --echo                             in batch mode, print query before execution
  --log-level arg                    log level
  --server_logs_file arg             put server logs into specified file
  --suggestion_limit arg (=10000)    Suggestion limit for how many databases, tables and columns to fetch.
  -f [ --format ] arg                default output format (and input format for clickhouse-local)
  --output-format arg                default output format (this option has preference over --format)
  -E [ --vertical ]                  vertical output format, same as --format=Vertical or FORMAT Vertical or \G at end of command
  --highlight arg (=1)               enable or disable basic syntax highlight in interactive command line
  --ignore-error                     do not stop processing in multiquery mode
  --stacktrace                       print stack traces of exceptions
  --hardware-utilization             print hardware utilization information in progress bar
  --print-profile-events             Printing ProfileEvents packets
  --profile-events-delay-ms arg (=0) Delay between printing `ProfileEvents` packets (-1 - print only totals, 0 - print every single packet)
  --processed-rows                   print the number of locally processed rows
  --interactive                      Process queries-file or --query query and start interactive mode
  --pager arg                        Pipe all output into this command (less or similar)
  --max_memory_usage_in_client arg   Set memory limit in client/local server
  --fuzzer-args arg                  Command line arguments for the LLVM's libFuzzer driver. Only relevant if the application is compiled with libFuzzer.
  -N [ --table ] arg                 name of the initial table
  -S [ --structure ] arg             structure of the initial table (list of column and type names)
  -F [ --file ] arg                  path to file with data of the initial table (stdin if not specified)
  --input-format arg                 input format of the initial table data
  --logger.console [=arg(=1)]        Log to console
  --logger.log arg                   Log file name
  --logger.level arg                 Log level
  --no-system-tables                 do not attach system tables (better startup time)
  --path arg                         Storage path
  --only-system-tables               attach only system tables from specified path
  --top_level_domains_path arg       Path to lists with custom TLDs

Example printing memory used by each Unix user:
ps aux | tail -n +2 | awk '{ printf("%s\t%s\n", $1, $4) }' | clickhouse-local -S "user String, mem Float64" -q "SELECT user, round(sum(mem), 2) as mem_total FROM table GROUP BY user ORDER BY mem_total DESC FORMAT PrettyCompact"
In addition, --param_name=value can be specified for substitution of parameters for parametrized queries.

See also: https://clickhouse.com/docs/en/operations/utilities/clickhouse-local/

実行すると、最初にバイナリの展開を始めました…。

Decompressing the binary....

なんか大きくなりましたけど。

$ ll -h clickhouse
-rwxr-xr-x 1 xxxxx xxxxx 478M  6月  9 23:05 clickhouse*

どうやら実体はclickhouse-localというものらしいですね。

usage: clickhouse-local [initial table definition] [--query <query>]
clickhouse-local allows to execute SQL queries on your data files via single command line call. To do so, initially you need to define your data source and its format. After you can execute your SQL queries in usual manner.

Quick Startに載っているserverやclientといったコマンドはヘルプには現れていないのですが…実行してみましょう。

サーバーを起動。

$ ./clickhouse server

割とあっさり起動します。

2024.06.09 23:08:15.190499 [ 1131 ] {} <Information> Application: Listening for http://127.0.0.1:8123
2024.06.09 23:08:15.190598 [ 1131 ] {} <Information> Application: Listening for native protocol (tcp): 127.0.0.1:9000
2024.06.09 23:08:15.190741 [ 1131 ] {} <Information> Application: Listening for MySQL compatibility protocol: 127.0.0.1:9004
2024.06.09 23:08:15.190756 [ 1131 ] {} <Information> Application: Ready for connections.

なお、サーバーを起動するとカレントディレクトリにディレクトリがたくさん増えました…。

$ ls -l
合計 489152
-rwxr-xr-x 1 xxxxx xxxxx 500836568  6月  9 23:05 clickhouse
drwxr-x--- 4 xxxxx xxxxx      4096  6月  9 23:08 data
drwxr-x--- 2 xxxxx xxxxx      4096  6月  9 23:08 dictionaries_lib
drwxr-x--- 2 xxxxx xxxxx      4096  6月  9 23:08 flags
drwxr-x--- 2 xxxxx xxxxx      4096  6月  9 23:08 format_schemas
drwxr-x--- 2 xxxxx xxxxx      4096  6月  9 23:08 metadata
drwxr-x--- 2 xxxxx xxxxx      4096  6月  9 23:08 metadata_dropped
drwxr-x--- 2 xxxxx xxxxx      4096  6月  9 23:08 preprocessed_configs
-rw-r----- 1 xxxxx xxxxx        58  6月  9 23:08 status
drwxr-x--- 4 xxxxx xxxxx      4096  6月  9 23:08 store
drwxr-x--- 2 xxxxx xxxxx      4096  6月  9 23:08 user_files
drwxr-x--- 2 xxxxx xxxxx      4096  6月  9 23:08 user_scripts
-rw-r----- 1 xxxxx xxxxx        36  6月  9 23:08 uuid

サーバーはフォアグラウンドで動いているので、別のターミナルでクライアントを起動します。

$ ./clickhouse client

接続すると、「[ホスト名] :)」というプロンプトが現れます。

ClickHouse client version 24.6.1.3290 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 24.6.1.

Warnings:
 * Linux threads max count is too low. Check /proc/sys/kernel/threads-max
 * Delay accounting is not enabled, OSIOWaitMicroseconds will not be gathered. You can enable it using `echo 1 > /proc/sys/kernel/task_delayacct` or by using sysctl.
 * 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.

myserver :)

カーネルパラメーターやリソースやらでいろいろと警告されていますが、とりあえずこのまま進めましょう。

テーブルを作成。

CREATE TABLE my_first_table
(
    user_id UInt32,
    message String,
    timestamp DateTime,
    metric Float32
)
ENGINE = MergeTree
PRIMARY KEY (user_id, timestamp)

Query id: 58b03c2d-79ea-4a76-ab3b-f8db082ed88c

Ok.

0 rows in set. Elapsed: 0.040 sec.

データを登録。

myserver :) INSERT INTO my_first_table (user_id, message, timestamp, metric) VALUES
    (101, 'Hello, ClickHouse!',                                 now(),       -1.0    ),
    (102, 'Insert a lot of rows per batch',                     yesterday(), 1.41421 ),
    (102, 'Sort your data based on your commonly-used queries', today(),     2.718   ),
    (101, 'Granules are the smallest chunks of data read',      now() + 5,   3.14159 )

INSERT INTO my_first_table (user_id, message, timestamp, metric) FORMAT Values

Query id: 0613c112-6714-4a75-a778-650fd10250c9

Ok.

4 rows in set. Elapsed: 0.021 sec.

データの取得。

myserver :)  SELECT *
 FROM my_first_table
 ORDER BY timestamp

SELECT *
FROM my_first_table
ORDER BY timestamp ASC

Query id: 397bd051-4461-4eb8-85f7-7c5d1945d9c8

   ┌─user_id─┬─message────────────────────────────────────────────┬───────────timestamp─┬──metric─┐
1. │     102 │ Insert a lot of rows per batch                     │ 2024-06-08 00:00:00 │ 1.41421 │
2. │     102 │ Sort your data based on your commonly-used queries │ 2024-06-09 00:00:00 │   2.718 │
3. │     101 │ Hello, ClickHouse!                                 │ 2024-06-09 23:15:01 │      -1 │
4. │     101 │ Granules are the smallest chunks of data read      │ 2024-06-09 23:15:06 │ 3.14159 │
   └─────────┴────────────────────────────────────────────────────┴─────────────────────┴─────────┘

4 rows in set. Elapsed: 0.013 sec.

とりあえず、ふつうに動かせそうです。

切断。

myserver :) exit
Bye.

いったんサーバーを終了。

ところで、インストールするとどうなるんでしょうね?

試してみましょう。

$ sudo ./clickhouse install

こんなログが出力されました。

Copying ClickHouse binary to /usr/bin/clickhouse.new
Renaming /usr/bin/clickhouse.new to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-server to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-client to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-local to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-benchmark to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-obfuscator to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-git-import to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-compressor to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-format to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-extract-from-config to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-keeper to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-keeper-converter to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-disks to /usr/bin/clickhouse.
Creating symlink /usr/bin/ch to /usr/bin/clickhouse.
Creating symlink /usr/bin/chl to /usr/bin/clickhouse.
Creating symlink /usr/bin/chc to /usr/bin/clickhouse.
Creating clickhouse group if it does not exist.
 groupadd -r clickhouse
Creating clickhouse user if it does not exist.
 useradd -r --shell /bin/false --home-dir /nonexistent -g clickhouse clickhouse
Will set ulimits for clickhouse user in /etc/security/limits.d/clickhouse.conf.
Creating config directory /etc/clickhouse-server.
Creating config directory /etc/clickhouse-server/config.d that is used for tweaks of main server configuration.
Creating config directory /etc/clickhouse-server/users.d that is used for tweaks of users configuration.
Data path configuration override is saved to file /etc/clickhouse-server/config.d/data-paths.xml.
Log path configuration override is saved to file /etc/clickhouse-server/config.d/logger.xml.
User directory path configuration override is saved to file /etc/clickhouse-server/config.d/user-directories.xml.
OpenSSL path configuration override is saved to file /etc/clickhouse-server/config.d/openssl.xml.
Creating log directory /var/log/clickhouse-server.
Creating data directory /var/lib/clickhouse.
Creating pid directory /var/run/clickhouse-server.
 chown -R clickhouse:clickhouse '/var/log/clickhouse-server'
 chown -R clickhouse:clickhouse '/var/run/clickhouse-server'
 chown  clickhouse:clickhouse '/var/lib/clickhouse'
Enter password for the default user:
Password for the default user is saved in file /etc/clickhouse-server/users.d/default-password.xml.
Setting capabilities for clickhouse binary. This is optional.
Allow server to accept connections from the network (default is localhost only), [y/N]: y
The choice is saved in file /etc/clickhouse-server/config.d/listen.xml.
 chown -R clickhouse:clickhouse '/etc/clickhouse-server'

ClickHouse has been successfully installed.

Start clickhouse-server with:
 sudo clickhouse start

Start clickhouse-client with:
 clickhouse-client --password

インストール途中に、デフォルトユーザーのパスワードとネットワーク接続の許可を質問されます。

Enter password for the default user:

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

ログを見るとわかりますが、バイナリは/usr/binにインストールされたようです。

$ which clickhouse
/usr/bin/clickhouse

設定ファイルは/etc/clickhouse-serverに、データは/var/lib/clickhouseに、ログは/var/log/clickhouse-serverの各ディレクトリにありそうです。

起動してみましょう。

$ sudo clickhouse start
 chown -R clickhouse: '/var/run/clickhouse-server/'
Will run sudo --preserve-env -u 'clickhouse' /usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml --pid-file /var/run/clickhouse-server/clickhouse-server.pid --daemon
Waiting for server to start
Waiting for server to start
Server started

接続はclickhouse-clientで行います。

$ clickhouse-client
ClickHouse client version 24.6.1.3290 (official build).
Connecting to localhost:9000 as user default.
Password for user (default):
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 24.6.1.

Warnings:
 * Linux threads max count is too low. Check /proc/sys/kernel/threads-max
 * Delay accounting is not enabled, OSIOWaitMicroseconds will not be gathered. You can enable it using `echo 1 > /proc/sys/kernel/task_delayacct` or by using sysctl.
 * 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.

myserver :)

この手順ではここまでにしておきましょう。

debパッケージからインストールする

次はインストール向けのページに従ってパッケージインストールしてみたいと思います。

Install ClickHouse | ClickHouse Docs

このページ内にQuick Startで行ったスクリプトでのインストール方法も書かれているのですが、こちらは開発やテスト向けのものだった
ようです。

本番環境向けにはパッケージからのインストールがよいみたいですね。

Install ClickHouse / Production Deployments

今回はdebパッケージを使ってインストールします。

Install ClickHouse / Production Deployments / From DEB Packages

必要なパッケージのインストール。

$ sudo apt install -y apt-transport-https ca-certificates curl gnupg

GPG鍵のインポートとaptリポジトリーの追加。

$ curl -fsSL 'https://packages.clickhouse.com/rpm/lts/repodata/repomd.xml.key' | sudo gpg --dearmor -o /usr/share/keyrings/clickhouse-keyring.gpg
$ echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg] https://packages.clickhouse.com/deb stable main" | sudo tee \
    /etc/apt/sources.list.d/clickhouse.list

更新。

$ sudo apt update

ClickHouseのサーバーとクライアントをインストール。

$ sudo apt install clickhouse-server clickhouse-client

実行時のログ。

ClickHouse binary is already located at /usr/bin/clickhouse
Symlink /usr/bin/clickhouse-server already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-server to /usr/bin/clickhouse.
Symlink /usr/bin/clickhouse-client already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-client to /usr/bin/clickhouse.
Symlink /usr/bin/clickhouse-local already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-local to /usr/bin/clickhouse.
Symlink /usr/bin/clickhouse-benchmark already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-benchmark to /usr/bin/clickhouse.
Symlink /usr/bin/clickhouse-obfuscator already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-obfuscator to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-git-import to /usr/bin/clickhouse.
Symlink /usr/bin/clickhouse-compressor already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-compressor to /usr/bin/clickhouse.
Symlink /usr/bin/clickhouse-format already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-format to /usr/bin/clickhouse.
Symlink /usr/bin/clickhouse-extract-from-config already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-extract-from-config to /usr/bin/clickhouse.
Symlink /usr/bin/clickhouse-keeper already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-keeper to /usr/bin/clickhouse.
Symlink /usr/bin/clickhouse-keeper-converter already exists but it points to /clickhouse. Will replace the old symlink to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-keeper-converter to /usr/bin/clickhouse.
Creating symlink /usr/bin/clickhouse-disks to /usr/bin/clickhouse.
Symlink /usr/bin/ch already exists. Will keep it.
Symlink /usr/bin/chl already exists. Will keep it.
Symlink /usr/bin/chc already exists. Will keep it.
Creating clickhouse group if it does not exist.
 groupadd -r clickhouse
Creating clickhouse user if it does not exist.
 useradd -r --shell /bin/false --home-dir /nonexistent -g clickhouse clickhouse
Will set ulimits for clickhouse user in /etc/security/limits.d/clickhouse.conf.
Creating config directory /etc/clickhouse-server/config.d that is used for tweaks of main server configuration.
Creating config directory /etc/clickhouse-server/users.d that is used for tweaks of users configuration.
Config file /etc/clickhouse-server/config.xml already exists, will keep it and extract path info from it.
/etc/clickhouse-server/config.xml has /var/lib/clickhouse/ as data path.
/etc/clickhouse-server/config.xml has /var/log/clickhouse-server/ as log path.
Users config file /etc/clickhouse-server/users.xml already exists, will keep it and extract users info from it.
Creating log directory /var/log/clickhouse-server/.
Creating data directory /var/lib/clickhouse/.
Creating pid directory /var/run/clickhouse-server.
 chown -R clickhouse:clickhouse '/var/log/clickhouse-server/'
 chown -R clickhouse:clickhouse '/var/run/clickhouse-server'
 chown  clickhouse:clickhouse '/var/lib/clickhouse/'
Enter password for the default user:
Password for the default user is saved in file /etc/clickhouse-server/users.d/default-password.xml.
Setting capabilities for clickhouse binary. This is optional.
 chown -R clickhouse:clickhouse '/etc/clickhouse-server'

ClickHouse has been successfully installed.

Start clickhouse-server with:
 sudo clickhouse start

Start clickhouse-client with:
 clickhouse-client --password

Synchronizing state of clickhouse-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable clickhouse-server
Created symlink /etc/systemd/system/multi-user.target.wants/clickhouse-server.service → /lib/systemd/system/clickhouse-server.service.
clickhouse-client (24.5.1.1763) を設定しています ...

インストール先やディレクトリは、見たところ先ほど実行したものと変わらないようですね。

デフォルトユーザーのパスワードを聞かれるところは同じでした。

Enter password for the default user:

ClickHouseサーバーはsystemdにユニットとして登録されています。

$ sudo systemctl status clickhouse-server
○ clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)
     Loaded: loaded (/lib/systemd/system/clickhouse-server.service; enabled; vendor preset: enabled)
     Active: inactive (dead)

起動してみます。

$ sudo systemctl start clickhouse-server

ステータス確認。

$ sudo systemctl status clickhouse-server
● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)
     Loaded: loaded (/lib/systemd/system/clickhouse-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2024-06-09 23:47:06 JST; 8s ago
   Main PID: 1942 (clickhouse-serv)
      Tasks: 662 (limit: 2219)
     Memory: 134.2M
        CPU: 1.198s
     CGroup: /system.slice/clickhouse-server.service
             ├─1941 clickhouse-watchdog "" "" "" "" "" "" "" --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid
             └─1942 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid

 6月 09 23:47:05 myserver systemd[1]: Starting ClickHouse Server (analytic DBMS for big data)...
 6月 09 23:47:05 myserver clickhouse-server[1941]: Processing configuration file '/etc/clickhouse-server/config.xml'.
 6月 09 23:47:05 myserver clickhouse-server[1941]: Logging trace to /var/log/clickhouse-server/clickhouse-server.log
 6月 09 23:47:05 myserver clickhouse-server[1941]: Logging errors to /var/log/clickhouse-server/clickhouse-server.err.log
 6月 09 23:47:05 myserver systemd[1]: clickhouse-server.service: Supervising process 1942 which is not our child. We'll most likely not notice when it exits.

クライアントから接続。

$ clickhouse-client
ClickHouse client version 24.5.1.1763 (official build).
Connecting to localhost:9000 as user default.
Password for user (default):
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 24.5.1.

Warnings:
 * Linux threads max count is too low. Check /proc/sys/kernel/threads-max
 * Delay accounting is not enabled, OSIOWaitMicroseconds will not be gathered. You can enable it using `echo 1 > /proc/sys/kernel/task_delayacct` or by using sysctl.
 * 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.

myserver :)

OKですね。

ところで、ここからさらにClickHouse Keeperというコンポーネントもインストールできるようです。

Install ClickHouse / Production Deployments / From DEB Packages / Install standalone ClickHouse Keeper

ClickHouse Keeperは分散環境を構成する際に必要なコンポーネントで、Apache ZooKeeperと互換性があるようです。

Scaling out | ClickHouse Docs

今回はこちらは見るだけにしておきましょう。

ちなみに、ちゃんとインストールするとバージョンが確認できるようですね。

$ clickhouse --version
ClickHouse local version 24.5.1.1763 (official build).


$ clickhouse-client --version
ClickHouse client version 24.5.1.1763 (official build).

おわりに

オープンソースの列指向データベースであるClickHouseをとりあえずインストールしてみました。

前々から興味があったのですが、実際にインストールして動かしてみることで少しイメージアップしましたね。

現時点ではそう頻繁に扱う予定はないのですが、ちょっと合間を見て触っていければなと思っています。