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

一、安装环境

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 protocolPROXYv1 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 errorsnearest_hostname - from set of replicas with minimum number of errors, choose replicawith 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 requestswhose 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.02a02: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.mzph.cn/news/219579.shtml

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

相关文章

C语言 联合体验证 主机字节序 +枚举

联合体应用&#xff1a;验证当前主机的大小端&#xff08;字节序&#xff09; //验证当前主机的大小端 #include <stdio.h>union MyData {unsigned int data;struct{unsigned char byte0;unsigned char byte1;unsigned char byte2;unsigned char byte3;}byte; };int main…

详细说说vuex

Vuex 是什么 Vuex有几个属性及作用注意事项vuex 使用举例Vuex3和Vuex4有哪些区别 创建 Store 的方式在组件中使用 Store辅助函数的用法响应式的改进Vuex4 支持多例模式 Vuex 是什么 Vuex是一个专门为Vue.js应用设计的状态管理构架&#xff0c;它统一管理和维护各个Vue组件的可…

【深度学习】Pytorch 系列教程(一):PyTorch数据结构:1、Tensor(张量)及其维度(Dimensions)、数据类型(Data Types)

文章目录 一、前言二、实验环境三、PyTorch数据结构0、分类1、Tensor&#xff08;张量&#xff09;1. 维度&#xff08;Dimensions&#xff09;0维&#xff08;标量&#xff09;1维&#xff08;向量&#xff09;2维&#xff08;矩阵&#xff09;3维张量 2. 数据类型&#xff08…

报告称超 5 成职场人员有兼职 ,有人因做副业被降薪或被辞,有哪些信息值得关注?你有下班兼职的打算吗?

在职程序员分享身边几个做兼职的案例&#xff1a; 前领导从21年开始做小红书账号&#xff0c;粉丝30w&#xff0c;月入5w左右&#xff1b; 隔壁工位的哥们每隔几个月都会在平台接点小单&#xff0c;今年赚了小几万&#xff1b; 室友每天开车上班顺便接顺风车单子&#xff0c;一…

推荐一款好用的包含表格识别的OCR网站

在当今数字化的时代&#xff0c;文字和表格识别已经成为了许多行业的关键技术。无论是处理大量的纸质文档&#xff0c;还是从网络上收集数据&#xff0c;OCR&#xff08;光学字符识别&#xff09;技术都扮演着重要的角色。然而&#xff0c;对于许多用户来说&#xff0c;OCR软件…

螺旋矩阵算法(leetcode第885题)

题目描述&#xff1a; 在 rows x cols 的网格上&#xff0c;你从单元格 (rStart, cStart) 面朝东面开始。网格的西北角位于第一行第一列&#xff0c;网格的东南角位于最后一行最后一列。你需要以顺时针按螺旋状行走&#xff0c;访问此网格中的每个位置。每当移动到网格的边界之…

GradNorm理解

主要参考这一篇&#xff0c;GradNorm&#xff1a;Gradient Normalization for Adaptive Loss Balancing in Deep Multitask Networks&#xff0c;梯度归一化_grad norm-CSDN博客 14:20-15:30 提前需要理解的概念 损失函数&#xff0c;衡量ypred与ytruth的差距。 Grad Loss定…

盲盒小程序如何盈利?创业新模式

当前&#xff0c;盲盒的影响力越来越大&#xff0c;深受年轻人的热爱&#xff0c;受众群体逐渐增加&#xff0c;盲盒的市场规模不断扩大。 在当下社交媒体时代&#xff0c;盲盒也转到了互联网上&#xff0c;根据网络的传播&#xff0c;盲盒也迎来了新一轮的发展&#xff0c;“…

在服务器上配置jupyter notebook便于本地访问

文章目录 需求配置1. 安装jupyter2. 生成配置文件3. 设置登录密码并生成秘钥a. 打开服务器的终端b. 设置密码 4. 修改配置文件a. 进入配置文件所在的文件夹b. 编辑配置文件jupyter_notebook_config.pyc. 保存文件 5. 在服务器上生成jupyter访问地址 关注公众号&#xff1a;『 …

