打开users.xml
Install vim编辑器:
root@b9c8a34c7b70:/# apt-get update
root@b9c8a34c7b70:/# apt-get install vim
授权可读写权限:
root@b9c8a34c7b70:/etc/clickhouse-server# chmod 777 users.xml
//可写可读可执行
添加用户yanfang
<yanfang>
<password_sha256_hex></password_sha256_hex>
<networks incl="networks" replace="replace">
<ip>::/0</ip>
</networks>
<profile>default</profile>
<quota>default</quota>
<allow_databases>
<database>gf3_cell_dev</database>
<database>gf3_cell_prod</database>
</allow_databases>
</yanfang>
这里也可以不用password_sha256_hex,直接用<password>yanfang</password>也可以,后面就不用生成加密密码。
生成password:
root@b9c8a34c7b70:/etc/clickhouse-server# PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'
q4eWPQr7
3556329bfd521e33ce95bac1354967590c4d33e56c64ac60fd99ebd6f1e0c237
将加密password(3556329bfd521e33ce95bac1354967590c4d33e56c64ac60fd99ebd6f1e0c237)放到<password_sha256_hex></password_sha256_hex>中
登陆:
root@6c0b62bbae13:/etc/clickhouse-server# clickhouse-client -u yanfang -h 127.0.0.1 --password q4eWPQr7
ClickHouse client version 20.12.4.5 (official build).
Connecting to 127.0.0.1:9000 as user yanfang.
Connected to ClickHouse server version 20.12.4 revision 54442.
6c0b62bbae13 :)
配置RBAC权限:
在users.xml中的用户配置加一行:
<access_management>1</access_management>
以下为尝试工具登陆clickhouse失败案例:
IDEA工具登陆clickhouse
(1)找到clickhouse-server所在container的IP
root@6c0b62bbae13:/etc/clickhouse-server# hostname -I
(2)关闭防火墙
查询系统版本:
root@6c0b62bbae13:/etc/clickhouse-server# uname -r
4.9.13-moby
或:
root@6c0b62bbae13:/# cat /proc/version
Linux version 4.9.13-moby (root@11fbdc1f630f) (gcc version 6.2.1 20160822 (Alpine 6.2.1) ) #1 SMP Tue Mar 21 21:21:05 UTC 2017
查询防火墙状态:
root@6c0b62bbae13:/# service iptables status
iptables: unrecognized service
root@6c0b62bbae13:/# apt-get install iptables
root@6c0b62bbae13:/# service iptables status
iptables: unrecognized service //安装完成后仍然报错
原因:在ubuntu中由于不存在 /etc/init.d/iptales文件,所以无法使用service等命令来启动iptables
直接用iptables命令:
root@6c0b62bbae13:/# iptables -L
iptables v1.8.4 (legacy): can't initialize iptables table `filter': Permission denied (you must be root)
解决办法:登陆container时加上--privileged
localhost:clickhouse-on-cluster-master yanfang$ docker exec -it --privileged clickhouseonclustermaster_ch-server-2_1 bash
root@6c0b62bbae13:/# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
root@6c0b62bbae13:/#
未完待续...
IEDA工具登陆成功:
Host: 127.0.0.1