clickhouse安装配置

1.安装
1
2
3
4
5
6
7
8
1.安装curl系统包
yum install -y curl
2.安装clickhouse repositories
sudo yum install -y clickhouse-server clickhouse-client
3.查询clickhouse包
yum list 'clickhouse*'
4.安装clickhouse包
yum install -y 'clickhouse*'

2.修改配置文件

1
文件位置 /etc/clickhouse-server
2.1.远程可访问配置
1
2
3
4
5
6
将config.xml文件下的一行代码注释打开

找到<!-- <listen_host>::</listen_host> --> 打开注释之后变成这样<listen_host>::</listen_host>
重启

service clickhouse-server restart

#####2.2..创建角色

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
对config.xml修改
在最后一行加上下面的代码,用于接收创建的角色信息,加完代码之后记得创建这个文件

<access_control_path>/data/work/clickhouse/access/</access_control_path>
对users.xml 的配置修改
<profiles>
<!-- Default settings. -->
<default>
<!-- Maximum memory usage for processing single query, in bytes. -->
<max_memory_usage>10000000000</max_memory_usage>

<!-- Use cache of uncompressed blocks of data. Meaningful only for processing many of very short queries. -->
<use_uncompressed_cache>0</use_uncompressed_cache>

<!-- How to choose between replicas during distributed query processing.
random - choose random replica from set of replicas with minimum number of errors
nearest_hostname - from set of replicas with minimum number of errors, choose replica
with minimum number of different symbols between replica's hostname and local hostname
(Hamming distance).
in_order - first live replica is chosen in specified order.
first_or_random - if first replica one has higher number of errors, pick a random one from replicas with minimum number of errors.
-->
<load_balancing>random</load_balancing>
</default>

<!-- Profile that allows only read queries. -->
<readonly>
<readonly>1</readonly>
</readonly>

<authority_r>
<readonly>1</readonly>
<allow_ddl>0</allow_ddl>
</authority_r>

<authority_rw>
<readonly>2</readonly>
<allow_ddl>0</allow_ddl>
</authority_rw>

<authority_rwd>
<readonly>0</readonly>
<allow_ddl>1</allow_ddl>
</authority_rwd>

</profiles>
<users>
<admin> ## clickhouse自带default用户,但是该用户拥有所有权限且没有设置登陆密码和开启RBAC
<password>123456</password> ## 自定义密码
<access_management>1</access_management> ### 默认为0,修改成1 开启RBAC权限控制
<networks incl="networks" replace="replace">
<ip>::/0</ip>
</networks>
<profile>default</profile> ## 使用的用户配置。直接写名称default 认为已经引用了所有default的配置
<quota>default</quota> ## 资源限额,引用default的全部设置
</admin>
</users>
profiles下的对象是对权限的具体定义,users可继承profile中对象的属性这里创建的admin账号全部引用的default的配置 readonly 有三种状态 0不做限制 1可读(select,exists,show,describe) 2可读可设置(比1多了set) allow_ddl 有两种状态 0不允许ddl 1允许ddl

#####删除clickhouse配置和文件

1
2
3
4
5
6
7
8
9
10
11
yum list installed | grep clickhouse

yum remove -y clickhouse-common-static

yum remove -y clickhouse-server-common

rm -rf /var/lib/clickhouse

rm -rf /etc/clickhouse-*

rm -rf /var/log/clickhouse-server