简介
目前在olap领域clickhouse无疑是一个非常火爆的软件,本文讲解如何使用docker 搭建一个clickhouse的测试环境。
环境搭建
# 启动 server 实例
docker run -d --name some-clickhouse-server -p 18123:8123 -p19000:9000 --ulimit nofile=262144:262144 clickhouse/clickhouse-server:22.4.5
# 使用clickhouse官方提供的click连接服务器
docker run -it --rm --link some-clickhouse-server:clickhouse-server clickhouse/clickhouse-client --host clickhouse-server
命令测试
CREATE DATABASE IF NOT EXISTS helloworld;
CREATE TABLE helloworld.my_first_table
(
user_id UInt32,
message String,
timestamp DateTime,
metric Float32
)
ENGINE = MergeTree()
PRIMARY KEY (user_id, timestamp);
insert into helloworld.my_first_table (user_id,message,timestamp,metric) values (1,'name',now(),1.2);
selct * from helloworld.my_first_table;
补充说明
- 可挂载的配置文件:
/etc/clickhouse-server/config.d/*.xml - 服务器配置调整
/etc/clickhouse-server/usert.d/*.xml - files with use settings adjustmenets
/docker-entrypoint-initdb.d/ - folder with database initialization scripts (see below).
- 数据目录:/var/lib/clickhouse/ - main folder where ClickHouse stores the data
- 日志目录:/val/log/clickhouse-server/ - logs
docker run -d \
-v $(realpath ./ch_data):/var/lib/clickhouse/ \
-v $(realpath ./ch_logs):/var/log/clickhouse-server/ \
--name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server
- 端口:9000-默认client访问端口,8123默认的http端口
网友评论