【问题标题】:Issues with loading Maxmind Data into Clickhouse Database using a local file使用本地文件将 Maxmind 数据加载到 Clickhouse 数据库的问题
【发布时间】:2021-10-24 05:26:39
【问题描述】:

我正在尝试将 Maxmind 数据插入 Clickhouse 字典,但将其源定义为本地文件,我可以从中运行我的客户端。

所以要定义我的字典,我使用查询:

CREATE DICTIONARY usage_analytics.city_locations(
    geoname_id UInt64 DEFAULT 0,
    ...
    ...
    ...
    ...
)
PRIMARY KEY geoname_id
SOURCE(File(path '/home/ubuntu/maxmind_csv/GeoLite2-City-Locations-en.csv' format 'CSVWithNames'))
SETTINGS(format_csv_allow_single_quotes = 0)
LAYOUT(HASHED())
LIFETIME(300);

但我一直受到以下错误的打击:

Failed to load dictionary 'usage_analytics.city_locations': std::exception. Code: 1001, type: std::__1::__fs::filesystem::filesystem_error, e.what() = filesystem error: in canonical: No such file or directory [\home/ubuntu/maxmind_csv/GeoLite2-City-Locations-en.csv] [/],

根据文档,我必须使用它的绝对路径,这是我通过使用 readlink 完成的,但它仍然无法检测到我的文件。我正在从远程计算机运行 clickhouse 客户端,并将文件保存在远程计算机上。我是否应该将我的文件放在其他地方或什么地方?

【问题讨论】:

    标签: clickhouse maxmind clickhouse-client


    【解决方案1】:

    此文件似乎不可用,要修复它需要为文件设置正确的所有权:

    chown clickhouse:clickhouse /home/ubuntu/maxmind_csv/GeoLite2-City-Locations-en.csv
    
    # chown -R clickhouse:clickhouse /home/ubuntu/maxmind_csv
    

    【讨论】:

      【解决方案2】:

      .XML 字典允许从任何文件夹读取文件。 SQL 字典没有。

      https://clickhouse.tech/docs/en/sql-reference/dictionaries/external-dictionaries/external-dicts-dict-sources/#dicts-external_dicts_dict_sources-local_file

      通过 DDL 命令(CREATE DICTIONARY ...)创建带有源文件的字典时,源文件需要位于 user_files 目录,以防止 DB 用户访问 ClickHouse 节点上的任意文件。

      /etc/clickhouse-server/config.xml

          <!-- Directory with user provided files that are accessible by 'file' table function. -->
          <user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-04-29
        • 2020-01-25
        • 2021-09-08
        • 1970-01-01
        • 2017-06-28
        • 2015-06-21
        • 1970-01-01
        相关资源
        最近更新 更多