You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为ClickHouse的MergeTree引擎配置HDFS磁盘Kerberos认证?

为MergeTree引擎的HDFS磁盘配置Kerberos认证

要给MergeTree使用的HDFS磁盘配置Kerberos认证,只需将Kerberos相关配置和HDFS磁盘定义结合即可,有两种配置方式可选:

1. 全局Kerberos配置(所有HDFS磁盘共用)

如果所有HDFS磁盘都用相同的Kerberos认证信息,可在ClickHouse主配置根节点添加全局HDFS认证配置,磁盘定义只需保留endpoint:

<clickhouse>
    <!-- 全局HDFS引擎Kerberos配置 -->
    <hdfs>
        <hadoop_kerberos_keytab>/tmp/keytab/clickhouse.keytab</hadoop_kerberos_keytab>
        <hadoop_kerberos_principal>clickuser@TEST.CLICKHOUSE.TECH</hadoop_kerberos_principal>
        <hadoop_security_authentication>kerberos</hadoop_security_authentication>
    </hdfs>

    <!-- 存储配置:定义供MergeTree使用的HDFS磁盘 -->
    <storage_configuration>
        <disks>
            <hdfs>
                <type>hdfs</type>
                <endpoint>hdfs://hdfs1:9000/clickhouse/</endpoint>
            </hdfs>
        </disks>
        <!-- 可选:配置存储策略,让MergeTree数据指向HDFS磁盘 -->
        <policies>
            <hdfs_policy>
                <volumes>
                    <hdfs_volume>
                        <disk>hdfs</disk>
                    </hdfs_volume>
                </volumes>
            </hdfs_policy>
        </policies>
    </storage_configuration>
</clickhouse>

2. 单个HDFS磁盘单独配置Kerberos

如果不同HDFS磁盘需要不同的Kerberos身份,可直接在磁盘定义内添加专属认证参数:

<clickhouse>
    <storage_configuration>
        <disks>
            <hdfs_disk1>
                <type>hdfs</type>
                <endpoint>hdfs://hdfs1:9000/clickhouse/</endpoint>
                <!-- 该磁盘专属的Kerberos配置 -->
                <hadoop_kerberos_keytab>/tmp/keytab/clickhouse_disk1.keytab</hadoop_kerberos_keytab>
                <hadoop_kerberos_principal>clickuser_disk1@TEST.CLICKHOUSE.TECH</hadoop_kerberos_principal>
                <hadoop_security_authentication>kerberos</hadoop_security_authentication>
            </hdfs_disk1>
        </disks>
        <!-- 存储策略配置 -->
        <policies>
            <hdfs_disk1_policy>
                <volumes>
                    <hdfs_volume>
                        <disk>hdfs_disk1</disk>
                    </hdfs_volume>
                </volumes>
            </hdfs_disk1_policy>
        </policies>
    </storage_configuration>
</clickhouse>

后续使用说明

  • 配置完成后重启ClickHouse服务生效。
  • 创建MergeTree表时,通过storage_policy参数指定使用HDFS磁盘的存储策略:
CREATE TABLE test_hdfs_merge_tree
(
    id UInt64,
    name String
)
ENGINE = MergeTree()
ORDER BY id
SETTINGS storage_policy = 'hdfs_policy';

内容的提问来源于stack exchange,提问作者StrangeMann

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 13:05:19