首页 > 其他分享 >ClickHouse02-小白快速部署和使用

ClickHouse02-小白快速部署和使用

时间:2024-03-19 09:02:11浏览次数:36  
标签:21 部署 noarch 小白 al8 ClickHouse02 server clickhouse 4.0

通过上篇已经了解到在OLAP领域,甚至开始侵占传统数据库市场的ClickHouse的一些特点,本篇就是小白快速上手篇,搭建一个试用。

在这里插入图片描述

快速上手体验功能

可以下载二进制文件,可用于运行 ClickHouse 服务器、clickhouse-client、clickhouse-local、ClickHouse Keeper 和其他工具

curl https://clickhouse.com/ | sh

./clickhouse server

./clickhouse client

生产使用:Linux平台安装

这边展示通过RPM包安装,此外还有DEB包、Tgz包

配置官方YUM仓库

[ clickhouse]# yum install -y yum-utils
Last metadata expiration check: 0:18:30 ago on Fri 26 Jan 2024 09:31:27 PM CST.
Package yum-utils-4.0.21-14.1.al8.noarch is already installed.
Dependencies resolved.
=========================================================================================================================================================================================
 Package                                                             Architecture                   Version                                Repository                               Size
=========================================================================================================================================================================================
Upgrading:
 dnf-plugins-core                                                    noarch                         4.0.21-19.al8                          alinux3-updates                          75 k
 python3-dnf-plugin-post-transaction-actions                         noarch                         4.0.21-19.al8                          alinux3-updates                          57 k
 python3-dnf-plugins-core                                            noarch                         4.0.21-19.al8                          alinux3-updates                         261 k
 yum-utils                                                           noarch                         4.0.21-19.al8                          alinux3-updates                          75 k
Installing dependencies:
 python3-systemd                                                     x86_64                         234-8.2.al8                            alinux3-os                               81 k

Transaction Summary
=========================================================================================================================================================================================
Install  1 Package
Upgrade  4 Packages

Total download size: 550 k
Downloading Packages:
(1/5): python3-dnf-plugin-post-transaction-actions-4.0.21-19.al8.noarch.rpm                                                                              4.1 MB/s |  57 kB     00:00    
(2/5): python3-systemd-234-8.2.al8.x86_64.rpm                                                                                                            4.7 MB/s |  81 kB     00:00    
(3/5): yum-utils-4.0.21-19.al8.noarch.rpm                                                                                                                8.3 MB/s |  75 kB     00:00    
(4/5): python3-dnf-plugins-core-4.0.21-19.al8.noarch.rpm                                                                                                  11 MB/s | 261 kB     00:00    
(5/5): dnf-plugins-core-4.0.21-19.al8.noarch.rpm                                                                                                         1.3 MB/s |  75 kB     00:00    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                    9.3 MB/s | 550 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                 1/1 
  Installing       : python3-systemd-234-8.2.al8.x86_64                                                                                                                              1/9 
  Upgrading        : python3-dnf-plugins-core-4.0.21-19.al8.noarch                                                                                                                   2/9 
  Upgrading        : dnf-plugins-core-4.0.21-19.al8.noarch                                                                                                                           3/9 
  Upgrading        : yum-utils-4.0.21-19.al8.noarch                                                                                                                                  4/9 
  Upgrading        : python3-dnf-plugin-post-transaction-actions-4.0.21-19.al8.noarch                                                                                                5/9 
  Cleanup          : yum-utils-4.0.21-14.1.al8.noarch                                                                                                                                6/9 
  Cleanup          : dnf-plugins-core-4.0.21-14.1.al8.noarch                                                                                                                         7/9 
  Cleanup          : python3-dnf-plugin-post-transaction-actions-4.0.21-14.1.al8.noarch                                                                                              8/9 
  Cleanup          : python3-dnf-plugins-core-4.0.21-14.1.al8.noarch                                                                                                                 9/9 
  Running scriptlet: python3-dnf-plugins-core-4.0.21-14.1.al8.noarch                                                                                                                 9/9 
  Verifying        : python3-systemd-234-8.2.al8.x86_64                                                                                                                              1/9 
  Verifying        : dnf-plugins-core-4.0.21-19.al8.noarch                                                                                                                           2/9 
  Verifying        : dnf-plugins-core-4.0.21-14.1.al8.noarch                                                                                                                         3/9 
  Verifying        : python3-dnf-plugin-post-transaction-actions-4.0.21-19.al8.noarch                                                                                                4/9 
  Verifying        : python3-dnf-plugin-post-transaction-actions-4.0.21-14.1.al8.noarch                                                                                              5/9 
  Verifying        : python3-dnf-plugins-core-4.0.21-19.al8.noarch                                                                                                                   6/9 
  Verifying        : python3-dnf-plugins-core-4.0.21-14.1.al8.noarch                                                                                                                 7/9 
  Verifying        : yum-utils-4.0.21-19.al8.noarch                                                                                                                                  8/9 
  Verifying        : yum-utils-4.0.21-14.1.al8.noarch                                                                                                                                9/9 

