LoginSignup
2
0

More than 1 year has passed since last update.

ClickHouseをWindowsのWSLで動かす

Last updated at Posted at 2022-06-23

ClickHouseをWindows10で動かしたかったので、WSLで動かしました。

  • テスト環境
    • Windows 10 21H2(OSビルド 19044.1706)
    • WSL2
    • Ubuntu 20.04.4 LTS
    • Clickhouse 22.6.1.1985

0 WSLでubuntuを導入

まず、以下の記事を参考にしてWindows 10のWSLでubuntuを導入しました。

Windows 10でLinuxを使う(WSL2) - Qiita

PS C:\temp\wsl> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart ; dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all

1 ClickHouse導入

以下の手順でClickhouseのサーバーとクライアントを導入できました。

Installation | ClickHouse Docs

sudo apt-get install -y apt-transport-https ca-certificates dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754

echo "deb https://packages.clickhouse.com/deb stable main" | sudo tee \
    /etc/apt/sources.list.d/clickhouse.list
sudo apt-get update
sudo apt-get install -y clickhouse-server clickhouse-client

なお、特定のバージョンを指定する場合には

sudo apt-get install clickhouse-server=22.4.5.9 clickhouse-client=22.4.5.9 clickhouse-common-static=22.4.5.9 

で導入します。

passwordはインストーラー実行中に以下のように聞かれました。
パスワードを入力してEnterするとインストーラーが続行します。

hkwd@ABC:~/clickhouse$ sudo apt-get install -y clickhouse-server clickhouse-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  apport-symptoms dconf-gsettings-backend dconf-service gir1.2-packagekitglib-1.0 glib-networking
  glib-networking-common glib-networking-services gsettings-desktop-schemas libappstream4 libdconf1 libglib2.0-bin

---中略----
 chown -R clickhouse-bridge:clickhouse-bridge '/usr/bin/clickhouse-library-bridge'
Enter password for default user:

2 ClickHouseサーバー起動

WSLではsystemctlがそのままでは使えず、上の手順の「sudo service clickhouse-server start」は使えませんでしたので、
sudo clickhouse start
で起動しました。テスト用なので自動起動はしていません。

hkwd@ABC:~$ sudo clickhouse start
 chown -R clickhouse: '/var/run/clickhouse-server/'
Will run clickhouse su '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

3 ClickHouseクライアントを起動

clickhouse-client --password <password>
で、defaultユーザーでクライアントを起動できます。

hkwd@ABC:~$ clickhouse-client --password xxxxx
ClickHouse client version 22.6.1.1985 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 22.6.1 revision 54455.

Warnings:
 * Linux transparent hugepages are set to "always". Check /sys/kernel/mm/transparent_hugepage/enabled

ABC.localdomain :) select 1

SELECT 1

Query id: 50c43eef-b09b-4ffd-937c-7a79759c2937

┌─1─┐
│ 1 │
└───┘

1 row in set. Elapsed: 0.001 sec.

ABC.localdomain :) quit
Bye.
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0