【Linux服务器Java环境搭建】09 在CentOS系统中安装和配置clickhouse数据库

news2024/11/22 16:36:55

一、安装环境

CentOS7

二、官网安装参考文档

官网安装参考文档

不同系统请参考如下建议

  • 从RPM软件包安装:
    建议在CentOS、RedHat和所有其他基于rpm的Linux发行版上使用官方预编译的rpm软件包
  • 从DEB软件包安装:
    建议在Debian或Ubuntu上使用官方预编译的deb软件包

三、安装步骤

1. 设置clickhouse仓库

执行如下命令,设置clickhouse官方仓库

[root@172 ~]# yum install -y yum-utils
[root@172 ~]# yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo

在这里插入图片描述

2. 安装clickhouse服务和客户端

[root@172 ~]# yum install -y clickhouse-server clickhouse-client

在这里插入图片描述
在这里插入图片描述

3. 启动clickhouse服务

如下为clickhouse相关命令

命令说明
systemctl status clickhouse-server查看服务状态
systemctl start clickhouse-server启动服务
systemctl stop clickhouse-server停止服务
systemctl enable clickhouse-server设置服务为自启动
systemctl disable clickhouse-server禁用服务为自启动

未启动状态
在这里插入图片描述
启动之后的状态
在这里插入图片描述

4、通过clickhouse-client连接clickhouse数据库

clickhouse-client # or "clickhouse-client --password" if you set up a password.

在这里插入图片描述

四 查看clickhouse配置文件以及设置密码

注意:默认账号为default ,密码为空

1. 查看配置文件

[root@172 /]# cat /etc/clickhouse-server/config.xml

内容较多,只截取部分

<!--display_name>production</display_name-->

    <!-- Port for HTTP API. See also 'https_port' for secure connections.
         This interface is also used by ODBC and JDBC drivers (DataGrip, Dbeaver, ...)
         and by most of web interfaces (embedded UI, Grafana, Redash, ...).
      -->
    <http_port>8123</http_port>

    <!-- Port for interaction by native protocol with:
         - clickhouse-client and other native ClickHouse tools (clickhouse-benchmark, clickhouse-copier);
         - clickhouse-server with other clickhouse-servers for distributed query processing;
         - ClickHouse drivers and applications supporting native protocol
         (this protocol is also informally called as "the TCP protocol");
         See also 'tcp_port_secure' for secure connections.
    -->
    <tcp_port>9000</tcp_port>

    <!-- Compatibility with MySQL protocol.
         ClickHouse will pretend to be MySQL for applications connecting to this port.
    -->
    <mysql_port>9004</mysql_port>

    <!-- Compatibility with PostgreSQL protocol.
         ClickHouse will pretend to be PostgreSQL for applications connecting to this port.
    -->
    <postgresql_port>9005</postgresql_port>

    <!-- HTTP API with TLS (HTTPS).
         You have to configure certificate to enable this interface.
         See the openSSL section below.
    -->
    <!-- <https_port>8443</https_port> -->

    <!-- Native interface with TLS.
         You have to configure certificate to enable this interface.
         See the openSSL section below.
    -->
    <!-- <tcp_port_secure>9440</tcp_port_secure> -->

    <!-- Native interface wrapped with PROXYv1 protocol
         PROXYv1 header sent for every connection.
         ClickHouse will extract information about proxy-forwarded client address from the header.
    -->
    <!-- <tcp_with_proxy_port>9011</tcp_with_proxy_port> -->

    <!-- Port for communication between replicas. Used for data exchange.
         It provides low-level data access between servers.
         This port should not be accessible from untrusted networks.
         See also 'interserver_http_credentials'.
         Data transferred over connections to this port should not go through untrusted networks.
         See also 'interserver_https_port'.
      -->
    <interserver_http_port>9009</interserver_http_port>

2. 设置密码

[root@172 /]# vim /etc/clickhouse-server/users.xml

如下为具体内容,请注意password部分

