ClickHouseのインストール手順(CentOS 7環境)

ClickHouseのインストール

公式サイト:https://clickhouse.tech/#quick-start

公式サイトで提供されている方法に従ってインストールします:(順番に実行)

sudo yum install yum-utils
sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/clickhouse.repo
sudo yum install clickhouse-server clickhouse-client

サービスを起動してログイン:

# サービス起動
sudo /etc/init.d/clickhouse-server start

# クライアントログイン
clickhouse-client

公式ドキュメント:https://clickhouse.tech/docs/en/

サービスの各種操作:

# 状態確認
service clickhouse-server status

# サービス起動
service clickhouse-server start

# サービス停止
service clickhouse-server stop

# サービス再起動
service clickhouse-server restart

ディレクトリ設定

データディレクトリを変更します。インストール後のデフォルトディレクトリは/var/lib/clickhouse/です。このディレクトリを大容量のディレクトリに配置する必要があります。例えば、ここでは/data/clickhouse/です。

変更する設定ファイルは/etc/clickhouse-server/config.xmlにあります。

公式の説明:

Server config files are located in `/etc/clickhouse-server/`. Before going further, please notice the `` element in `config.xml`. Path determines the location for data storage, so it should be located on volume with large disk capacity; the default value is `/var/lib/clickhouse/.If you want to adjust the configuration, it's not handy to directly edit `config.xml` file, considering it might get rewritten on future package updates. The recommended way to override the config elements is to create files in config.d directory which serve as "patches" to config.xml.

The default location for server logs is `/var/log/clickhouse-server/`. The server is ready to handle client connections once it logs the `Ready for connections` message.

すべてのデータ保存ディレクトリを/data/clickhouse/ディレクトリに設定します。

vim /etc/clickhouse-server/config.xml

    <!-- データディレクトリへのパス、末尾にスラッシュを含む。 -->
    <path>/data/clickhouse/</path>

    <!-- 処理が難しいクエリ用の一時データのパス。 -->
    <tmp_path>/data/clickhouse/tmp/</tmp_path>

    <!-- 'file'テーブル関数によってアクセス可能なユーザー提供ファイルのディレクトリ。 -->
    <user_files_path>/data/clickhouse/user_files/</user_files_path>

    <!-- SQLコマンドによって作成されたユーザーとロールが保存されるディレクトリへのパス。 -->
    <access_control_path>/data/clickhouse/access/</access_control_path>

    <!-- 種々の入力形式のスキーマファイルを含むディレクトリ。
         ディレクトリが存在しない場合は作成されます。
      -->
    <format_schema_path>/data/clickhouse/format_schemas/</format_schema_path>

変更後、サービスを再起動します:

service clickhouse-server restart

データベースへのログイン

データベースにログインして確認(デフォルトユーザーはdefault、パスワードは空)

clickhouse-clientまたはclickhouse-client -h127.0.0.1のどちらでも可能です。

[root@centf8120 ~]# clickhouse-client -h127.0.0.1
ClickHouse client version 20.6.4.44 (official build).
Connecting to 127.0.0.1:9000 as user default.
Connected to ClickHouse server version 20.6.4 revision 54436.

centf8120.sharding3.db :) show databases;

SHOW DATABASES

┌─name───────────────────────────┐
│ _temporary_and_external_tables │
│ default                        │
│ system                         │
└────────────────────────────────┘

3 rows in set. Elapsed: 0.003 sec. 

centf8120.sharding3.db :) 

タグ: ClickHouse CentOS データベース インストール 設定

6月23日 18:56 投稿