文档:什么是ClickHouse? | ClickHouse Docs
02.ClickHouse单机版安装教程 - 李林超博客 ~ 个人博客
准备工作
# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
# 关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# 查看状态
cat /etc/selinux/config
# 取消打开文件数限制
vim /etc/security/limits.conf
vim /etc/security/limits.d/20-nproc.conf
# 打开以上两个文件,末尾添加以下4行内容
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
# 重启后检查是否生效:open files
ulimit -n
ulimit -a
服务器端安装:
clickhouse-rpm-stable安装包下载_开源镜像站-阿里云
Altinity/clickhouse - Packages · packagecloud
# 下载下面三个文件并执行
clickhouse-common-static-22.8.2.11.x86_64.rpm
clickhouse-server-22.8.2.11.x86_64.rpm
clickhouse-client-22.8.2.11.x86_64.rpm
# rpm方式安装
rpm -ivh clickhouse-*.rpm
# 查看是否安装成功
rpm -qa|grep clickhouse
# yum方式安装
yum install -y yum-utils
yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo
yum install -y clickhouse-server clickhouse-client
# 启动
systemctl enable clickhouse-server
systemctl restart clickhouse-server
systemctl status clickhouse-server
服务器端放开远程访问
# 放开远程访问
netstat -tunlp|grep 8123
tcp 0 0 127.0.0.1:8123 0.0.0.0:* LISTEN 4202/clickhouse-ser
tcp6 0 0 ::1:8123 :::* LISTEN 4202/clickhouse-ser
vim /etc/clickhouse-server/config.xml
# 放开如下注释可被任意客户端访问
<listen_host>::</listen_host>
# 可不重启就可生效
wq!
# 重启服务,不重启也可以
systemctl restart clickhouse-server
# 检查端口
netstat -tunlp|grep 8123
tcp 0 0 0.0.0.0:8123 0.0.0.0:* LISTEN 53445/clickhouse-se
# cmd查看端口访问
telnet 192.168.125.167 8123
设置访问密码,可忽略
vim /etc/clickhouse-server/users.xml
# 设置明文密码
<password>123</password>
# 可不重启就可生效
wq!
ClickHouse各文件目录:
bin/ ===> /usr/bin/
conf/ ===> /etc/clickhouse-server/
lib/ ===> /var/lib/clickhouse
log/ ===> /var/log/clickhouse-server
客户端访问
# 多行输入
clickhouse-client -m
客户端访问
--host/-h 服务端的host名称, 默认是localhost。
--port 连接的端口,默认值:9000。注意HTTP接口以及TCP原生接口使用的是不同端口。
--user/-u 用户名。 默认值:default。
--password 登录的密码,默认值为空。如果在用户定义中未设置密码,则不需要填写(例如默认的default用户)
--database/-d 默认当前操作的数据库. 默认值:服务端默认的配置(默认是default)。
--query/-q 只能在非交互式查询时使用,用于指定SQL语句
--multiquery/-n 在非交互式执行时,允许一次运行多条SQL语句,多条语句之间以分号间隔。
--time/-t 在非交互式执行时,会打印每条SQL的执行时间
--multiline/-m 如果指定,允许多行语句查询
--format/-f 使用指定的默认格式输出结果。
可视化工具DBeaver