🙏废话不多说系列,直接开整🙏
一、安装过程
基础环境为:① Ubuntu18.04;②Docker version 20.10.2, build 20.10.2-0ubuntu1~18.04.2
(1)下载 Docker clickhouse
① 查看 docker 中是否有可用的 clickhouse 版本
# 查看docker下是否存在可用版本的clickhouse
root@ubuntu:/etc/apt# docker search clickhouse
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
yandex/clickhouse-server ClickHouse is an open-source column-oriented… 305 [OK]
yandex/clickhouse-client Native client for the Clickhouse database ma… 77 [OK]
spoonest/clickhouse-tabix-web-client tabix: https://github.com/tabixio/tabix 9 [OK]
alexakulov/clickhouse-backup Tool for easy ClickHouse backup and restore … 3
nikepan/clickhouse-bulk Collects small insterts and sends big reques… 3
altinity/clickhouse-operator ClickHouse Operator for Kubernetes (beta) 2
tacyuuhon/clickhouse-chproxy This is a Docker images of a chproxy 2
f1yegor/clickhouse-exporter ClickHouse exporter for Prometheus 1 [OK]
qxip/clickhouse-grafana Clickhouse + Grafana 1
yandex/clickhouse-binary-builder 1
yandex/clickhouse-stateful-test 0
yandex/clickhouse-deb-builder 0
yandex/clickhouse-stateless-test 0
yandex/clickhouse-integration-helper 0
flant/clickhouse-exporter Clickhouse Prometheus exporter 0
datagrip/clickhouse ClickHouse image with an external dictionary 0 [OK]
yandex/clickhouse-integration-test 0
yandex/clickhouse-stress-test 0
yandex/clickhouse-integration-tests-runner 0
yandex/clickhouse-unit-test 0
crobox/clickhouse Clickhouse server image that only uses IPv4 0 [OK]
muxinc/clickhouse-server https://hub.docker.com/r/yandex/clickhouse-s… 0
podshumok/clickhouse My attempt to build Clickhouse with CPU-opti… 0
noenv/clickhouse-server Clickhouse Docker Image 0
hruljov/clickhouse-bulk clickhouse-bulk v1.2.6 0
root@ubuntu:/etc/apt#
② 安装号 clickhouse-server 和 clickhouse-client 官方版本的
# 拉取clickhouse服务端和客户端
docker pull yandex/clickhouse-server
docker pull yandex/clickhouse-client
# 示例
root@ubuntu:/etc/apt# docker pull yandex/clickhouse-server
Using default tag: latest
latest: Pulling from yandex/clickhouse-server
345e3491a907: Pull complete
57671312ef6f: Pull complete
5e9250ddb7d0: Pull complete
bec15d24205a: Pull complete
ba6fa5c6feaa: Pull complete
ca1a2c5c6b9b: Pull complete
93bb8ed3b1c1: Pull complete
e0bccf8a81a6: Pull complete
176f1fc9271f: Pull complete
0d1965052502: Pull complete
Digest: sha256:1c73a207247b3a6dbc5819354d951344cfa0bc957a0aee01ecb028f2368304f0
Status: Downloaded newer image for yandex/clickhouse-server:latest
docker.io/yandex/clickhouse-server:latest
root@ubuntu:/etc/apt# docker pull yandex/clickhouse-client
Using default tag: latest
latest: Pulling from yandex/clickhouse-client
01bf7da0a88c: Pull complete
f3b4a5f15c7a: Pull complete
57ffbe87baa1: Pull complete
968d41722cd6: Pull complete
8d18dab2ef05: Pull complete
Digest: sha256:75bc3deaca493f780485d39704e6474d621251f3a610912897831fda3fbe86b7
Status: Downloaded newer image for yandex/clickhouse-client:latest
docker.io/yandex/clickhouse-client:latest
(2)启动 ClickHouse-server 端容器
# 启动方式一:默认直接启动即可
docker run -d --name [启动之后的名称] --ulimit nofile=262144:262144 yandex/clickhouse-server
# 启动方式二:如果想指定目录启动,这里以clickhouse-test-server命令为例,可以随意写
mkdir /work/clickhouse/clickhouse-test-db ## 创建数据文件目录
# 使用以下路径启动,在外只能访问clickhouse提供的默认9000端口,只能通过clickhouse-client连接server
docker run -d --name clickhouse-test-server --ulimit nofile=262144:262144 --volume=/work/clickhouse/clickhouse_test_db:/var/lib/clickhouse yandex/clickhouse-server
操作实例演示:
# 启动方式一:启动docker中的clickhouse服务,并将此服务命名为 clickhouse-test-server
docker run -d --name clickhouse-test-server --ulimit nofile=262144:262144 yandex/clickhouse-server
# 启动方式二:指定目录启动,创建数据文件目录
mkdir -p /work/clickhouse/clickhouse-test-db
# 1.使用以下路径启动,在外只能访问clickhouse提供的默认9000端口,只能通过clickhouse-client连接server
docker run -d --name clickhouse-test-server --ulimit nofile=262144:262144 --volume=/work/clickhouse/clickhouse_test_db:/var/lib/clickhouse yandex/clickhouse-server
(3)启动并连接 clickhouse
# docker启动 clickhouse-client ,用于连接docker中的clickhouse-client
docker run -it --rm --link clickhouse-test-server:clickhouse-server yandex/clickhouse-client --host clickhouse-server
补充:
# 客户端常用参数
clickhouse-client
--host, -h :服务端host名称,默认 localhost
--port :连接端口,默认9000
--user, -u :用户名,默认 default
--password :密码,默认空
--query, -q :非交互模式下的查询语句
--database, -d :默认当前操作的数据库,默认default
--multiline, -m :允许多行语句查询,在clickhouse中默认回车即为sql结束,可使用该参数多行输入
--format, -f :使用指定的默认格式输出结果 csv,以逗号分隔
--time, -t :非交互模式下会打印查询执行的时间
--stacktrace :出现异常会打印堆栈跟踪信息
--config-file :配置文件名称
(4)关闭clickhouse-server服务
# 关闭 clickhouse-server 服务
docker container kill [容器ID/容器名称]
(5)移除 clickhouse-server 容器
# 移除 clickhouse-server 容器
docker container rm [容器ID/容器名称]
附录
(1)问题1:不能正常关闭容器
① 问题描述
② 解决方案 方案来源:blog.csdn.net/qq_28719743…
🙏至此,非常感谢阅读🙏