1 为服务器部署docker
服务器版本:Red Hat Enterprise Linux Server release 7.9 (Maipo)
服务器存在成熟yum源,直接部署docker
yum install docker-ce docker-ce-cli containerd.io
注意:报错
You have enabled checking of packages via GPG keys. This is a good thing.
However, you do not have any GPG public keys installed. You need to download
the keys for packages you wish to install and install them.
You can do that by running the command:
rpm --import public.gpg.key
解决方式:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
启动docker
systemctl start docker
验证docker
docker run hello-world
2 部署镜像
2.1拉取镜像
docker pull clickhouse/clickhouse-server
注:可在其他可以联网的机器上pull,之后下载下来后save,再到目标上save.
2.2 启动镜像
启动容器,拉取配置文件
docker run -d --rm --name=temp yandex/clickhouse-server
docker cp temp:/etc/clickhouse-server/users.xml \
/home/soft_1/clickhouse-server/conf/users.xml
docker cp temp:/etc/clickhouse-server/config.xml \
/home/soft_1/clickhouse-server/conf/config.xml
注意: 目录/home/soft_1/clickhouse-server 为事先建好的目录,并且下面有conf/database/log三个子目录。
2.3 修改链接用户名密码
密码密文产生方式:
PASSWORD='xxx123456'; echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'
修改拷贝过来的users.xml
vi users.xml
<root>
<password_sha256_hex>12369caba5e25666d5120dfa03ea1e09ef421b7910c632f60fc6c2c5a6b</password_sha256_hex>
<networks>
<ip>::/0</ip>
</networks>
<profile>default</profile>
<quota>default</quota>
</root>
2.4启动clickhouse容器
docker run -d --name gjb-clickhouse-server -p 8123:8123 -p 9009:9009 -p 9090:9000 --ulimit nofile=262144:262144 --volume=/home/soft_1/clickhouse-server/database:/var/lib/clickhouse --volume=/home/soft_1/clickhouse-server/log:/var/log/clickhouse-server --volume=/home/soft_1/clickhouse-server/conf/config.xml:/etc/clickhouse-server/config.xml --volume=/home/soft_1/clickhouse-server/conf/users.xml:/etc/clickhouse-server/users.xml yandex/clickhouse-server
3 部署完毕,可以使用dbeaver访问
参考:
https://www.cnblogs.com/98record/p/docker-kuai-su-bu-shuclickhouse.html
https://www.jianshu.com/p/146187593a1a
欢迎大家一起学习讨论。