操作系统是CentOS7
sudo yum install -y curl
curl -s https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | sudo bash
由于网络原因,可能会失败,多试几次
sudo yum list 'clickhouse*'
sudo yum install -y clickhouse-server clickhouse-client
sudo yum list installed 'clickhouse*'
sudo service clickhouse-server start
这种是后台启动,自动使用/etc/clickhouse-server/config.xml作为配置文件,也可以手动启动,指定配置文件:
clickhouse-server --config=/etc/clickhouse-server/config.xml
clickhouse-client
进入到clickhouse客户端,与MySQL客户端类似,show databases、show tables等,简单试下
localhost :) show databases
SHOW DATABASES
┌─name────┐
│ default │
│ system │
└─────────┘
2 rows in set. Elapsed: 0.030 sec.
localhost :) exit
Bye.
重启
service clickhouse-server restart
官方安装教程:https://github.com/Altinity/clickhouse-rpm-install
安装完成后导入数据
创建表
create table kfdatabase
(
Name String,
CardNo String,
Descriot String,
CtfTp String,
CtfId String,
Gender String,
Birthday String,
Address String,
Zip String,
Dirty String,
District1 String,
District2 String,
District3 String,
District4 String,
District5 String,
District6 String,
FirstNm String,
LastNm String,
Duty String,
Mobile String,
Tel String,
Fax String,
EMail String,
Nation String,
Taste String,
Education String,
Company String,
CTel String,
CAddress String,
CZip String,
Family String,
Version String,
id String
)
engine = Memory;
执行导入命令200W数据一个文件没有列名的。
clickhouse-client --database=default --user=default --input_format_allow_errors_num=1000 --input_format_allow_errors_ratio=0.1 --query="INSERT INTO default.kfdatabase FORMAT CSV"
导入文件 CSV文件命令有列名的:
clickhouse-client --database=default --user=default --input_format_allow_errors_num=1000 --input_format_allow_errors_ratio=0.1 --query="INSERT INTO default.kfdatabase FORMAT CSVWithNames"