新手上路

系统要求

这不是一个跨平台的系统,他需要Linux Ubuntu(12.04以后),x86_64架构,SSE4.2支持,测试SSE支持使用:

  1. grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"

我们建议使用Ubuntu Trusty 或Ubuntu Xenial或Ubuntu Precise,终端必须使用UTF-8编码(Ubuntu默认如此)

安装

对于测试和开发,可以在单机上安装

使用包安装

In /etc/apt/sources.list (or in a separate /etc/apt/sources.list.d/clickhouse.list file), add the repository:

On Ubuntu Trusty (14.04):

  1. deb http://repo.yandex.ru/clickhouse/trusty stable main

For other Ubuntu versions, replace trusty to xenial or precise.

Then run:

  1. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4 # optional
  2. sudo apt-get update
  3. sudo apt-get install clickhouse-client clickhouse-server-common

也可以自己下载安装: http://repo.yandex.ru/clickhouse/trusty/pool/main/c/clickhouse/ http://repo.yandex.ru/clickhouse/xenial/pool/main/c/clickhouse/ http://repo.yandex.ru/clickhouse/precise/pool/main/c/clickhouse/

ClickHouse包含了读取限制的设置,在”users.xml”文件中,与”config.xml”相邻。

默认情况下,允许默认用户从任何位置免密码读取数据。查看”user/default/networks”,更多信息查阅:Configuration files

从代码安装

跟着链接中的教程进行编译:build.md

你可以编译后安装,也可以不安装直接使用

  1. Client: src/dbms/src/Client/
  2. Server: src/dbms/src/Server/

在server中创建数据目录,例如:

  1. /opt/clickhouse/data/default/
  2. /opt/clickhouse/metadata/default/

目录的配置在server的配置文件中

使用chown设置相应用户权限。日志路径在server的配置文件中(src/dbms/src/Server/config.xml).

其他方式安装

Docker镜像: https://hub.docker.com/r/yandex/clickhouse-server/

Gentoo overlay: https://github.com/kmeaw/clickhouse-overlay

启动

启动命令(作为后台服务):

  1. sudo service clickhouse-server start

查看日志:

  1. /var/log/clickhouse-server/

如果服务没有正常启动,查看配置文件:

  1. /etc/clickhouse-server/config.xml

也可以在前台启动:

  1. clickhouse-server --config-file=/etc/clickhouse-server/config.xml

日志将会输出到控制台,开发阶段会更方便。默认的配置文件是./config.xml,如果是可以不需要加—config-file

使用下面的命令来连接server:

  1. clickhouse-client

默认情况下会连接到localhost:9000,使用default用户,没有密码。也可以连接到远程的服务器:

  1. clickhouse-client --host=example.com

更多信息参考“Command-line client

检查系统是否已经启动:

  1. milovidov@milovidov-Latitude-E6320:~/work/metrica/src/dbms/src/Client$ ./clickhouse-client
  2. ClickHouse client version 0.0.18749.
  3. Connecting to localhost:9000.
  4. Connected to ClickHouse server version 0.0.18749.
  5. :) SELECT 1
  6. SELECT 1
  7. ┌─1─┐
  8. 1
  9. └───┘
  10. 1 rows in set. Elapsed: 0.003 sec.
  11. :)

以上信息代表启动成功。

测试数据

如果不是Yandex员工, 可以使用公开的数据集:这里

如果有问题

可以在Stackoverflow上提问

可以在GoogleGroups里讨论

或发邮件至clickhouse-feedback@yandex-team.com