当前位置:网站首页>[基础服务] [数据库] ClickHouse的安装和配置
[基础服务] [数据库] ClickHouse的安装和配置
2022-07-26 19:46:00 【0xYGC】
简介
安装环境:CentOS 7.x or RedHat
方法 / 步骤
一:yum 安装
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo
sudo yum install -y clickhouse-server clickhouse-client
sudo /etc/init.d/clickhouse-server start
clickhouse-client
# 或者使用 "clickhouse-client --password" 如果你要设置密码
# 其他命令

- 开启外网访问
在默认服务配置文件 /etc/clickhouse-server/config.xml 放开外网绑定
<listen_host>0.0.0.0</listen_host>
- 其他相关命令
# 启动
sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml
# 重启
sudo systemctl restart clickhouse-server
二:Docker 安装
docker pull clickhouse/clickhouse-server
使用自定义配置启动服务器实例
docker run -d --name clickhouse-server8123 \
-p 8123:8123 -p 9000:9000 \
--ulimit nofile=262144:262144 \
-v /docker/clickhouse8123/clickhouse-server/conf/config.xml:/etc/clickhouse-server/config.xml \
-v /docker/clickhouse8123/clickhouse-server/conf/users.xml:/etc/clickhouse-server/users.xml \
-v /docker/clickhouse8123/clickhouse-server/log:/var/log/clickhouse-server:rw \
clickhouse/clickhouse-server
其他相关命令
# 启动删除容器命令
$ docker stop some-clickhouse-server
$ docker rm some-clickhouse-server
三:连接和配置
3.1 DBeaver的使用
连接ClickHouse数据库一般用两种方式DBeaver 和 网页端Tabix
3.1 网页端Tabix(官方推荐)
docker search clickhouse
docker pull spoonest/clickhouse-tabix-web-client
启动Tabix
docker run -d -p 8080:80 spoonest/clickhouse-tabix-web-client
- 打开可视化页面

HTTP clients 的默认端口号 8123 运行的SQL请求在 http://127.0.0.1:8123(把ip 改成你自己的IP)

注意,在 Play UI 中用默认值填充了用户名,密码文本字段保持为空。如果为默认用户分配了密码,请将其输入到 password 字段中。
尝试运行查询。例如,下面返回预定义数据库的名称:
SHOW databases
- 单击 RUN 按钮,响应显示在 Play UI 的下半部分:

四: 常规操作
4.1 建表语句,一定要指定引擎
create table tb_test(
id Int8 ,
name String
) engine=Memory;
4.2 Array数组类型
create table test_array(
name String ,
hobby Array(String)
) engine=Log;
insert into test_array values('于谦',['抽烟','喝酒','烫头']);
insert into test_array values('班长',['抽烟','于谦']);
-- 查看
SELECT * from test_array

4.3 Enum枚举类型
create table test_enum(
id UInt8 ,
color Enum('RED'=1,'GREEN'=2 ,'BLUE'=3)
)engine=Memory ;
-- 没有声明的值是不能插入
insert into test_enum values(1,'RED'),(3,'BLUE') ;
insert into test_enum values(4,'PINK');

4.4 Tuple元祖类型
create table test_tuple(
name String ,
info Tuple(String,String,UInt8)
)engine=Memory ;
insert into test_tuple values('zss',('M','coder',23)),('lss',tuple('F','coder',33));

4.5 Nested嵌套类型
create table test_nested(
uid Int8 ,
name String ,
hobby Nested(
id Int8 ,
hname1 String ,
hname2 String
)
)engine=Memory ;
insert into test_nested values (1,'zss',[1,2,3],['吃','喝','睡'],['eat','drink','sleep']);
insert into test_nested values (2,'lss',[1,2],['吃','喝'],['eat','drink']);

4.6 特殊类型
特殊类型包括Domain 、IPv6、IPv4(存储ip地址)和Nulltable 类型
4.6.1 IPv4类型
create table tb_ip2(
id Int8 ,
ip IPv4
)engine=Memory ;
insert into tb_ip2 values(1,'192.167.34.2') ;

4.6.2 Nulltable 类型
create table tb_nulltable (
id Int8 ,
age Nulltable(Int8)
)engine=Memory ;
安装完毕
- 后续学习资料
ClickHouse操作指南
参考资料 & 致谢
[1] Official website
[2] Github - ClickHouse
边栏推荐
- Vite configuration eslint specification code
- QT驾校科目考试系统——从实现到发布
- Shell script basic programming commands
- Do employees have to compensate the company for losses when they resign? The 34 year old captain resigned and was claimed 10.66 million yuan by the company
- 内网渗透学习(二)信息收集
- 实验6 BGP联邦综合实验
- 会议OA之会议排座&送审
- this指向,最简单的规则记住它
- [record of question brushing] 22. bracket generation
- Summary of message queue knowledge points
猜你喜欢

数字化工厂有哪些关键技术

员工辞职还得赔偿公司损失?34岁机长辞职被公司索赔1066万

.net GC workflow

How to implement an asynchronous task queue system that can handle massive data (supreme Collection Edition)

Task 1 report

When there are many query fields, you can add ordinary query and advanced query

Solve attributeerror: module 'win32com.gen_ py. 00020813-0000-0000-C000-000000000046x0x1x9‘ has no attribu

QT信号与槽连接(松耦合)

TinUI发展历程

Task 2 kaggle diabetes detection
随机推荐
C # use the default transformation method
第二章:遇到阻难!绕过WAF过滤!【SQL注入攻击】
Servlet
QT信号与槽连接(松耦合)
GBase学习-安装GBase 8a MPP Cluster V95
解决IBGP的水平分割和BGP选路原则
T246836 [LSOT-1] 暴龙的土豆
SwiftUI 4 新功能之实时获取点击位置 .onTapGesture { location in} (教程含源码)
BUU刷题记4
regular expression
The first training course was a perfect success (๑ㅂ•) و*
ES6新特性
Usage of Smoothscroll Polyfill plug-in
Leetcode-300 最长递增子序列
Definition and use of one-dimensional array
three. JS tag and pop-up the earth
Ue5 editor slate quick start [opening]
Student's t distribution
A super simple neural network code with 5 coordinates for one layer node training
The typing competition is over!