1.拉取clickhouse-server镜像

docker pull yandex/clickhouse-server:21.12.4.1

// 运行容器

docker run -d --rm --name=clickhouse  yandex/clickhouse-server:21.12.4.1

2.宿主机创建目录,用于存放配置文件、数据、日志

mkdir -p /data/udata/clickhouse01/conf /data/udata/clickhouse01/data /data/udata/clickhouse01/log

3.将容器内配置文件拷贝到宿主机

docker cp clickhouse:/etc/clickhouse-server/users.xml /data/udata/clickhouse01/conf/users.xml
docker cp clickhouse:/etc/clickhouse-server/config.xml /data/udata/clickhouse01/conf/config.xml

4.修改连接用户名、密码(users.xml
修改users.xml配置文件(/data/udata/clickhouse01/conf/users.xml)

<users>
    <default>
        <password>123456</password>
    </default>
</users>

5.删除clickhouse临时容器

 docker stop clickhouse && docker rm clickhouse

6.启动clickhouse容器

docker run -d --name clickhouse01 \
-e TZ="Asia/Shanghai" \
--add-host=ck1:127.0.0.1 \
-p 8123:8123 \
-p 9009:9009 \
-p 9000:9000 \
--ulimit nofile=262144:262144 \
--volume=/data/udata/clickhouse01/data:/var/lib/clickhouse \
--volume=/data/udata/clickhouse01/log:/var/log/clickhouse-server \
--volume=/data/udata/clickhouse01/conf/config.xml:/etc/clickhouse-server/config.xml \
--volume=/data/udata/v/conf/metrika.xml:/etc/clickhouse-server/metrika.xml \
--volume=/data/udata/clickhouse01/conf/users.xml:/etc/clickhouse-server/users.xml \
yandex/clickhouse-server:21.12.4.1

7.客户端访问服务端

 进入容器: docker exec -it cid  bash
连接:
clickhouse-client -h 127.0.0.1 -d default -m -u default --password '123456'

 


 

 

 



posted on 2022-06-07 19:12  lshan  阅读(700)  评论(0编辑  收藏  举报