<?xml version="1.0"?>
<clickhouse>
    <!-- See also the files in users.d directory where the settings can be overridden. -->

    <!-- Profiles of settings. -->
    <profiles>
        <!-- Default settings. -->
        <default>
            <!-- Maximum memory usage for processing single query, in bytes. -->
            <max_memory_usage>10000000000</max_memory_usage>

            <!-- How to choose between replicas during distributed query processing.
                 random - choose random replica from set of replicas with minimum number of errors
                 nearest_hostname - from set of replicas with minimum number of errors, choose replica
                  with minimum number of different symbols between replica's hostname and local hostname
                  (Hamming distance).
                 in_order - first live replica is chosen in specified order.
                 first_or_random - if first replica one has higher number of errors, pick a random one from replicas with minimum number of errors.
            -->
            <load_balancing>random</load_balancing>
        </default>

        <!-- Profile that allows only read queries. -->
        <readonly>
            <readonly>1</readonly>
        </readonly>
    </profiles>

    <!-- Users and ACL. -->
    <users>
        <!-- If user name was not specified, 'default' user is used. -->
        <default>
            <!-- See also the files in users.d directory where the password can be overridden.

                 Password could be specified in plaintext or in SHA256 (in hex format).

                 If you want to specify password in plaintext (not recommended), place it in 'password' element.
                 Example: <password>qwerty</password>.
                 Password could be empty.

                 If you want to specify SHA256, place it in 'password_sha256_hex' element.
                 Example: <password_sha256_hex>65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5</password_sha256_hex>
                 Restrictions of SHA256: impossibility to connect to ClickHouse using MySQL JS client (as of July 2019).

                 If you want to specify double SHA1, place it in 'password_double_sha1_hex' element.
                 Example: <password_double_sha1_hex>e395796d6546b1b65db9d665cd43f0e858dd4303</password_double_sha1_hex>

                 If you want to specify a previously defined LDAP server (see 'ldap_servers' in the main config) for authentication,
                  place its name in 'server' element inside 'ldap' element.
                 Example: <ldap><server>my_ldap_server</server></ldap>

                 If you want to authenticate the user via Kerberos (assuming Kerberos is enabled, see 'kerberos' in the main config),
                  place 'kerberos' element instead of 'password' (and similar) elements.
                 The name part of the canonical principal name of the initiator must match the user name for authentication to succeed.
                 You can also place 'realm' element inside 'kerberos' element to further restrict authentication to only those requests
                  whose initiator's realm matches it.
                 Example: <kerberos />
                 Example: <kerberos><realm>EXAMPLE.COM</realm></kerberos>

                 How to generate decent password:
                 Execute: PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'
                 In first line will be password and in second - corresponding SHA256.

                 How to generate double SHA1:
                 Execute: PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-'
                 In first line will be password and in second - corresponding double SHA1.
            -->
            <password>设置自己的密码</password>

            <!-- List of networks with open access.

                 To open access from everywhere, specify:
                    <ip>::/0</ip>

                 To open access only from localhost, specify:
                    <ip>::1</ip>
                    <ip>127.0.0.1</ip>

                 Each element of list has one of the following forms:
                 <ip> IP-address or network mask. Examples: 213.180.204.3 or 10.0.0.1/8 or 10.0.0.1/255.255.255.0
                     2a02:6b8::3 or 2a02:6b8::3/64 or 2a02:6b8::3/ffff:ffff:ffff:ffff::.
                 <host> Hostname. Example: server01.yandex.ru.
                     To check access, DNS query is performed, and all received addresses compared to peer address.
                 <host_regexp> Regular expression for host names. Example, ^server\d\d-\d\d-\d\.yandex\.ru$
                     To check access, DNS PTR query is performed for peer address and then regexp is applied.
                     Then, for result of PTR query, another DNS query is performed and all received addresses compared to peer address.
                     Strongly recommended that regexp is ends with $
                 All results of DNS requests are cached till server restart.
            -->
            <networks>
                <ip>::/0</ip>
            </networks>

            <!-- Settings profile for user. -->
            <profile>default</profile>

            <!-- Quota for user. -->
            <quota>default</quota>

            <!-- User can create other users and grant rights to them. -->
            <!-- <access_management>1</access_management> -->
        </default>
    </users>

    <!-- Quotas. -->
    <quotas>
        <!-- Name of quota. -->
        <default>
            <!-- Limits for time interval. You could specify many intervals with different limits. -->
            <interval>
                <!-- Length of interval. -->
                <duration>3600</duration>

                <!-- No limits. Just calculate resource usage for time interval. -->
                <queries>0</queries>
                <errors>0</errors>
                <result_rows>0</result_rows>
                <read_rows>0</read_rows>
                <execution_time>0</execution_time>
            </interval>
        </default>
    </quotas>
</clickhouse>

五、监听8123端口的服务

[root@172 /]# netstat -tulpn | grep 8123

这将显示正在监听8123端口的服务,以及它的进程ID(PID)
在这里插入图片描述

六、开放8123端口号

  • 设置开放的端口号
[root@172 /]# firewall-cmd --add-port=8123/tcp --permanent
  • 重启防火墙
[root@172 /]# firewall-cmd --reload
  • 查看当前已开放的端口号
[root@172 /]# firewall-cmd --list-all

在这里插入图片描述

七、通过数据库管理工具链接测试

1、连接测试报错如下

Connection refused: no further information
在这里插入图片描述

2、解决方案

出现如上问题的原因是因为配置文件中,对于远程连接IP的设置的原因

通过如下命令查看配置文件

