Files
compose-anything/src/clickhouse/README.zh.md
Sun-ZhenXing ece59b42bf Add environment configuration and documentation for various services
- Created .env.example files for Kafka, Kibana, KodBox, Kong, Langfuse, Logstash, n8n, Nginx, OceanBase, OpenCoze, RocketMQ, TiDB, and TiKV.
- Added README.md and README.zh.md files for OceanBase, RocketMQ, TiDB, and TiKV, detailing usage, configuration, and access instructions.
- Implemented docker-compose.yaml files for OceanBase, RocketMQ, TiDB, and TiKV, defining service configurations, health checks, and resource limits.
- Included broker.conf for RocketMQ to specify broker settings.
- Established a consistent timezone (UTC) across all services.
- Provided optional port overrides in .env.example files for flexibility in deployment.
2025-10-22 11:46:50 +08:00

1.8 KiB
Raw Blame History

ClickHouse

ClickHouse 是一个快速的开源列式数据库管理系统,支持实时生成分析数据报告。

使用方法

docker compose up -d

配置说明

主要环境变量:

  • CLICKHOUSE_DB:默认数据库名称(默认:default
  • CLICKHOUSE_USER:默认用户名(默认:default
  • CLICKHOUSE_PASSWORD:默认用户密码(默认:clickhouse
  • CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT:启用 SQL 驱动的访问控制(默认:1

端口说明

  • 8123HTTP 接口
  • 9000Native TCP 协议
  • 9004MySQL 协议模拟
  • 9005PostgreSQL 协议模拟

访问方式

HTTP 接口

curl 'http://localhost:8123/?user=default&password=clickhouse' -d 'SELECT 1'

ClickHouse 客户端

docker compose exec clickhouse clickhouse-client --user default --password clickhouse

MySQL 协议

mysql -h127.0.0.1 -P9004 -udefault -pclickhouse

PostgreSQL 协议

psql -h127.0.0.1 -p9005 -Udefault

示例查询

-- 创建表
CREATE TABLE events (
    event_date Date,
    event_type String,
    user_id UInt32
) ENGINE = MergeTree()
ORDER BY (event_date, event_type);

-- 插入数据
INSERT INTO events VALUES ('2024-01-01', 'click', 1), ('2024-01-01', 'view', 2);

-- 查询数据
SELECT * FROM events;

注意事项

  • ClickHouse 专为 OLAP在线分析处理工作负载优化
  • 擅长快速聚合大量数据
  • 生产环境建议使用集群配置和复制功能
  • 自定义配置可以挂载到 /etc/clickhouse-server/config.d//etc/clickhouse-server/users.d/

参考资料