1.创建用户用户名和密码
PASSWORD=$(base64 < /dev/urandom | head -c8); echo "mypassword"; echo -n "mypassword" | sha256sum | tr -d '-' # 在服务器执行 mypassword:为你要设置的密码
root # 返回的结果 这你明文密码 就是你前面设置的 mypassword
4813494d137e1631bba301d5acab6e7bb7aa74ce1185d456565ef51d737677b2 # 返回的结果 这你sha256加密的密码 就是你前面设置的 mypassword 经过sha256加密后等到的结果
<password>root</password> :修改users.xml配置 使用明文密码
<password_sha256_hex>4813494d137e1631bba301d5acab6e7bb7aa74ce1185d456565ef51d737677b2</password_sha256_hex> :修改users.xml配置 使用密文密码
2.修改users.xlm clickhouse用户配置文件
cd /etc/clickhouse-server # clickhouse 配置文件目录
cp users.xml users.xml.rpmnew # 复制一份users.xml配置文件
vim users.xml
<profiles>
<!--可自定义名称,default是默认存在的角色名称-->
<default>
<max_memory_usage>10000000000</max_memory_usage>
<load_balancing>random</load_balancing>
<constraints><!-- 配置约束-->
<max_memory_usage>
<min>5000000000</min>
<max>20000000000</max>
</max_memory_usage>
<load_balancing>
<readonly/>
</load_balancing>
</constraints>
</default>
<readonly><!--自定义readonly角色-->
<readonly>1</readonly>
</readonly>
</profiles>
<!--Min:最小值约束,对应参数取值不能小于该值-->
<!--Max:最大值约束,对应参数取值不能大雨该值-->
<!--Readonly:只读约束,对应参数禁止修改-->
<!--profile中default的constraints配置约束会作为全局约束,自动被其他profile继承。-->
<users> <!--在用户配置表情下面添加一个用户-->
<root> <!--用户名-->
<password>root</password> <!--密码设置--> <!--官网不推荐使用明文-->
<password_sha256_hex>4813494d137e1631bba301d5acab6e7bb7aa74ce1185d456565ef51d737677b2</password_sha256_hex> <!--密码设置-->
<networks incl="networks" replace="replace"> <!--网络设置,一般用来限制可登陆的客户端地址-->
<ip>::/0</ip> <!--为所有客户端打开权限-->
</networks>
<profile>default</profile> <!--该用户所使用的profile-->
<quota>default</quota> <!--该用户所使用的quota-->
</root>
</users>
<quotas> <!--quotas标签是限制了单位时间内的系统资源使用量 值为0表示不限制-->
<default> <!--自定义名称-->
<interval>
<duration>3600</duration> <!--累计的时间周期,单位为秒,达到该时间周期后,清除所有收集的值,接下来的周期,将重新开始计算-->
<queries>0</queries> <!--在该周期内,允许执行的查询次数,0为不限制。-->
<errors>0</errors> <!--在该周期内,允许引发异常的查询次数,0为不限制。-->
<result_rows>0</result_rows> <!--在周期内,允许查询返回的结果行数,0为不限制。-->
<read_rows>0</read_rows> <!--表示在周期内,允许远程节点读取的数据行数,0为不限制。-->
<execution_time>0</execution_time> <!--允许查询的总执行时间(又叫wall time),单位为秒,0为不限制。-->
</interval>
</default>
</quotas>
3.访问
clickhouse-client -h 127.0.0.1 -d default -m -u default --port 9000 --password root(明文密码)
clickhouse-client -h 192.168.107.215 --port 9000 -u ck --password root(明文密码)