clickhouse安装部署

下载安装文件

这里直接去GitHub下载最新版本,我下载的是最新的ClickHouse stable release v21.12.2.17-stable,用rpm方式安装,主要下载一下几个文件:

clickhouse-server-21.12.2.17-2.noarch.rpm
clickhouse-common-static-21.12.2.17-2.x86_64.rpm
clickhouse-client-21.12.2.17-2.noarch.rpm
clickhouse-common-static-dbg-21.12.2.17-2.x86_64.rpm

下载之后上传到服务器的文件夹下:

/home/software/clickhouse

安装

sudo rpm -ivh *.rpm

升级

yum upgrade *.rpm -y

出现下面提示代表升级完成

Installed:
  clickhouse-server.noarch 0:21.12.2.17-2                                                                                                                                                                                                                                     

Updated:
  clickhouse-client.noarch 0:21.12.2.17-2                                                                                            clickhouse-common-static.x86_64 0:21.12.2.17-2                                                                                           

Replaced:
  clickhouse-server-common.x86_64 0:1.1.54390-1.el7                                                                                                                                                                                                                           

Complete!

安装或升级完验证

rpm -qa|grep clickhouse

启动

sudo systemctl start clickhouse-server

查看是否启动成功

 systemctl status clickhouse-server
 或者
ps -ef | grep clickhouse-server

启动失败

查看clickhouse的启动日志,发现有Application: filesystem error: in remove_all: Permission denied [xxx],这个是改文件没有权限,如果是通过systemctl启动的,需要看下启动脚步里面配置的用户,比如:

[Unit]
Description=ClickHouse Server (analytic DBMS for big data)
Requires=network-online.target
# NOTE: that After/Wants=time-sync.target is not enough, you need to ensure
# that the time was adjusted already, if you use systemd-timesyncd you are
# safe, but if you use ntp or some other daemon, you should configure it
# additionaly.
After=time-sync.target network-online.target
Wants=time-sync.target

[Service]
Type=simple
User=clickhouse
Group=clickhouse
Restart=always
RestartSec=30
RuntimeDirectory=clickhouse-server
ExecStart=/usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid
LimitCORE=infinity
LimitNOFILE=500000
CapabilityBoundingSet=CAP_NET_ADMIN CAP_IPC_LOCK CAP_SYS_NICE

[Install]
# ClickHouse should not start from the rescue shell (rescue.target).
WantedBy=multi-user.target

这里的用户是clickhouse,那么刚刚报错的文件是没有clickhose用户的权限的,查看权限:

ll xxxx

添加权限:

chown clickhouse:clickhouse xxxx

同时给多个目录授权:

chown -R clickhouse:clickhouse /var/lib/clickhouse /var/log/clickhouse-server /etc/clickhouse-server /etc/clickhouse-client /usr/bin/clickhouse /opt/topology/db_data/clickhouse

查看systemctl start xxx的日志

journalctl -u xxx

进入命令行

clickhouse-client

查看数据库

show databases; 

导出csv文件

clickhouse-client -h 127.0.0.1 --database="db" --query="select * from db.test_table FORMAT CSV" > test.csv

导入csv文件

clickhouse-client -h 127.0.0.1 --database="db" --query="insert into db.test_table FORMAT CSV" < ./test.csv
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值