1.下载文件:
2.创建目录
[root@node01 ~]# cd /clickhouse/
[root@node01 clickhouse]# ll
总用量 0
drwxr-xr-x 6 clickhouse clickhouse 165 2月 7 02:13 app
drwxr-xr-x 13 clickhouse clickhouse 215 2月 7 02:17 data
drwxr-xr-x 4 clickhouse clickhouse 56 2月 6 01:29 etc
drwxr-xr-x 2 clickhouse clickhouse 68 2月 6 01:38 log
drwxr-xr-x 2 clickhouse clickhouse 6 2月 6 00:44 soft
[root@node01 clickhouse]#
3. 修改配置文件
vi clickhouse-server/install/doinst.sh
修改内容
CLICKHOUSE_DATADIR=${CLICKHOUSE_DATADIR:=/clickhouse/data}
CLICKHOUSE_LOGDIR=${CLICKHOUSE_LOGDIR:=/clickhouse/log}
3.2 修改第二个配置文件
2.vi clickhouse-server/etc/clickhouse-server/config.xml
<log>/clickhouse/log/clickhouse-server.log</log>
<errorlog>/clickhouse/log/clickhouse-server.err.log</errorlog>
<path>/clickhouse/data</path> 数据路径 /var/lib
<tmp_path>/clickhouse/data/tmp/</tmp_path>
<user_files_path>/clickhouse/data/user_files/</user_files_path>
<local_directory>
<!-- Path to folder where users created by SQL commands are stored. -->
<path>/clickhouse/data/access/</path>
</local_directory>
<format_schema_path>/clickhouse/data/format_schemas/</format_schema_path>
去掉注释监听所有的ip
<listen_host>::</listen_host>
修改时区
<timezone>Asia/Shanghai</timezone>
3.3 修改第三个配置文件:
vi clickhouse-server/etc/clickhouse-server/users.xml
打开注释才能创建用户和用户授权
<access_management>1</access_management>
默认使用查询内存 如果120G 生产环境就修改为80G
<max_memory_usage>10000000000</max_memory_usage>
4. 安装顺序
clickhouse-common-static
clickhouse-common-static-dbg
clickhouse-server
clickhouse-client
4.1 安装
./clickhouse-common-static/install/doinst.sh
./clickhouse-common-static-dbg/install/doinst.sh
./clickhouse-server/install/doinst.sh // 输入y 表示所有的服务都需要连接网络
./clickhouse-client/install/doinst.sh
4.2 进入etc 下面多了连个目录
[root@node01 etc]# ls -ls clickhouse-*
clickhouse-client:
总用量 4
0 drwxr-xr-x 2 root root 6 2月 6 01:24 conf.d
4 -rw-r--r-- 1 root root 1568 2月 6 01:24 config.xml
clickhouse-server:
总用量 48
0 dr-x------ 2 clickhouse clickhouse 24 2月 6 01:23 config.d
40 -r-------- 1 clickhouse clickhouse 38352 2月 6 01:22 config.xml
0 dr-x------ 2 clickhouse clickhouse 6 2月 6 01:22 users.d
8 -r-------- 1 clickhouse clickhouse 5579 2月 6 01:22 users.xml
[root@node01 etc]#
4.3
将两个文件拷贝到 /clickhouse/etc/ 下面
[root@node01 etc]# mv /etc/clickhouse-* /clickhouse/etc/
[root@node01 etc]# ls -lsa /clickhouse/etc/
总用量 0
0 drwxr-xr-x 4 root root 56 2月 6 01:29 .
0 drwxr-xr-x 7 root root 63 2月 6 00:44 ..
0 drwxr-xr-x 3 root root 38 2月 6 01:24 clickhouse-client
0 drwx------ 4 clickhouse clickhouse 72 2月 6 01:22 clickhouse-server
[root@node01 etc]#
4.4 创建软连接
[root@node01 etc]# ln -sf /clickhouse/etc/* .
[root@node01 etc]# ls -lsa /etc/clickhouse-*
0 lrwxrwxrwx 1 root root 33 2月 6 01:31 /etc/clickhouse-client -> /clickhouse/etc/clickhouse-client
0 lrwxrwxrwx 1 root root 33 2月 6 01:31 /etc/clickhouse-server -> /clickhouse/etc/clickhouse-server
[root@node01 etc]#
4.5 修改权限
[root@node01 etc]# chown -R clickhouse:clickhouse /clickhouse/
[root@node01 etc]# chmod -R 755 /clickhouse/
[root@node01 etc]#
4.6 开机启动的服务: 不用修改
vi /etc/systemd/system/clickhouse-server.service
4.7 服务命令
systemctl status clickhouse-server
systemctl start clickhouse-server
systemctl stop clickhouse-server
开机自动启动
systemctl enable clickhouse-server
5. clickhouse 默认端口是9000 但是和namenode 端口重复
/clickhouse/etc/clickhouse-server/config.xml
<tcp_port>9800</tcp_port>
<replica>
<host>localhost</host>
<port>9800</port>
<!-- Optional. Priority of the replica for load_balancing. Default: 1 (less value has more priority). -->
<!-- <priority>1</priority> -->
</replica>
</shard>
</test_shard_localhost>
<test_cluster_two_shards_localhost>
<shard>
<replica>
<host>localhost</host>
<port>9800</port>
</replica>
</shard>
<shard>
<replica>
<host>localhost</host>
<port>9800</port>
6. 客户端连接 clickhouse-client --port 9800
[root@node01 ~]# clickhouse-client --port 9800
ClickHouse client version 20.11.4.13 (official build).
Connecting to localhost:9800 as user default.
Connected to ClickHouse server version 20.11.4 revision 54442.
node01.com :) show databases;
SHOW DATABASES
Query id: 4b795404-5391-4ba7-80a7-6edf881f1f90
┌─name───────────────────────────┐
│ _temporary_and_external_tables │
│ default │
│ system │
└────────────────────────────────┘
3 rows in set. Elapsed: 0.003 sec.
node01.com :)
****************************************** 多实例的安装*******************************************
7. 拷贝配置文件
拷贝配置文件路径/clickhouse/etc/clickhouse-server , cp config.xml config9200.xml
[root@node01 clickhouse-server]# cp config.xml config9200.xml
[root@node01 clickhouse-server]# pwd
/clickhouse/etc/clickhouse-server
[root@node01 clickhouse-server]#
8 修改配置文件 config9200.xml
<log>/clickhouse/log9200/clickhouse-server.log</log>
<errorlog>/clickhouse/log9200/clickhouse-server.err.log</errorlog>
<path>/clickhouse/data9200</path>
<tmp_path>/clickhouse/data9200/tmp/</tmp_path>
<user_files_path>/clickhouse/data9200/user_files/</user_files_path>
<path>/clickhouse/data9200/access/</path>
<format_schema_path>/clickhouse/data9200/format_schemas/</format_schema_path>
<http_port>8124</http_port>
<tcp_port>9200</tcp_port>
<mysql_port>9204</mysql_port>
<interserver_http_port>9209</interserver_http_port>
9.创建目录
创建目录:
mkdir data9200 log9200
[root@node01 clickhouse]# mkdir data9200
[root@node01 clickhouse]# mkdir log9200
[root@node01 clickhouse]# ls
app data data9200 etc log log9200 soft
[root@node01 clickhouse]#
10.创建启动文件:
[root@node01 app]# cat clickhouse.start
#!/bin/bash
nohup clickhouse-server --config=/etc/clickhouse-server/config.xml &
sleep 5
nohup clickhouse-server --config=/etc/clickhouse-server/config9200.xml &
[root@node01 app]# pwd
/clickhouse/app
[root@node01 app]#
11. 连接
实例1clickhouse-client --port 9200
[root@node01 app]# clickhouse-client --port 9200
ClickHouse client version 20.11.4.13 (official build).
Connecting to localhost:9200 as user default.
Connected to ClickHouse server version 20.11.4 revision 54442.
node01.com :) show databases;
SHOW DATABASES
Query id: d856f23b-74a0-4c88-8f13-e49d89dcfa91
┌─name───────────────────────────┐
│ _temporary_and_external_tables │
│ default │
│ system │
└────────────────────────────────┘
3 rows in set. Elapsed: 0.006 sec.
node01.com :)
启动实例二
sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml
连接命令:clickhouse-client --port 9800
[root@node01 ~]# clickhouse-client --port 9800
ClickHouse client version 20.11.4.13 (official build).
Connecting to localhost:9800 as user default.
Connected to ClickHouse server version 20.11.4 revision 54442.
node01.com :) show databases;
SHOW DATABASES
Query id: 4b795404-5391-4ba7-80a7-6edf881f1f90
┌─name───────────────────────────┐
│ _temporary_and_external_tables │
│ default │
│ system │
└────────────────────────────────┘
3 rows in set. Elapsed: 0.003 sec.
node01.com :)
网友评论