开始学习《ClickHouse原理解析与应用实践》,写博客作读书笔记。
本文全部内容都来自于书中内容,个人提炼。
第10章:
第11章 管理与运维
11.1 用户配置
user.xml配置文件默认位于/etc/clickhouse-server路径下。
定义用户相关的配置项,包括系统参数的设定、 用户的定义、权限以及熔断机制等。
【这部分的参数可以在会话级别更改。】
11.1.1 用户profile
作用类似于用户角色,多组,预先定义在 user.xml中。
<yandex>
<profiles><!-- 配置profile -->
<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>
……
可以在CLI中直接切换到想要的profile:
SET profile = test1
名称为default的profile是默认配置,必须有,没有报错。
profile 在定义中引用其他的 profile名称可以实现继承。
<normal_inherit> <!-- 只有read查询权限-->
<profile>test1</profile>
<profile>test2</profile>
<distributed_product_mode>deny</distributed_product_mode>
</normal_inherit>
新的参数值会覆盖原有的参数值。
11.1.2 配置约束
constraints标签可以设置一组约束条件。
- Min:最小值约束,在设置相应参数的时候,取值不能小于该阈值。
- Max:最大值约束,在设置相应参数的时候,取值不能大于该阈值。
- Readonly:只读约束,该参数值不允许被修改。
<profiles><!-- 配置profiles -->
<default> <!-- 自定义名称,默认角色-->
<max_memory_usage>10000000000</max_memory_usage>
<distributed_product_mode>allow</distributed_product_mode>
<constraints><!-- 配置约束-->
<max_memory_usage>
<min>5000000000</min>
<max>20000000000</max>
</max_memory_usage>
<distributed_product_mode>
<readonly/>
</distributed_product_mode>
</constraint