Docker 安装 ClickHouse
1、创建目录mkdir -p /docker/cloud/clickhouse/confmkdir -p /docker/cloud/clickhouse/datamkdir -p /docker/cloud/clickhouse/logchmod -R 777 /docker/cloud/clickhouse/confchmod -R 777/docker/cloud/clickhouse/co
1、创建目录
mkdir -p /docker/cloud/clickhouse/conf
mkdir -p /docker/cloud/clickhouse/data
mkdir -p /docker/cloud/clickhouse/log
chmod -R 777 /docker/cloud/clickhouse/conf
chmod -R 777 /docker/cloud/clickhouse/conf
chmod -R 777 /docker/cloud/clickhouse/conf
2、pull click house image
docker pull yandex/clickhouse-server:latest
3、创建临时容器
docker run --rm -d --name=clickhouse-server \
--ulimit nofile=262144:262144 \
-p 8123:8123 -p 9009:9009 -p 9000:9000 \
yandex/clickhouse-server:latest
4、复制容器中的配置文件到宿主机,用于修改账号密码
docker cp clickhouse-server:/etc/clickhouse-server/config.xml /docker/cloud/clickhouse/conf/config.xml
docker cp clickhouse-server:/etc/clickhouse-server/users.xml /docker/cloud/clickhouse/conf/users.xml
5、stop cotainer
docker stop clickhouse-server
6、随机生成 密码及对应 sha256 加密密码
PASSWORD=$(base64 < /dev/urandom | head -c8);
echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'
[root@VM-0-15-centos conf]# PASSWORD=$(base64 < /dev/urandom | head -c8);
[root@VM-0-15-centos conf]# echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'
wlbrwc1X
7e4c3d498c26c06f2a7515a5476b90638051f0635266d0bd26b1e97c8ef4a380[root@VM-0-15-centos conf]# echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'
5apFvh5o
fb47d5069eeaa3bcf531d832dac543c2ff397ddc471df650202ede8bba9b8a32
7、修改密码
vim /docker/cloud/clickhouse/conf/users.xml
<?xml version="1.0"?>
<yandex>
<!-- Profiles of settings. -->
<profiles>
<!-- Default settings. -->
<default>
<max_memory_usage>10000000000</max_memory_usage>
<use_uncompressed_cache>0</use_uncompressed_cache>
<load_balancing>random</load_balancing>
</default>
<!-- Profile that allows only read queries. -->
<readonly>
<max_memory_usage>10000000000</max_memory_usage>
<use_uncompressed_cache>0</use_uncompressed_cache>
<load_balancing>random</load_balancing>
<readonly>1</readonly>
</readonly>
</profiles>
<!-- Users and ACL. -->
<users>
<!-- If user name was not specified, 'default' user is used. -->
<default>
<password_sha256_hex>7e4c3d498c26c06f2a7515a5476b90638051f0635266d0bd26b1e97c8ef4a380</password_sha256_hex>
<networks incl="networks" replace="replace">
<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>fb47d5069eeaa3bcf531d832dac543c2ff397ddc471df650202ede8bba9b8a32</password_sha256_hex>
<networks incl="networks" replace="replace">
<ip>::/0</ip>
</networks>
<profile>default</profile>
<quota>default</quota>
</root>
</users>
<!-- Quotas. -->
<quotas>
<!-- Name of quota. -->
<default>
<!-- Limits for time interval. You could specify many intervals with different limits. -->
<interval>
<!-- Length of interval. -->
<duration>3600</duration>
<!-- No limits. Just calculate resource usage for time interval. -->
<queries>0</queries>
<errors>0</errors>
<result_rows>0</result_rows>
<read_rows>0</read_rows>
<execution_time>0</execution_time>
</interval>
</default>
</quotas>
</yandex>
创建只读账号 default 和 root 用户
8、启动容器
docker run -d --name=clickhouse-server \
-p 8123:8123 -p 9009:9009 -p 9000:9000 \
--ulimit nofile=262144:262144 \
-v /docker/cloud/clickhouse/data:/var/lib/clickhouse:rw \
-v /docker/cloud/clickhouse/conf/config.xml:/etc/clickhouse-server/config.xml \
-v /docker/cloud/clickhouse/conf/users.xml:/etc/clickhouse-server/users.xml \
-v /docker/cloud/clickhouse/log:/var/log/clickhouse-server:rw \
yandex/clickhouse-server:latest
9、使用 DBeaver 连接 click house
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)