Không thể CHÈN VÀO ClickHouse DB do Không đủ quyền: / var / lib / clickhouse / data /

Dec 15 2020

Tôi đã tạo một phiên bản của ClickHouse DB trong một vùng chứa thông qua docker-compos:

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'

Tôi có thể truy cập nó và tìm cơ sở dữ liệu mà tôi đã tạo, nhưng khi tôi chạy

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

Tôi nhận được phản hồi này:

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.

Làm cách nào để nhận được quyền CHÈN VÀO?

Ghi chú:

Tôi không có vấn đề gì khi chạy:

SELECT * FROM simple_people

Tôi đang sử dụng WSL: Ubuntu-20.04

Trả lời

1 DennyCrane Dec 16 2020 at 00:27

Đó là do WSL + docker.

Hãy thử đường dẫn đầy đủ, thay vì ./data

1 sh0ck_wave Dec 21 2020 at 04:42

Tôi đã cài đặt clickhouse trực tiếp trên WSL Ubuntu 18.04 trên máy chủ Windows 2019 mà không cần docker và gặp phải vấn đề tương tự. Trong trường hợp của tôi, tôi đang cố gắng chèn dữ liệu vào bảng với thiết lập chính sách lưu trữ ClickHouse để tất cả dữ liệu sẽ được lưu trữ trong / mnt / f / clickhouse (F: \ clickhouse trên windows). Lỗi tôi nhận được là:

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

Cách khắc phục sự cố là bật tính năng siêu dữ liệu trên WSL, tính năng đồng bộ hóa quyền giữa linux và windows bằng cách gắn lại ổ F: có bật tính năng này. Và sau đó tạo lại thư mục clickhouse nếu nó đã tồn tại.

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

Thông tin bổ sung

Nếu bạn có bất kỳ câu hỏi nào về cách thiết lập chính sách lưu trữ trên clickhouse để chọn vị trí dữ liệu của bạn. Dưới đây là nội dung của /etc/clickhouse-server/config.d/storage.xml của tôi

<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>

Chọn chính sách lưu trữ khi tạo bảng:

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