ClickHouse安装(单机版)

本文介绍了在CentOS系统中如何使用yum安装ClickHouse服务器和客户端,包括添加官方仓库、启动服务以及修改配置以允许远程访问。此外,还详细讲解了设置SHA256加密密码的方法,并提供了客户端验证的步骤。
摘要由CSDN通过智能技术生成

官方说明文档

yum install -y yum-utils
yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo
yum install -y clickhouse-server clickhouse-client
clickhouse-server start

至此安装成功。

# 查看启动状态
clickhouse-server status
# 启动
clickhouse-server start
# 停止
clickhouse-server stop
# 重启
clickhouse-server restart

相关配置修改如下:
1、由于默认只能本地访问,所有需要修改配置,将config.xml中的 **<listen_host>::</listen_host>**注释去掉

vim /etc/clickhouse-server/config.xml
# 如果支持IPV6
<listen_host>::</listen_host>
# 如果支持IPV4
<listen_host>0.0.0.0</listen_host>
# 默认数据文件路径:<path>/var/lib/clickhouse/</path>
# 默认日志文件路径:<log>/usr/logs/clickhouse-server/clickhouse-server.log</log>

在这里插入图片描述
2、设置密码,这里使用sha256加密密文进行配置,以下命令可以获得明文密码的密文。

echo -n 明文密码 | openssl dgst -sha256

在这里插入图片描述
修改users.xml中的配置。

vim /etc/clickhouse-server/users.xml
# 添加如下配置,注意替换自己的密文
<password_sha256_hex>4092f076859881b4939b61b968e234f8474c0f09347770829de2ba6b98a140ba</password_sha256_hex>

在这里插入图片描述
注:关于密码配置users.xml文件中给了详细的说明

<users>
        <!-- If user name was not specified, 'default' user is used. -->
        <default>
            <!-- 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>

                 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>123456</password>
      </default>
</users>

配置完成之后重启clickhouse即可!

3、客户端验证

 clickhouse-client --password ******

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是ClickHouse单机版安装部署的步骤: 1. 环境准备 确保你的操作系统是64位的,并且至少有1GB的可用内存。如果你的系统是32位的,则需要安装ClickHouse的低版本。此外,你还需要安装以下软件包: - curl - gnupg - lsof - sudo 2. 添加ClickHouse软件包 运行以下命令添加ClickHouse软件包: ```shell sudo yum install -y yum-utils sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64 sudo yum install -y clickhouse-server clickhouse-client ``` 3. 启动ClickHouse服务 运行以下命令启动ClickHouse服务: ```shell sudo systemctl start clickhouse-server ``` 4. 验证ClickHouse服务 运行以下命令验证ClickHouse服务是否已经启动: ```shell sudo systemctl status clickhouse-server ``` 如果服务已经启动,则会输出类似以下内容: ``` ● clickhouse-server.service - ClickHouse Server Loaded: loaded (/usr/lib/systemd/system/clickhouse-server.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2021-11-02 09:47:23 UTC; 1min 23s ago Main PID: 12345 (clickhouse-serv) Tasks: 47 (limit: 4915) Memory: 1.1G CGroup: /system.slice/clickhouse-server.service ├─12345 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/var/run/clickhouse-server/clickhouse-server.pid └─12346 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/var/run/clickhouse-server/clickhouse-server.pid ``` 5. 连接到ClickHouse客户端 运行以下命令连接到ClickHouse客户端: ```shell clickhouse-client ``` 6. 验证ClickHouse客户端 运行以下命令验证ClickHouse客户端是否已经连接到服务端: ```shell SELECT 1 ``` 如果连接成功,则会输出类似以下内容: ``` ClickHouse client version 21.10.2.9 (official build). Connecting to localhost:9000 as user default. Connected to ClickHouse server version 21.10.2 revision 54429. ClickHouse server version: 21.10.2 revision 54429 1 ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值