[root@172 clickhouse-server]# cat config.xml

如下为默认配置信息,注意<!-- <listen_host>::</listen_host> -->

 <!-- Listen specified address.
         Use :: (wildcard IPv6 address), if you want to accept connections both with IPv4 and IPv6 from everywhere.
         Notes:
         If you open connections from wildcard address, make sure that at least one of the following measures applied:
         - server is protected by firewall and not accessible from untrusted networks;
         - all users are restricted to subset of network addresses (see users.xml);
         - all users have strong passwords, only secure (TLS) interfaces are accessible, or connections are only made via TLS interfaces.
         - users without password have readonly access.
         See also: https://www.shodan.io/search?query=clickhouse
      -->
    <!-- <listen_host>::</listen_host> -->


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

    <!-- Default values - try listen localhost on IPv4 and IPv6. -->
    <!--
    <listen_host>::1</listen_host>
    <listen_host>127.0.0.1</listen_host>
    -->

解决方案:
把注释去掉,修改完成后如下<listen_host>::</listen_host>
通过如下命令修改配置文件,目录为[root@172 /]# cd /etc/clickhouse-server

[root@172 clickhouse-server]# vim config.xml

在这里插入图片描述
修改完成后,保存并退出,再次测试,成功连接
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1308544.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

深圳移动与大富科技助力深圳人工智能教育高质量发展

12月12日&#xff0c;中国移动通信集团广东有限公司深圳分公司(以下简称“深圳移动”) 与大富科技&#xff08;安徽&#xff09;股份有限公司&#xff08;以下简称“大富科技”&#xff09;在中国移动深圳信息大厦签署“战略合作框架协议”&#xff0c;共同推进人工智能教育、I…

物联网与低代码:构建智能化的连接世界

物联网&#xff08;IoT&#xff09;是指通过互联网将各种物理设备、传感器、车辆等连接起来&#xff0c;从而实现数据交互和智能化控制的技术领域。而低代码开发平台则是一种快速构建应用程序的方法&#xff0c;通过简化开发过程&#xff0c;使开发人员能够更迅速地实现创意和创…

数据结构学习 快速幂

看了这一篇很好的文章&#xff1a;快速幂&#xff0c;学习了一下快速幂。如果你看到这篇文章想要学习快速幂&#xff0c;我建议你直接去看这篇文章吧&#xff0c;下面的都是我个人的笔记和碎碎念。 重拾我的考研线性代数&#xff0c;非常有趣呢&#xff01; 基本的快速幂&…

Flutter之Android Studio No connected devices found

看图1. 是有显示有Redmi虚拟机的。 看图2. 没有Redmi虚拟机可选择&#xff0c;继续往下看解决方案。 看图3.点开项目结构设置SDK确定。 看图4.它来了

基于JavaWeb+SSM+Vue实习记录微信小程序系统的设计和实现

基于JavaWebSSMVue实习记录微信小程序系统的设计和实现 源码获取入口Lun文目录前言主要技术系统设计功能截图订阅经典源码专栏Java项目精品实战案例《500套》 源码获取 源码获取入口 Lun文目录 目 录 摘 要 III Abstract 1 1 系统概述 1 1.1 概述 2 1.2课题意义 3 1.3 主要内…

thinkphp 中 关联查询 like 查询失效

