ClickHouse是一个用于联机分析(OLAP)的列式数据库管理系统(DBMS)。
DEB安装包
sudo apt-get install apt-transport-https ca-certificates dirmngrsudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4echo "deb https://repo.clickhouse.tech/deb/stable/ main/" | sudo tee /etc/apt/sources.list.d/clickhouse.listsudo apt-get updatesudo apt-get install -y clickhouse-server clickhouse-clientsudo service clickhouse-server startclickhouse-client
RPM安装包
sudo yum install yum-utilssudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPGsudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64sudo yum install clickhouse-server clickhouse-clientsudo systemctl start clickhouse-server
Tgz安装包
export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+.[0-9]+.[0-9]+.[0-9]+' | head -n 1`curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgzcurl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgzcurl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgzcurl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgztar -xzvf clickhouse-common-static-$LATEST_VERSION.tgzsudo clickhouse-common-static-$LATEST_VERSION/install/doinst.shtar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgzsudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.shtar -xzvf clickhouse-server-$LATEST_VERSION.tgzsudo clickhouse-server-$LATEST_VERSION/install/doinst.shsudo /etc/init.d/clickhouse-server starttar -xzvf clickhouse-client-$LATEST_VERSION.tgzsudo clickhouse-client-$LATEST_VERSION/install/doinst.sh
Docker安装包
1.启动一个server实例
docker run -d --name some-clickhouse-server --ulimit nofile=262144:262144 yandex/clickhouse-server
2.启动一个映射本地卷的server实例
mkdir $HOME/some_clickhouse_database
docker run -d --name some-clickhouse-server --ulimit nofile=262144:262144 --volume=$HOME/some_clickhouse_database:/var/lib/clickhouse yandex/clickhouse-server
3.本地客户端连接
docker run -it --rm --link some-clickhouse-server:clickhouse-server yandex/clickhouse-client --host clickhouse-server
4.Dockerfile文件
FROM ubuntu:18.04ARG repository="deb http://repo.yandex.ru/clickhouse/deb/stable/ main/"ARG version=19.1.13ARG gosu_ver=1.10RUN apt-get update && apt-get install --yes --no-install-recommends apt-transport-https dirmngr gnupg && mkdir -p /etc/apt/sources.list.d && apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4 && echo $repository > /etc/apt/sources.list.d/clickhouse.list && apt-get update && env DEBIAN_FRONTEND=noninteractive apt-get install --allow-unauthenticated --yes --no-install-recommends clickhouse-common-static=$version clickhouse-client=$version clickhouse-server=$version libgcc-7-dev locales tzdata wget && rm -rf /var/lib/apt/lists/* /var/cache/debconf /tmp/* && apt-get cleanADD https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 /bin/gosuRUN locale-gen en_US.UTF-8ENV LANG en_US.UTF-8ENV LANGUAGE en_US:enENV LC_ALL en_US.UTF-8RUN mkdir /docker-entrypoint-initdb.dCOPY docker_related_config.xml /etc/clickhouse-server/config.d/COPY entrypoint.sh /entrypoint.shRUN chmod +x /entrypoint.sh /bin/gosuEXPOSE 9000 8123 9009VOLUME /var/lib/clickhouseENV CLICKHOUSE_CONFIG /etc/clickhouse-server/config.xmlENTRYPOINT ["/entrypoint.sh"]
启动clickhouse-server
1. 服务启动
sudo systemctl start clickhouse-server 或者 sudo /etc/init.d/clickhouse-server start
日志存放/var/log/clickhouse-server/
2.手动从控制台启动服务器:
clickhouse-server --config-file=/etc/clickhouse-server/config.xml
日志前台展示,便于调试
3.本地客户端连接
$ clickhouse-client
$ ./clickhouse-clientClickHouse client version 0.0.18749.Connecting to localhost:9000.Connected to ClickHouse server version 0.0.18749.:) SELECT 1SELECT 1┌─1─┐│ 1 │└───┘1 rows in set. Elapsed: 0.003 sec.:)