Upgraded:
  dnf-plugins-core-4.0.21-19.al8.noarch  python3-dnf-plugin-post-transaction-actions-4.0.21-19.al8.noarch  python3-dnf-plugins-core-4.0.21-19.al8.noarch  yum-utils-4.0.21-19.al8.noarch 
Installed:
  python3-systemd-234-8.2.al8.x86_64                                                                                                                                                     

Complete!

[ clickhouse]# yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo
Adding repo from: https://packages.clickhouse.com/rpm/clickhouse.repo

安装ClickHouse服务端和客户端

[ clickhouse]# yum install -y clickhouse-server clickhouse-client
ClickHouse - Stable Repository                                                                                                                           373  B/s | 833  B     00:02    
ClickHouse - Stable Repository                                                                                                                           5.3 kB/s | 5.7 kB     00:01    
Importing GPG key 0x2B48D754:
 Userid     : "ClickHouse Inc. Repositories Key <packages@clickhouse.com>"
 Fingerprint: 3A9E A119 3A97 B548 BE14 57D4 8919 F6BD 2B48 D754
 From       : https://packages.clickhouse.com/rpm/stable/repodata/repomd.xml.key
ClickHouse - Stable Repository                                                                                                                            52 kB/s | 266 kB     00:05    
Dependencies resolved.
=========================================================================================================================================================================================
 Package                                              Architecture                       Version                                     Repository                                     Size
=========================================================================================================================================================================================
Installing:
 clickhouse-client                                    x86_64                             23.12.2.59-1                                clickhouse-stable                             136 k
 clickhouse-server                                    x86_64                             23.12.2.59-1                                clickhouse-stable                             164 k
Installing dependencies:
 clickhouse-common-static                             x86_64                             23.12.2.59-1                                clickhouse-stable                             276 M

Transaction Summary
=========================================================================================================================================================================================
Install  3 Packages

Total download size: 276 M
Installed size: 862 M
Downloading Packages:
(1/3): clickhouse-server-23.12.2.59.x86_64.rpm                                                                                                            90 kB/s | 164 kB     00:01    
(2/3): clickhouse-client-23.12.2.59.x86_64.rpm                                                                                                            36 kB/s | 136 kB     00:03    
(3/3): clickhouse-common-static-23.12.2.59.x86_64.rpm                     10% [=======-                                                                ] 150 kB/s |  29 MB     28:14 ETA

sudo /etc/init.d/clickhouse-server start
clickhouse-client # or "clickhouse-client --password" if you set up a password.

启动并测试

【推荐】以服务的方式

sudo systemctl enable clickhouse-server
sudo systemctl start clickhouse-server
sudo systemctl status clickhouse-server
clickhouse-client # or "clickhouse-client --password" if you set up a password.

【已过时】手动启动

[ clickhouse]# /etc/init.d/clickhouse-server start
 chown -R clickhouse: '/var/run/clickhouse-server/'
Will run sudo --preserve-env -u 'clickhouse' /usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml --pid-file /var/run/clickhouse-server/clickhouse-server.pid --daemon
Waiting for server to start
Waiting for server to start
Server started

确认服务

[ clickhouse]# ps -e |grep clickhouse
 243525 ?        00:00:00 clickhouse-serv

生产使用:Docker/K8S环境安装

以下展示单节点,集群形式后续再讨论

单节点主要关注的config.xml内部的配置,做好挂载即可

Docker单节点

启动一个临时容器,用于获取config.xml

docker run --rm -d --name=temp-ch clickhouse/clickhouse-server

docker cp temp-ch:/etc/clickhouse-server/ ./clickhouse/conf/

修改config.xml,主要打开IPV6支持

 <!-- Same for hosts without support for IPv6: -->
    <listen_host>0.0.0.0</listen_host>

重新创建容器启动

docker run -d \
--name clickhouse \
--ulimit nofile=262144:262144 \
--volume=./clickhousenode/data:/var/lib/clickhouse \
--volume=./clickhousenode/conf/clickhouse-server/:/etc/clickhouse-server/ \
-p 9000:9000 \
-p 8123:8123 \
-p 9009:9009 \
clickhouse/clickhouse-server

K8S单节点

version: '3.8'
services: 
  cknode:
    image: clickhouse/clickhouse-server
    container_name: cknode
    hostname: cknode
    volumes:
      - ./clickhousenode/data:/var/lib/clickhouse
      - ./clickhousenode/conf/clickhouse-server/:/etc/clickhouse-server/
    ports:
      - "9000:9000"
      - "8123:8123"
      - "9009:9009"
      - "9363:9363"

关于端口

  • 8123 是 ClickHouse 提供的 HTTP 端口,用于 HTTP 接口访问,它提供了 RESTful API 以及交互式的查询终端界面。
  • 9000 是 ClickHouse 的默认 TCP 端口,用于 Native TCP 协议进行交互,提供高效的数据交换。
  • 9363 在一些情况下是指 ClickHouse 的分布式表引擎使用的 gRPC 端口,用于 ClickHouse 集群间的内部通信,尤其是在涉及到 ZooKeeper 集群管理和复制时。

确认服务启动

