首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何禁止默认用户在clickhouse中查看数据库?

如何禁止默认用户在clickhouse中查看数据库?
EN

Stack Overflow用户
提问于 2020-12-09 15:35:23
回答 2查看 789关注 0票数 0

我希望限制默认用户从特定数据库读取表,但revoke命令会给出以下异常。

代码语言:javascript
复制
REVOKE SELECT ON test_db.* FROM default

Received exception from server (version 20.5.2):
Code: 495. DB::Exception: Received from localhost:9000. DB::Exception: Cannot update user `default` in [users.xml] because this storage is readonly. 

users.xml拥有666权限。我想知道如何做到这一点,这样默认的用户就不能查看给定数据库中的表。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-12-09 19:16:24

管理用户有两种方法。旧的XML方式和新的创建/授予/RBAC。

用户默认值由旧的XML-way(硬编码为clickhouse源代码)创建。

您可以完全删除此用户的“默认”。

代码语言:javascript
复制
cat /etc/clickhouse-server/conf.d/z_user_def_remove.xml
<?xml version="1.0" ?>
<yandex>
    <users>
        <default remove="remove"></default>
    </users>
</yandex>

--我用z_命名了该文件,以便将其应用到末尾(作为最后一个文件)。

或者可以限制此用户的数据库“默认”。

代码语言:javascript
复制
cat /etc/clickhouse-server/conf.d/user_def_db.xml
<?xml version="1.0" ?>
<yandex>
    <users>
        <default>
           <allow_databases>
            <database>system</database>
           </allow_databases>
        </default>
    </users>
</yandex>
票数 2
EN

Stack Overflow用户

发布于 2020-12-09 18:52:27

这个答案是基于对默认配置文件服务器间凭据使用默认设置的事实。

我不确定是否应该修改默认用户并在集群之外进行访问。默认情况下,它具有特殊用途,如集群中的服务器间交互

我建议限制在集群节点内使用默认用户:

代码语言:javascript
复制
<!-- users.xml -->
..
    <profiles>
        <default>
            <!-- default-profile is full-access profile (like super user).
            Do NOT restrict permissions of default-profile. The default profile has a special purpose: it must always be present
            and is applied when starting the server and used by internal processes (Buffer storage, Distibuted DDL worker and so on)
            -->
            ..
        </default>
        ..
    </profiles>

    <users>
        <!--
            default user that used ONLY for inter-server interaction.
            Password intentionally is EMPTY so this account MUST be restricted only inner network.
        -->
        <default>
            <password replace="replace"></password>
            <profile replace="replace">default</profile>

            <networks replace="replace">
                <!-- Restrict account to hosts belonging to the cluster. -->
                <host>clickhouse-node-1</host>
                <host>clickhouse-node-2</host>
                ..
            </networks>
        </default>
        ..
    </users>
..

并为您的目标添加一个专用用户,而不是使用默认目标。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65219899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档