controller: public function goodsList(){if (request()->isGet()) {//表单验证//调用发布$where [];$goodname $this->request->param(goodname, );if(!empty($goodname)){$where[] [name,like,$goodname];}return $this->logic->goodsList($where, $this-…

【EXCEL】vlookup,index/match查找函数

区别&#xff1a; 1.Vlookup函数只能查找列数据&#xff0c;即纵向查找&#xff0c;而IndexMatch函数&#xff0c;既可以纵向查找&#xff0c;也可以横向查找&#xff1b; 2、Vlookup函数查找的依据(第一个参数)必须位于数据源的第一列&#xff0c;IndexMatch函数组合则无此限制…

​Linux Ubuntu环境下使用docker构建spark运行环境(超级详细)

​Linux Ubuntu环境下使用docker构建spark运行环境&#xff08;超级详细&#xff09; 这篇文章深入研究了在Linux Ubuntu环境下使用Docker构建Spark运行环境的详细步骤。首先&#xff0c;文章介绍了Spark的基本概念以及在大数据处理中的关键作用&#xff0c;为读者提供了对Spa…

设计模式——观察者模式(Observer Pattern)

概述 观察者模式是使用频率最高的设计模式之一&#xff0c;它用于建立一种对象与对象之间的依赖关系&#xff0c;一个对象发生改变时将自动通知其他对象&#xff0c;其他对象将相应作出反应。在观察者模式中&#xff0c;发生改变的对象称为观察目标&#xff0c;而被通知的对象称…

广西岑溪市火灾通报:1人死亡 AI科技助力预防悲剧

近日&#xff0c;广西岑溪市玉梧大道紫坭工业园一厂房发生一起令人心痛的火灾事件&#xff0c;造成1人不幸丧生。这起悲剧再次提醒我们&#xff0c;火灾的防范工作是多么的重要。在这样的背景下&#xff0c;我想分享一个能够有效预防类似悲剧的技术——北京富维图像公司开发的F…

鸿蒙原生应用/元服务开发-Stage模型能力接口(三)

一、说明 AbilityLifecycleCallback模块提供应用上下文ApplicationContext的生命周期发生变化时触发相应回调的能力&#xff0c;包括onAbilityCreate、onWindowStageCreate、onWindowStageActive、onWindowStageInactive、onWindowStageDestroy、onAbilityDestroy、onAbilityFo…

力扣题:数字与字符串间转换-12.14

力扣题-12.14 [力扣刷题攻略] Re&#xff1a;从零开始的力扣刷题生活 力扣题1&#xff1a;442. 数组中重复的数据 解题思想&#xff1a;从字符串中能够正确提取数字即可 class Solution(object):def complexNumberMultiply(self, num1, num2):""":type num1:…

acwing-蓝桥杯C++ AB组辅导课Day1-递归

感谢梦翔老哥的蓝桥杯C AB组辅导课~ 省一刷200题 国赛拿成绩300题 比赛考察的是各种模型的熟练度&#xff0c;可以从dfs的角度比较各个模型与当前问题的匹配程度。 常见时间复杂度&#xff0c;根据时间复杂度可以判别是否可以选用这个解题思路 写递归的时候&#xff…

visual Studio MFC 平台实现图片的傅里叶变换

图片的傅里叶变换 本文主要讲解傅里叶变换的基本数学概念与物理概念&#xff0c;并本文使用visual Studio MFC 平台实现对傅里叶变换在图片上进行了应用。 一、傅里叶变换的原理 在这里推荐一篇讲得非常形象的文章通俗讲解&#xff1a;图像傅里叶变换 1.1 傅里叶变换原理的说明…

kernel(三):kernel移植

本文主要探讨210官方kernel移植。 配置文件选择 选择配置文件smdkv210_android_defconfig(arch/arm/configs) 修改主Makefile 配置cpu架构和交叉编译工具链 vim MakefileARCH ? armCROSS_COMPILE ? /root/arm-2009q3/bin/arm-none-linux-gnueabi- 初步编译烧…

HarmonyOS应用程序框架

应用程序入口—UIAbility的使用 UIAbility概述 UIAbility是一种包含用户界面的应用组件&#xff0c;主要用于和用户进行交互。UIAbility也是系统调度的单元&#xff0c;为应用提供窗口在其中绘制界面。 每一个UIAbility实例&#xff0c;都对应于一个最近任务列表中的任务。 …

【论文阅读】MAKE-A-VIDEO: TEXT-TO-VIDEO GENERATION WITHOUT TEXT-VIDEO DATA

Make-a-video:没有文本-视频数据的文本-视频生成。 paper&#xff1a; code&#xff1a; ABSTRACT 优点: (1)加速了T2V模型的训练(不需要从头开始学习视觉和多模态表示)&#xff0c; (2)不需要配对的文本-视频数据&#xff0c; (3)生成的视频继承了当今图像生成模型的庞大…

HBase 高可用集群详细图文安装部署

目录 一、HBase 安装部署 1.1 Zookeeper 正常部署 1.2 Hadoop 正常部署 1.3 HBase 安装 1.4 HBase 的配置文件 1.4.1 hbase-env.sh 1.4.2 hbase-site.xml 1.4.3 regionservers 1.4.4 创建目录 1.5 HBase 远程发送到其他节点 1.6 HBase 服务的启动 1.6.1 单点…

用友时空 KSOA 多处SQL注入漏洞复现

0x01 产品简介 用友时空 KSOA 是建立在 SOA 理念指导下研发的新一代产品,是根据流通企业前沿的 IT 需求推出的统一的IT基础架构,它可以让流通企业各个时期建立的 IT 系统之间彼此轻松对话。 0x02 漏洞概述 用友时空 KSOA 系统 PayBill、QueryService、linkadd.jsp等接口处…

数字化赋能实体经济,凌雄科技发挥DaaS模式提质增效价值

11月中旬&#xff0c;市场监管总局发布了2023年前三季度经营主体数据。其中&#xff0c;前三季度全国新设民营企业总计706.5万户&#xff0c;截至9月底&#xff0c;全国登记在册的民营企业数量超过5200万户&#xff0c;在企业总量中占比高达92.3%。如何帮助民营企业实现高质量发…