当前位置:网站首页>[基础服务] [数据库] 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
边栏推荐
- C # convert PDF files into pictures
- 福音!微信个人公众号可以改名了!
- 任务一 报告
- Week 6 Convolutional Neural Networks (CNNs)
- Game partner topic: breederdao and ultiverse have established a new metauniverse
- 本机号码一键登录原理与应用(荣耀典藏版)
- Is flush reliable? I just started to learn financial management. Is it safe to open a securities account?
- Kotlin - 协程上下文 CoroutineContext
- Software testing - development test content specification (project test template)
- A little cool, explore space with.Net Maui
猜你喜欢

The sandbox cooperates with artist Alec monopoly

Software testing - development test content specification (project test template)

Week 6 Convolutional Neural Networks (CNNs)

The typing competition is over!

App uploader download and installation

URL format

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

BGP的路由黑洞和防环

What are the key technologies of digital factory

Where are the single dogs in the evening of 5.20?
随机推荐
会议OA之会议排座&送审
T246836 [lsot-1] potatoes of Tyrannosaurus Rex
一层节点训练5个坐标的超简单神经网络代码
同花顺靠谱吗?我刚开始学习理财,开证券账户安全吗?
第一次培训课完美成功(๑•ㅂ•)و*
HM中如何获取CU块划分信息并用Matlab绘图
Exchange 2010 SSL certificate installation document
tf.GraphKeys
numpy.zeros_ like
PSPICE 仿真石英晶体振荡电路
QT驾校科目考试系统——从实现到发布
Where are the single dogs in the evening of 5.20?
查询字段较多时可以添加普通查询和高级查询两种情况
Ue5 editor slate quick start [opening]
EtherCAT 同步模式
What are the key technologies of digital factory
numpy.put()
This point - super classic interview questions
第二章:遇到阻难!绕过WAF过滤!【SQL注入攻击】
MPLS 多协议标签交换技术