clickhosue报DB::Exception: std::__1::__fs::filesystem error: in rename: Permission denied
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/855/855bfefd-93fb-48e6-8c0a-8a90da3f5261/tmp_insert_0d301dd2a7d9fd60dbed3a6833d53711_1_1_0/"] ["/var/lib/clickhouse/store/855/855bfefd-93fb-48e6-8c0a-8a90da3f5261/0d301dd2a7d9fd60dbed3a6833d53711_1_1_0/"]. (STD_EXCEPTION
最近在windows环境借助dockerdesktop新建了一个容器,目的是使用24.7.3.42版本的clickhouse/clickhouse-server:。
创建容器命令如下
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;
然后就开始报错
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.
意思就是文件系统格式不支持,没有给出具体解决方案。
考虑到可能是挂载的目录跟容器通信间的问题,这样的话我就把本地挂载目录去掉,重新创建了一个容器。进去执行相同的操作,没有继续报错。
docker run -d -p 8123:8123 -p 9000:9000 -p 9009:9009 --ulimit nofile=262144:262144 --name clickhouse-server3-24-7-3-42 clickhouse/clickhouse-server:24.7.3.42
继续搜索发现还有其他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文件系统等,或者直接不使用挂载目录。