第一步 clickHouse官网查看安装教程
首先,需要添加官方存储库:
sudo yum install yum-utils
sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64
如果您想使用最新版本,请替换stable为testing(推荐用于您的测试环境)。prestable有时也可用。
然后运行这些命令来安装软件包:
sudo yum install clickhouse-server clickhouse-client
或者手动下载tar包安装
如果使用的是Docker也可以使用Docker镜像安装
都是官网资料非常好用
修改配置/etc/clickhouse-server/config.xml
1、开放远程连接: <listen_host>::</listen_host>
2、数据目录改为服务器最大的数据盘,如此处是/data2:
<!-- Path to data directory, with trailing slash. -->
<path>/data2/clickhouse/</path>
<tmp_path>/data2/clickhouse/tmp/</tmp_path>
<user_files_path>/data2/clickhouse/user_files/</user_files_path>
<format_schema_path>/data2/clickhouse/format_schemas/</format_schema_path>
其他优化配置项修改
配置日志文件切割 (100M做一个切割,ClickHouse存储的已归档日志文件的数量 设置为 10),配置文件:/etc/clickhouse-server/config.xml
修改如下:
<size>100M</size>
<count>10</count>
配置允许的文件导入的错误数(放到<interserver_http_port> 配置项后面):
<input_format_allow_errors_num>100</input_format_allow_errors_num>
配置连接超时时间参数
vim /etc/clickhouse-server/config.xml
修改如下参数:
<keep_alive_timeout>900</keep_alive_timeout>
<default_session_timeout>600</default_session_timeout>
是否使用未压缩块的缓存,提升短查询速度。接受0或1。默认情况下0(禁用),改为1
修改:<use_uncompressed_cache>0</use_uncompressed_cache> 为 <use_uncompressed_cache>1</use_uncompressed_cache>
修改单个查询使用的最大内存限制
<max_memory_usage>20000000000</max_memory_usage>
配置账号密码: vi /etc/clickhouse-server/users.xml
修改: 将注释打开直接添加一个简单密码也可以使用SHA256加密的密文+明文密码
安装完成之后就可以启动服务看一下了
sudo service clickhouse-server start
如果没有sevice命令执行
/etc/init.d/clickhouse-server start
或者使用配置文件启动也可以
clickhouse-server --config-file=/etc/clickhouse-server/config.xml
启动后查看服务状态
service clickhouse-server status
使用client 连接服务端查看是否正常或者建表插入数据
clickhouse-client -m --user default --password 123--port 9000
也可以使用IDEA带的数据库工具连接