C# WinForm 跨线程访问控件

写在前面 在WinForm开发中&#xff0c;经常会碰到主线程代码运行过程中需要刷新窗体控件的情况&#xff0c;如果直接在其他线程中去操作窗体控件&#xff0c;这时会抛出线程间操作无效的异常信息&#xff0c;因为窗体控件是由主线程创建的&#xff0c;C#强制要求代码必须是线程…

SAP 标准GUI 中增加按钮时报错:EC181

今天在打一个note的时候&#xff0c;需要做一些手动的调整&#xff0c;其中的步骤就需要我去在标准的GUI STATUS 增加按钮 我在进入编辑模式的时候&#xff0c;直接去插入的时候&#xff0c;始终报错如下&#xff1a; Function code xxxx has not been assigned to a functio…

使用matlab制作声音采样率转换、播放以及显示的界面

利用matlab做一个声音采样率转换、播放以及显示的界面 大抵流程&#xff1a; 图形界面创建&#xff1a;使用figure函数创建名为“声音采样率转换”的图形界面&#xff0c;并设置了其位置和大小。 按钮和文本框&#xff1a;使用uicontrol函数创建了选择音频文件的按钮、显示当前…

js基础之事件监听案例入门

事件绑定 代码 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>Document</title> </head&…

【IDEA】关于快捷键行注释时会从行首开始注释

前言 每次在使用IDEA写代码时&#xff0c;用快捷键进行行注释的时候&#xff0c;//会处于行首位置 但是我们想要的是这种注释效果 修改 IDEA中打开settings 找到Editor - Code Style- Java - 找到Code Genneration&#xff0c;取消勾选Line comment at first column&#x…

汽车内饰设计开发流程(入门基础)

1 开发流程简介 2 汽车内饰的子系统&#xff08;分类&#xff09; 1 软内饰&#xff08;顶棚、地毯、座椅&#xff09; 2 硬内饰&#xff08;仪表板、副仪表板护、A柱饰板、B柱饰板、C柱饰板、门槛、侧围饰板、背门饰板&#xff09; 3内外饰板的分类&#xff1a;功能件和装饰…

Linux的重定向

Linux中的重定向是将程序的输入流或输出流从默认的位置改变到指定的位置。可以使用特殊的符号来实现重定向操作。&#xff08;文中command代表命令&#xff09; &#xff08;1&#xff09;重定向命令列表 命令 说明 command > file …

第16章 网络io与io多路复用select/pool/epool

第16.1节 写一个服务端代码 服务端代码 #include <stdio.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h>#include <fcntl.h>int main() {//openint sockfd sock…

考试的最大困扰度

说在前面 &#x1f388;不知道大家对于算法的学习是一个怎样的心态呢&#xff1f;为了面试还是因为兴趣&#xff1f;不管是出于什么原因&#xff0c;算法学习需要持续保持。 1、题目描述 一位老师正在出一场由 n 道判断题构成的考试&#xff0c;每道题的答案为 true &#xff…

Hexo部署到云服务器后CSS样式无效的问题

Hexo部署到云服务器后CSS样式无效的问题 01 前言 趁活动入手了一个云服务器&#xff08;Linux&#xff09;&#xff0c;打算简单挂个博客上去&#xff0c;因为之前部署到github有了一些经验&#xff0c;所以还是选择使用Hexo。中间步骤略&#xff0c;部署完使用浏览器访问的时…

HT4125 低压CMOS 缓冲门器件 单电源电压转换

​​亿胜盈科HT4125 是一款低压CMOS 缓冲门器件&#xff0c;可运行在针对便携式和电池设备的更宽电压范围内。 其采用了较低阀值电路来设计此输入&#xff0c;以便匹配Vcc 3.3V 时的1.8V 输入逻辑&#xff0c;并且可被用 在1.8V 至3.3V 电平上行转换器功能中。此外&#xff0c;…