Linux 安装 Clickhouse

文档:https://clickhouse.com/docs/zh/
下载:https://packagecloud.io/Altinity/clickhouse

wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-common-20.8.3.18-1.el7.x86_64.rpm/download.rpm
yum install clickhouse-server-common-20.8.3.18-1.el7.x86_64

wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-common-static-20.8.3.18-1.el7.x86_64.rpm/download.rpm
yum install clickhouse-common-static-20.8.3.18-1.el7.x86_64

wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-20.8.3.18-1.el7.x86_64.rpm/download.rpm
yum install clickhouse-server-20.8.3.18-1.el7.x86_64

wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-client-20.8.3.18-1.el7.x86_64.rpm/download.rpm
yum install clickhouse-client-20.8.3.18-1.el7.x86_64


安装包后到对应目录中,进行安装:
    安装命令:rpm -ivh ./clickhouse-*.rpm
全部安装完无错误信息即可,在过程中可能会出现缺少安装包的情况,此时需要将缺失的依赖补齐即可

    1. /etc/clickhouse-server : 服务端的配置文件目录,包括全局配置config.xml 和用户配置users.xml,其中如需要外网访问则需要打开config.xml中更改配置:
    其中需要放开<listen_host>::</listen_host>的注释即可
    2. /var/lib/clickhouse : 默认的数据存储目录,通常会修改,将数据保存到大容量磁盘路径中
    3. /var/log/cllckhouse-server : 默认保存日志的目录,通常会修改,将数据保存到大容量磁盘路径中

启动服务:
    启动:service clickhouse-server start
    重启:service clickhouse-server restart
    启动:systemctl start clickhouse-server
状态: systemctl status clickhouse-server
 停止: systemctl stop clickhouse-server
    [root@localhost clickhouse-server]# 
    service clickhouse-server start
    start clickhouse-server service: Path to data directory in /etc/clickhouse-server/config.xml: /var/lib/clickhouse/
    DONE

可以在/var/log/clickhouse-server/目录中查看日志。
如果服务没有启动,请检查配置文件 /etc/clickhouse-server/config.xml

手动从控制台启动服务器:
    clickhouse-server --config-file=/etc/clickhouse-server/config.xml
    sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml
连接:
    clickhouse-client
    
测试:select 1

API:https://clickhouse.com/docs/zh/getting-started/install/
【错误1】:Effective user of the process (root) does not match the owner of the data (clickhouse). Run under 'sudo -u clickhouse'.
    解决:更改目录权限:chown -R clickhouse:clickhouse /etc/clickhouse-server /var/log/clickhouse-server

#添加相关方存储库:
    sudo yum install -y yum-utils
    sudo yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo
    sudo yum install -y clickhouse-server clickhouse-client
#如果没有service,可以运行如下命令在后台启动服务:
    sudo /etc/init.d/clickhouse-server start 
#使用命令行客户端连接
    clickhouse-client # or "clickhouse-client --password"  if you set up a password.

【错误2】:DB::Exception: Cannot lock file /var/lib/clickhouse/status. Another server instance in same directory is already running.
    解决:ps -ef | grep clickhouse-server
          kill -9 $pid
          可能不起作用,可使用 ps -ef 查到所有进程再删除 
【】<Error> Application: DNS error: EAI: -9
    解决:本机没有开放ipv6,只能对ipv4生效。可以考虑在config.xml中,把<listen_host>::</listen_host> 改成<listen_host>0.0.0.0</listen_host>
    
【】:Memory limit (for query) exceeded: would use 9.31 GiB (attempt to allocate chunk of 1048576 bytes), maximum: 9.31 GiB
    解决:修改user.xml里max_memory_usage 值,把他改大一些,默认是953M,不到1G,可以改到2G

【】Include not found: clickhouse_remote_servers
    Include not found: clickhouse_compression
    Poco::Exception. Code: 1000, e.code() = 0, e.displayText() = Exception: Cannot set max size of core file to 1073741824, e.what() = Exception
    解决:没有开放core文件写入,使用命令: ulimit -c 1073741824, 开放即可。

【】Access to file denied: /var/log/clickhouse-server/clickhouse-server.err.log 
    解决:到目录下删除 clickhouse-server.err.log  文件

posted @   至丰  阅读(1472)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示