2.1 网址
官网:https://clickhouse.yandex/
https://clickhouse.tech/docs/zh/
下载地址:http://repo.red-soft.biz/repos/clickhouse/stable/el6/
2.2 单机模式
2.2.1 上传4个文件到/opt/software/
[root@hadoop102 software]# ls
clickhouse-client-19.7.3.9-1.el6.x86_64.rpm
clickhouse-server-19.7.3.9-1.el6.x86_64.rpm
clickhouse-compressor-19.7.3.9-1.el6.x86_64.rpm
clickhouse-server-common-19.7.3.9-1.el6.x86_64.rpm
2.2.2分别安装这4个rpm文件
image.png[root@hadoop102 software]#
rpm -ivh clickhouse-server-common-19.7.3.9-1.el6.x86_64.rpm
Preparing… ########################################### [100%]
1:clickhouse-server-commo########################################### [100%]
[root@hadoop102 software]#
rpm -ivh clickhouse-server-19.7.3.9-1.el6.x86_64.rpm
Preparing… ########################################### [100%]
1:clickhouse-server ########################################### [100%]
[root@hadoop102 software]#
rpm -ivh clickhouse-client-19.7.3.9-1.el6.x86_64.rpm
Preparing… ########################################### [100%]
1:clickhouse-client ########################################### [100%]
[root@hadoop102 software]#
rpm -ivh clickhouse-compressor-19.7.3.9-1.el6.x86_64.rpm
Preparing… ########################################### [100%]
1:clickhouse-compressor ########################################### [100%]
2.2.3 启动ClickServer
[root@hadoop102 software]# service clickhouse-server start
[root@hadoop102 r ~]# service clickhouse-server status
clickhouse-server service is running
2.2.4 使用client连接server
[root@hadoop102 software]# clickhouse-client
ClickHouse client version 20.5.4.40.
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 20.5.4 revision 54435.
:)
image.png
[root@docker_server ~]# clickhouse-client -q 'show databases'
_temporary_and_external_tables
default
system
[root@docker_server ~]# clickhouse-client -d system
ClickHouse client version 20.5.4.40.
Connecting to database system at localhost:9000 as user default.
Connected to ClickHouse server version 20.5.4 revision 54435.
localhost :) show tables;
SHOW TABLES
┌─name───────────────────────────┐
│ aggregate_function_combinators │
│ asynchronous_metric_log │
│ asynchronous_metrics │
│ build_options │
│ clusters │
│ collations │
│ columns │
│ contributors │
│ current_roles │
│ data_type_families │
│ databases │
│ detached_parts │
│ dictionaries │
│ disks │
│ distribution_queue │
│ enabled_roles │
│ events │
│ formats │
│ functions │
│ grants │
│ graphite_retentions │
│ licenses │
│ macros │
│ merge_tree_settings │
│ merges │
│ metric_log │
│ metrics │
│ models │
│ mutations │
│ numbers │
│ numbers_mt │
│ one │
│ parts │
│ parts_columns │
│ privileges │
│ processes │
│ query_log │
│ query_thread_log │
│ quota_limits │
│ quota_usage │
│ quotas │
│ quotas_usage │
│ replicas │
│ replication_queue │
│ role_grants │
│ roles │
│ row_policies │
│ settings │
│ settings_profile_elements │
│ settings_profiles │
│ stack_trace │
│ storage_policies │
│ table_engines │
│ table_functions │
│ tables │
│ trace_log │
│ users │
│ zeros │
│ zeros_mt │
└────────────────────────────────┘
59 rows in set. Elapsed: 0.003 sec.
[root@docker_server ~]# clickhouse-client -m
ClickHouse client version 20.5.4.40.
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 20.5.4 revision 54435.
localhost :) show
:-] databases;
SHOW DATABASES
┌─name───────────────────────────┐
│ _temporary_and_external_tables │
│ default │
│ system │
└────────────────────────────────┘
↓ Progress: 3.00 rows, 331.00 B (1.94 thousand rows/s.,
3 rows in set. Elapsed: 0.002 sec.
localhost :)
[root@docker_server ~]# clickhouse-client -t -q 'show databases;'
_temporary_and_external_tables
default
system
0.001==========>执行时间
2.3 分布式集群安装
2.3.1 在hadoop103,hadoop104上面执行之前的所有步骤
2.3.2 三台机器修改配置文件config.xml
[root@hadoop102 ~]# vim /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->
[root@hadoop103 ~]# vim /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->
[root@hadoop104 ~]# vim /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->
2.3.3 在三台机器的etc目录下新建metrika.xml文件
[root@hadoop102 ~]# vim /etc/metrika.xml
添加如下内容:
<yandex>
<clickhouse_remote_servers>
<perftest_3shards_1replicas>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>hadoop102</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<internal_replication>true</internal_replication>
<host>hadoop103</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>hadoop104</host>
<port>9000</port>
</replica>
</shard>
</perftest_3shards_1replicas>
</clickhouse_remote_servers>
<zookeeper-servers>
<node index="1">
<host>hadoop102</host>
<port>2181</port>
</node>
<node index="2">
<host>hadoop103</host>
<port>2181</port>
</node>
<node index="3">
<host>hadoop104</host>
<port>2181</port>
</node>
</zookeeper-servers>
<macros>
<replica>hadoop104</replica>
</macros>
<networks>
<ip>::/0</ip>
</networks>
<clickhouse_compression>
<case>
<min_part_size>10000000000</min_part_size>
<min_part_size_ratio>0.01</min_part_size_ratio>
<method>lz4</method>
</case>
</clickhouse_compression>
</yandex>
注意:上面标红的地方需要根据机器不同去修改
2.3.4 三台机器启动ClickServer
首先在三台机器开启Zookeeper
前台启动:
[root@hadoop102 software]# clickhouse-server --config-file=/etc/clickhouse-server/config.xml
service clickhouse-server start
后台启动:
[root@hadoop102 software]# nohup clickhouse-server --config-file=/etc/clickhouse-server/config.xml >null 2>&1 &
[1] 2696
2.3.5 检查集群启动是否成功
select * from system.clusters;
image.png
网友评论