用户配置


User Settings | ClickHouse Documentation

user.xml 配置文件默认位于 /etc/clickhouse-server 路径下,ClickHouse 使用它来定义用户相关的配置项,包括系统参数的设定、用户的定义、权限以及熔断机制等。

用户 profile


用户 profile 的作用类似于用户角色。可以预先在 user.xml 中为 ClickHouse 定义多组 profile,并为每组 profile 定义不同的配置项,以实现配置的复用。

以下面的配置为例:

<yandex>
		<!-- 配置 profile -->
    <profiles>
				<!-- 自定义名称,默认角色 -->
        <default>
            <max_memory_usage>10000000000</max_memory_usage>
            <use_uncompressed_cache>0</use_uncompressed_cache>
        </default>
				<!-- 自定义名称,默认角色 -->
        <test1> 
            <allow_experimental_live_view>1</allow_experimental_live_view>
            <distributed_product_mode>allow</distributed_product_mode>
        </test1>
    </profiles>

在这组配置中,预先定义了 default 和 test1 两组 profile。引用相应的 profile 名称,便会获得相应的配置。


-- 可以在 CLI 中直接切换到想要的 profile,或是在定义用户的时候直接引用。
SET profile = test1

在所有的 profile 配置中,名称为 default 的 profile 将作为默认的配置被加载,所以它必须存在。

profile 配置支持继承,实现继承的方式是在定义中引用其他的 profile 名称,例如下面的例子所示:

<!-- 只有 read 查询权限 -->
<normal_inherit> 
    <profile>test1</profile>
    <profile>test2</profile>
    <distributed_product_mode>deny</distributed_product_mode>
</normal_inherit>

这个名为 normal_inherit 的 profile 继承了 test1 和 test2 的所有配置项,并且使用新的参数值覆盖了 test1 中原有的 distributed_product_mode 配置项。