1.创建目录
mkdir -p /data/clickhouse/data
mkdir -p /data/clickhouse/conf
mkdir -p /data/clickhouse/log
2.拉取镜像
docker pull clickhouse/clickhouse-server
3.创建临时容器
docker run -d --rm --name clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server
4.复制目录
docker cp clickhouse-server:/etc/clickhouse-server/config.xml /data/clickhouse/conf/config.xml
docker cp clickhouse-server:/etc/clickhouse-server/users.xml /data/clickhouse/conf/users.xml
5.停止容器
docker stop clickhouse-server
6.运行容器
docker run -d --name=clickhouse-server \
-p 8123:8123 -p 9090:9000 \
--ulimit nofile=262144:262144 \
-v /data/clickhouse/data:/var/lib/clickhouse:rw \
-v /data/clickhouse/conf/config.xml:/etc/clickhouse-server/config.xml \
-v /data/clickhouse/conf/users.xml:/etc/clickhouse-server/users.xml \
-v /data/clickhouse/log:/var/log/clickhouse-server:rw \
clickhouse/clickhouse-server
7.客户端连接
点击测试连接下载驱动
默认数据库
新增数据
CREATE TABLE user_info (
`id` UInt64,
`user_name` String,
`pass_word` String,
`phone` String,
`create_day` Date DEFAULT CAST(now(),'Date')
)ENGINE = MergeTree
primary key (id)
order by (id);
INSERT INTO user_info
(id,user_name,pass_word,phone)
VALUES
(1,'xiaowang','123456','13325511231'),
(2,'xiaoma','123456','13825511231'),
(3,'xiaozhao','123456','18925511231');