官方文档

安装(CentOS 7)

  1. 检测环境许可

    1
    grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
  2. 添加官方存储库

    1
    2
    3
    sudo yum install yum-utils
    sudo rpm --import https://repo.clickhouse.com/CLICKHOUSE-KEY.GPG
    sudo yum-config-manager --add-repo https://repo.clickhouse.com/rpm/stable/x86_64

    如果您想使用最新的版本,请用 testing 替代 stable(我们只推荐您用于测试环境)。prestable 有时也可用。

  3. 安装

    1
    sudo yum install clickhouse-server clickhouse-client

启动

  1. 配置文件

    编辑 /etc/clickhouse-server/config.xml,注释掉 <listen_host>...,开启对外访问。

  2. 启动

    1
    systemctl start clickhouse-server

ClickHouse Client 的快速提示

交互模式

1
2
clickhouse-client
clickhouse-client --host=... --port=... --user=... --password=...

启用多行查询

1
2
clickhouse-client -m
clickhouse-client --multiline

以批处理模式运行查询

1
2
3
clickhouse-client --query='SELECT 1'
echo 'SELECT 1' | clickhouse-client
clickhouse-client <<< 'SELECT 1'

从指定格式的文件中插入数据

1
2
clickhouse-client --query='INSERT INTO table VALUES' < data.txt
clickhouse-client --query='INSERT INTO table FORMAT TabSeparated' < data.tsv

ClickHouse Client 命令

命令参数文档

附:Docker (MySQL-ClickHouse-Tabix)

按照 readme 进行即可,截止到 2021-10-01 ClickHouse 为最新版本