ClikHouse安装部署-Centos7
Centos7安装clickhouse
1.下载安装包
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-test-18.12.14-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-common-18.12.14-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-18.12.14-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-debuginfo-18.12.14-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-common-static-18.12.14-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-client-18.12.14-1.el7.x86_64.rpm/download.rpm
2.安装顺序
rpm -ivh clickhouse-server-common-18.12.14-1.el7.x86_64.rpm
rpm -ivh clickhouse-common-static-18.12.14-1.el7.x86_64.rpm
rpm -ivh clickhouse-server-18.12.14-1.el7.x86_64.rpm
rpm -ivh clickhouse-debuginfo-18.12.14-1.el7.x86_64.rpm
rpm -ivh clickhouse-test-18.12.14-1.el7.x86_64.rpm
rpm -ivh clickhouse-client-18.12.14-1.el7.x86_64.rpm
3.启动
启动clickhouse服务端
service clickhouse-server start
通过客户端连接
clickhouse-client –m
show databases;
4.参数配置
1 放开远程访问
vi /etc/clickhouse-server/config.xml
第65行,放开注释即可
<listen_host>
2 内存限制设置
vi /etc/clickhouse-server/users.xml
<max_memory_usage>
3 设置数据目录
vi /etc/clickhouse-server/config.xml
<path>/data/clickhouse/</path>
<tmp_path>/data/clickhouse/tmp/</tmp_path>
5.创建用户设置密码
https://www.jianshu.com/p/e339336e7bb9
配置文件:user.xml
核心配置3部分:
- profile配置,最大内存、负载方式等(没有特别关注,可见官方文档)
- 配额设置,单个用户最大能用的资源多少(没有特别关注,可见官方文档)
- 用户设置,包括用户名和密码
密码有2种,一种是明文,一种是写sha256sum的Hash值
官方不建议直接写明文密码
PASSWORD=$(base64 < /dev/urandom | head -c8);
echo "$PASSWORD";
echo -n "$PASSWORD" | sha256sum | tr -d '-'
6lYaUiFi967f3bf355dddfabfca1c9f5cab39352b2ec1cd0b05f9e1e6b8f629705fe7d6e
用户:clickhouse
clickhouse-client -h 127.0.0.1 -d mela -m -u clickhouse --password 12345
建表
CREATE DATABASE IF NOT EXISTS mela;
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] [db.]name AS [db2.]name2 [ENGINE = engine]
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] [db.]name ENGINE = engine AS SELECT ...