-
创建临时容器,拿出里面的配置文件
# 下载镜像以及创建临时容器 sudo docker run --rm -d --name=clickhouse-server --ulimit nofile=262144:262144 -p 8123:8123 -p 9009:9009 -p 9000:9000 yandex/clickhouse-server:latest # 拿出里面的配置文件 config.xml users.xml docker cp clickhouse-server:/etc/clickhouse-server/config.xml C:\Users\sailing\Documents\software\clickhouse\conf\config.xml docker cp clickhouse-server:/etc/clickhouse-server/users.xml C:\Users\sailing\Documents\software\clickhouse\conf\users.xml # 停止临时容器 docker stop clickhouse-server
-
修改配置文件
准备数据库用户密码
PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' # 得到第一个用户密码 Qnh59bDt d8877c0bc153662d93b51ef4df0274f541c5c63e4d76e19b7a803ded2206ec56 PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' # 得到第二个用户密码 HE5ZhQzN 2b9847a742812b8317012d5df11f2a79d823afbed2789dd5c72d1067e44c6b53
想使用简单密码如 123456,经过 sha256 后如下:
8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92修改 users.xml 文件
-
把default账号设为只读权限,并设置密码 yandex-->users-->default-->profile 节点设为 readonly
-
注释掉 yandex-->users-->default-->password 节点
-
新增 yandex-->users-->default-->password_sha256_hex 节点,填入生成的密码
-
新增root账号
<users> <!-- If user name was not specified, 'default' user is used. --> <default> <!-- <password></password> --> <password_sha256_hex>d8877c0bc153662d93b51ef4df0274f541c5c63e4d76e19b7a803ded2206ec56</password_sha256_hex> <networks> <ip>::/0</ip> </networks> <!-- Settings profile for user. --> <profile>readonly</profile> <!-- Quota for user. --> <quota>default</quota> <!-- User can create other users and grant rights to them. --> <!-- <access_management>1</access_management> --> </default> <root> <password_sha256_hex>8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92</password_sha256_hex> <networks incl="networks" replace="replace"> <ip>::/0</ip> </networks> <profile>default</profile> <quota>default</quota> </root> </users>
-
-
创建正式的容器
# 删除临时容器
docker rm clickhouse-server
# 启动正式容器
# windows
docker run -d --name=clickhouse-server -p 8123:8123 -p 9009:9009 -p 9000:9000 --ulimit nofile=262144:262144 -v C:\Users\sailing\Documents\software\clickhouse\data:/var/lib/clickhouse:rw -v C:\Users\sailing\Documents\software\clickhouse\conf\config.xml:/etc/clickhouse-server/config.xml -v C:\Users\sailing\Documents\software\clickhouse\conf\users.xml:/etc/clickhouse-server/users.xml -v C:\Users\sailing\Documents\software\clickhouse\log:/var/log/clickhouse-server:rw yandex/clickhouse-server:latest
# linux
sudo docker run -d --name=clickhouse-server -p 8123:8123 -p 9009:9009 -p 9000:9000 --ulimit nofile=262144:262144 -v /app/cloud/clickhouse/data:/var/lib/clickhouse:rw -v /app/cloud/clickhouse/conf/config.xml:/etc/clickhouse-server/config.xml -v /app/cloud/clickhouse/conf/users.xml:/etc/clickhouse-server/users.xml -v /app/cloud/clickhouse/log:/var/log/clickhouse-server:rw yandex/clickhouse-server:latest
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:docker安装clickhouse - Python技术站