権限が不十分なため、ClickHouse DBに挿入できません:/ var / lib / clickhouse / data /

Dec 15 2020

docker-composeを使用して、コンテナー内にClickHouseDBのインスタンスを作成しました。

version: '3'

services:
  ch:
    image: yandex/clickhouse-server
    restart: on-failure
    volumes:
      - '/mnt/c/DevTools/source/storm/clickhouse_setup/data/ch:/var/lib/clickhouse/'
      - './ch_configs:/etc/clickhouse-server/'
    ports:
      - 9000:9000
      - 8123:8123
    ulimits:
      nofile: 262144
    
  client:
    image: yandex/clickhouse-client
    volumes:
      - './client-config.xml:/etc/clickhouse-client/config.xml'

アクセスして作成したデータベースを見つけることはできますが、実行すると

INSERT INTO simple_people (id, first_name, last_name) VALUES(1,'david','lo')

私はこの応答を受け取ります:

Query id: 46ef1af8-5728-425e-87f5-511f7e0e79d1
Received exception from server (version 20.12.3):
Code: 1000. DB::Exception: Received from ch:9000. DB::Exception: Access to file denied: insufficient permissions: /var/lib/clickhouse/data/registry/simple_people/tmp_insert_1_2_2_0.
1 rows in set. Elapsed: 0.068 sec.

INSERT INTOの許可を取得するにはどうすればよいですか?

ノート:

実行に問題はありません:

SELECT * FROM simple_people

私はWSLを使用しています:Ubuntu-20.04

回答

1 DennyCrane Dec 16 2020 at 00:27

これは、WSL + dockerが原因です。

./dataの代わりにフルパスを試してください

1 sh0ck_wave Dec 21 2020 at 04:42

Dockerを使用せずにWindowsServer2019のWSLUbuntu 18.04にクリックハウスを直接インストールしたところ、同じ問題が発生しました。私の場合、すべてのデータが/ mnt / f / clickhouse(WindowsではF:\ clickhouse)に保存されるように、ClickHouseストレージポリシーが設定されたテーブルにデータを挿入しようとしていました。私が得たエラーは:

DB::Exception: Access to file denied: insufficient permissions: /mnt/f/clickhouse/store/1e6/1e69cad8-25a1-4ec5-ab5b-fb32d73b7c8c/tmp_insert_all_2_2_0

この問題の修正は、機能を有効にしてF:ドライブを再マウントすることにより、LinuxとWindowsの間でアクセス許可を同期するWSLのメタデータ機能を有効にすることでした。次に、クリックハウスフォルダがすでに存在する場合は再作成します。

sudo umount /mnt/f
sudo mount -t drvfs F: /mnt/f -o metadata

追加情報

クリックハウスでストレージポリシーを設定してデータの場所を選択する方法について質問がある場合。以下は私の/etc/clickhouse-server/config.d/storage.xmlの内容です

<yandex>
  <storage_configuration>
    <disks>
      <!--
          default disk is special, it always
          exists even if not explicitly
          configured here, but you can't change
          it's path here (you should use <path>
          on top level config instead)
      -->
      <default>
         <!--
             You can reserve some amount of free space
             on any disk (including default) by adding
             keep_free_space_bytes tag
         -->
         <keep_free_space_bytes>1024</keep_free_space_bytes>
      </default>

      <mnt_f>
         <!--
         disk path must end with a slash,
         folder should be writable for clickhouse user
         -->
         <path>/mnt/f/clickhouse/</path>
      </mnt_f>
    </disks>
    <policies>
      <mnt_f_only> <!-- name for new storage policy -->
        <volumes>  
          <mnt_f_volume> <!-- name of volume -->
            <!-- 
                we have only one disk in that volume  
                and we reference here the name of disk
                as configured above in <disks> section
            -->
            <disk>mnt_f</disk>
          </mnt_f_volume>
        </volumes>
      </mnt_f_only>
    </policies>
  </storage_configuration>
</yandex>

テーブルを作成するときにストレージポリシーを選択します。

CREATE TABLE test(
    EventId String,
    EventName Nullable(String),
) ENGINE = MergeTree()
ORDER BY EventId
SETTINGS storage_policy = 'mnt_f_only';