对于Linux平台、Docker或者K8S平台,可以使用 clickhouse-client 进行了连接访问测试

此外还可以书写简单的JAVA访问程序进行测试

                    String url = "jdbc:ch://127.0.0.1:8123/default"; // use http protocol and port 8123 by default
                    Properties properties = new Properties();
                    List<HitsAll> list = new ArrayList<>();
                    try {
                        ClickHouseDataSource dataSource = new ClickHouseDataSource(url, properties);
                        try (Connection conn = dataSource.getConnection("default", "");
                             Statement stmt = conn.createStatement()) {
                            ResultSet rs = stmt.executeQuery("select * from default.hits_all ");
                            while (rs.next()) {
                                int id = rs.getInt("id");
                                HitsAll hitsAll = new HitsAll();
                                hitsAll.setId(id);
                                list.add(hitsAll);
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

如果喜欢我的文章的话,可以去GitHub上给一个免费的关注吗?

标签:21,部署,noarch,小白,al8,ClickHouse02,server,clickhouse,4.0
From: https://blog.csdn.net/c_zyer/article/details/136828925

相关文章

  • Ruoyi前后端分离项目部署至Tomcat上
    项目部署4.1.前端打包disaster-ui目录下为本项目的前端所在位置,在命令行窗口进入该目录,然后输入npmrunbuild:prod部署前端Vue项目,或者直接在disaster-ui/bin目录下双击build.bat文件部署前端。图4-1前端部署图4.2环境变量在MySQL可视化软件中新建flowable数据库(以......
  • 【Docker】wordpress 容器化部署
    WordPress标准软件基于Bitnamiwordpress构建。当前版本为6.4.3你可以通过轻云UC部署工具直接安装部署,也可以手动按如下文档操作,该项目已经全面开源,可以从如下环境获取配置文件地址:https://gitee.com/qingplus/qingcloud-platformqinghub自动安装部署配置库什么是Wo......
  • webapi通过docker部署到Linux的两种方式
    docker安装官网删除dockersudoyumremovedocker\docker-client\docker-client-latest\docker-common\docker-latest\docker-latest-logrotate\docker-logrotate\docker-engine安装sudoyuminstall-yyum-utilssudoyum-config-manage......
  • 旭日x3派部署自己训练的模型(安全帽识别、视频流推理、yolov5-6.2)
    旭日x3派部署自己训练的模型(安全帽识别、视频流推理、yolov5-6.2)windows,框架pytorch,python3.7效果模型训练模型转换1、pt模型文件转onnx2、检查onnx模型3、准备校准数据4、onnx转bin上板视频流推理1、图片推理2、视频流推理效果模型训练进官网可克隆yolov5......
  • 零基础小白如何入门HarmonyOS鸿蒙应用开发学习?
    HarmonyOS鸿蒙应用开发是当前非常热门的一个领域,许多人都想入门学习这个技术。但是,对于零基础的人来说,如何入门确实是一个问题。下面,我将从以下几个方面来介绍如何零基础入门HarmonyOS鸿蒙应用开发学习。一、了解HarmonyOS鸿蒙系统首先,我们需要了解HarmonyOS鸿蒙系统的一些......
  • 数字人解决方案— SadTalker语音驱动图像生成视频原理与源码部署
    简介随着数字人物概念的兴起和生成技术的不断发展,将照片中的人物与音频输入进行同步变得越来越容易。然而,目前仍存在一些问题,比如头部运动不自然、面部表情扭曲以及图片和视频中人物面部的差异等。为了解决这些问题,来自西安交通大学等机构的研究人员提出了SadTalker模型......
  • jenkins前端部署
    下载插件NodeJSPlugin(nodejs环境)PublishoverSSH(用于执行构建后的操作)GiteePlugin(由于我用的是gitee管理代码,所以需要安装)2。a.新建项目名称b.配置源码管理(Git仓库)c.配置购置触发器d.配置构建环境(node及npm)e.配置构建(写shell脚本)source/etc/profile:加载环......
  • 急速搭建ChatGPT——GPT4All本地部署
    云服务器可至雨云进行购买首先打开雨云官网雨云官网网址:https://www.rainyun.com/YZJ_?s=xxx 然后登录/注册雨云(登录/注册建在右上角)  如果没注册就点击下方注册,然后如果显示“正在使用优惠通道注册”就照常输入信息 没有则优惠码填“YZJ” 推荐配......
  • Docker部署Django项目——基础
    1.服务器配置1.1centos7系统的安装centos-7-isos-x86_64安装包下载)VMware安装自定义配置选择对应的系统镜像一般选择内核4核、内存8g、硬盘80g相关配置1.2.网络配置1.2.1查看win电脑虚拟机VMnet8的ip使用ipconfig查看虚拟机的ip1.2.2配置虚拟机VMne......
  • nexus部署迁移
    本文由ilanniweb提供友情赞助,首发于烂泥行天下想要获得更多的文章,可以关注我的微信ilanniwebjenkins技术分享QQ群:57198125720190829更新nexus2下载地址:https://help.sonatype.com/repomanager2/download/download-archives—repository-manager-ossnexus3下载地址:https:/......