最近在windows環境借助dockerdesktop新建了一個容器,目的是使用clickhouse/clickhouse-server:24.7.3.42。
創建容器命令如下
docker run -d -p 8123:8123 -p 9000:9000 -p 9009:9009 --ulimit nofile=262144:262144 -v C:\clickhouse24.7.3\db:/var/lib/clickhouse/ -v C:\clickhouse24.7.3\log:/var/log/clickhouse-server/ -v C:\clickhouse24.7.3\conf\users.xml:/etc/clickhouse-server/users.d/*.xml -v C:\clickhouse24.7.3\conf\config.xml:/etc/clickhouse-server/config.d/*.xml --name clickhouse-server-24-7-3-42 clickhouse/clickhouse-server:24.7.3.42
容器創建好之后進入容器執行
clickhouse-client -m --password
create database test;
use test;
CREATE TABLE demo
(
`demo_id` String,
`demo_name` String,
`create_time` DateTime64(3) DEFAULT toDateTime64(now64(), 3)
)
ENGINE = ReplacingMergeTree(create_time)
PARTITION BY toYYYYMMDD(create_time)
PRIMARY KEY (create_time, demo_id)
ORDER BY (create_time, demo_id)
SETTINGS index_granularity = 8192;
insert into demo (demo_id,demo_name) values ("1","name1");
然后就開始報錯
cfb6bb886635 :) insert into demo (demo_id,demo_name) values ('1','name1');
INSERT INTO demo (demo_id, demo_name) FORMAT Values
Query id: 0bb8ef4c-3868-44ce-b486-80799342078b
↘ Progress: 1.00 rows, 24.00 B (396.97 rows/s., 9.53 KB/s.)
1 row in set. Elapsed: 0.060 sec.
Received exception from server (version 24.7.3):
Code: 1001. DB::Exception: Received from localhost:9000. DB::Exception: std::__1::__fs::filesystem::filesystem_error: filesystem error: in rename: Permission denied ["/var/lib/clickhouse/store/5d4/5d4d3bf8-3d1f-4b6d-ad70-87f5b996f37f/tmp_insert_20240827_1_1_0/"] ["/var/lib/clickhouse/store/5d4/5d4d3bf8-3d1f-4b6d-ad70-87f5b996f37f/20240827_1_1_0/"]. (STD_EXCEPTION)
在GitHub上有clickhouse相關的issue說明
WSL problem.
Use internal ext4 filesystem, mapped volumes C:\clickhouse\data are unable to work, because they don't support some ext4 features.
意思就是文件系統格式,沒有給出具體解決方案。
這樣的話我就把本地掛載目錄去掉,重新創建了一個容器。進去執行相同的操作,問題得到了解決。
繼續搜索發現還有其他issue說明
it correctly reports "Permission denied" when the filesystem is misconfigured, e.g., the directories are in different mount points, or the filesystem does not support Unix permissions, or the filesystem reports an error for any other reason.
之所以報這個錯是因為掛載目錄有異常,掛載到不同的目錄或者不支持的文件系統都有可能有報錯。可以針對性的提供解決方案,掛載目錄盡可能在相同的目錄,文件系統改成unix文件系統等,或者直接不使用掛載目錄。