美文网首页clickhouseClickHouse中文社区
ClickHouse 用户名密码设置

ClickHouse 用户名密码设置

作者: c3729438b799 | 来源:发表于2017-11-22 21:19 被阅读1214次
    大家都说大数据有价值,但是,有多少人给大数据加了锁?ClickHouse集群,目前线上的都是裸奔,如果对方恶意请求数据,甚至删掉某些数据,就悲剧了

    Config概览


    配置文件:user.xml

    核心配置3部分:

    - profile配置,最大内存、负载方式等(没有特别关注,可见官方文档)

    - 配额设置,单个用户最大能用的资源多少(没有特别关注,可见官方文档)

    - 用户设置,包括用户名和密码

    密码有2种,一种是明文,一种是写sha256sum的Hash值

    官方不建议直接写明文密码

    我们的config文件:


    <yandex>
    <profiles> <default> <max_memory_usage>10000000000</max_memory_usage> <use_uncompressed_cache>0</use_uncompressed_cache> <load_balancing>random</load_balancing> </default> <readonly> <max_memory_usage>10000000000</max_memory_usage> <use_uncompressed_cache>0</use_uncompressed_cache> <load_balancing>random</load_balancing> <readonly>1</readonly> </readonly> </profiles> <quotas> <!-- Name of quota. --> <default> <interval> <duration>3600</duration> <queries>0</queries> <errors>0</errors> <result_rows>0</result_rows> <read_rows>0</read_rows> <execution_time>0</execution_time> </interval> </default> </quotas> <users> <default> <password_sha256_hex>967f3bf355dddfabfca1c9f5cab39352b2ec1cd0b05f9e1e6b8f629705fe7d6e</password_sha256_hex> <networks incl="networks" replace="replace"> <ip>::/0</ip> </networks> <profile>default</profile> <quota>default</quota> </default> <ck> <password_sha256_hex>967f3bf355dddfabfca1c9f5cab39352b2ec1cd0b05f9e1e6b8f629705fe7d6e</password_sha256_hex> <networks incl="networks" replace="replace"> <ip>::/0</ip> </networks> <profile>readonly</profile> <quota>default</quota> </ck> </users></yandex>

    配置解读

    下图定义了两组设置,名字不同

    第二组增加了readonly选项

    下图定义了2个用户,为了方便测试,用了同一个用户名

    ck用户是read模式

    如何生成密码

    PASSWORD=$(base64 < /dev/urandom | head -c8);echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'6lYaUiFi967f3bf355dddfabfca1c9f5cab39352b2ec1cd0b05f9e1e6b8f629705fe7d6e

    权限验证

    默认用户登陆(可以不用指定用户名)

    root@10.xxxx:/data1/clickhouse  # clickhouse-client -h 127.0.0.1 -d gaopeng4 -m -u default --password 6lYaUiFiClickHouse client version 1.1.54289.Connecting to database gaopeng4 at 127.0.0.1:9000 as user default.Connected to ClickHouse server version 1.1.54289.:) create database test1 ;CREATE DATABASE test1Ok.0 rows in set. Elapsed: 0.002 sec.:) ^C

    CH用户登陆

    12345678910111213
    root@10.xxxx:/data1/clickhouse  # clickhouse-client -h 127.0.0.1 -d gaopeng4 -m -u ck --password 6lYaUiFiClickHouse client version 1.1.54289.Connecting to database gaopeng4 at 127.0.0.1:9000 as user ck.Connected to ClickHouse server version 1.1.54289.:) create database test2 ;CREATE DATABASE test2Received exception from server:Code: 164. DB::Exception: Received from 127.0.0.1:9000. DB::Exception: Cannot execute query in readonly mode.0 rows in set. Elapsed: 0.014 sec.
    特别鸣谢 Sina 的Jack Gao 提供稿件

    相关文章

      网友评论

        本文标题:ClickHouse 用户名密码设置

        本文链接:https://www.haomeiwen.com/subject/ozwovxtx.html