ClickHouse 单节点快速玩耍
Debian
安装依赖包
apt-get -y install curl gnupg2 apt-transport-https ca-certificates
追加仓库镜像源
sh -c 'mkdir -p /usr/share/keyrings && curl -s https://builds.altinity.cloud/apt-repo/pubkey.gpg | gpg --dearmor > /usr/share/keyrings/altinity-archive-keyring.gpg'
sh -c 'echo "deb [signed-by=/usr/share/keyrings/altinity-archive-keyring.gpg] https://builds.altinity.cloud/apt-repo stable main" > /etc/apt/sources.list.d/altinity.list'
apt update
安装指定版本
version=23.8.11.29.altinitystable-1
apt-get install clickhouse-common-static=$version clickhouse-client=$version clickhouse-server=$version
RHEL 分支
追加仓库镜像源
curl https://builds.altinity.cloud/yum-repo/altinity.repo -o /etc/yum.repos.d/altinity.repo
安装指定版本
version=23.8.11.29.altinitystable-1
sudo $(type -p dnf || type -p yum) install clickhouse-common-static-$version clickhouse-server-$version clickhouse-client-$version
Docker
容器编排YAML文件内容
version: '3'
services:
clickhouse_server:
image: altinity/clickhouse-server:23.8.11.29.altinitystable-1
ports:
- "8123:8123"
volumes:
- ./clickhouse_database:/var/lib/clickhouse
networks:
- clickhouse_network
networks:
clickhouse_network:
driver: bridge
ipam:
config:
subnet: 10.222.1.0/24
服务启动
docker-compose up -d
常规配置
常规配置修改
# vim /etc/clickhouse-server/config.xml
...<省略若干行>...
<listen_host>0.0.0.0</listen_host> # 218行
<path>/data/dbs/clickhouse</path> # 425行
...<省略若干行>...
创建数据库
$ clickhouse-client --query="create database demo_db;"
创建用户并分配权限
$ echo -n "密码" | sha256sum | tr -d '-'
$ clickhouse-client --query="create user zhang3 IDENTIFIED WITH SHA256_HASH BY '密码密文'"
$ clickhouse-client --query="GRANT ALL ON demo_db.* TO zhang3;"