clickhouse快速搭建测试环境

2022-05-07  本文已影响0人  Nick_4438

简介

目前在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).
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
上一篇 下一篇

猜你喜欢

热点阅读