CentOS7 部署安装ClickHouse

一、什么是ClickHouse

ClickHouse 是俄罗斯的Yandex于2016年开源的列式存储数据库(DBMS),使用C++语言编写,主要用于在线分析处理查询(OLAP),能够使用SQL查询实时生成分析数据报告。

OLAP场景需要在大型数据集上对具有以下特征的复杂分析查询进行实时响应:

  • 数据集可以是巨大的——数十亿或数万亿行
  • 数据组织在包含多列的表中
  • 只选择少数几列来回答任何特定的查询
  • 必须以毫秒或秒为单位返回结果

 ClickHouse官网:Fast Open-Source OLAP DBMS - ClickHouse

二、单机部署安装

建议使用官方预编译的rpm软件包,适用于CentOS、RedHat和所有其他基于rpm的Linux发行版。

设置RPM存储库

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

安装ClickHouse服务器和客户端

yum install -y clickhouse-server clickhouse-client

启动ClickHouse服务器

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

修改配置文件

vim /etc/clickhouse-server/config.xml

把 <listen_host>::</listen_host> 的注释打开,这样的话才能让ClickHouse被除本机以外的服务器访问

在这个文件中,有ClickHouse的一些默认路径配置,比较重要的
数据文件路径:<path>/var/lib/clickhouse/</path>
日志文件路径:<log>/var/log/clickhouse-server/clickhouse-server.log</log>

启动Server

systemctl start clickhouse-server

使用client连接server

clickhouse-client -m

-m :可以在命令窗口输入多行命令

 安装完配置文件路径 /etc/clickhouse-*

 三、RPM包安装

rpm安装包地址:https://packages.clickhouse.com/rpm/

Packages
  • clickhouse-common-static:安装clickhouse编译的二进制文件
  • clickhouse-server:为clickhouse服务器创建一个软链接,并安装默认的服务器配置
  • clickhouse-client:为clickhouse客户端和其他与客户端相关的工具创建软链接。并安装客户端配置文件
  • clickhouse-common-static-dbg:安装ClickHouse编译的带有调试信息的二进制文件
  • clickhouse-keeper:用于在专用的ClickHouse Keeper节点上安装ClickHouse Keeper。如果您在与ClickHouse服务器相同的服务器上运行ClickHouse Keeper,则无需安装此软件包。安装ClickHouse Keeper和默认的ClickHouse Keeler配置文件

 安装包下载到自己制定路径

clickhouse-client-24.5.3.5.x86_64.rpm
clickhouse-common-static-24.5.3.5.x86_64.rpm
clickhouse-server-24.5.3.5.x86_64.rpm

 安装rpm

rpm -ivh clickhouse-*

 四、ClickHouse Keeper

ClickHouse 集群是需要使用Zookeeper去实现集群副本之间的同步,而ClickHouse Keeper基于Raft一致性算法开发的一款专门为ClickHouse设计的分布式一致性解决方案,旨在替代ZooKeeper作为ClickHouse集群的元数据存储与管理工具。

官方翻译:在生产环境中,我们强烈建议在专用节点上运行ClickHouse Keeper。在测试环境中,如果您决定在同一台服务器上运行ClickHouse Server和ClickHouse Keeper,则无需安装ClickHouse Keepper,因为它包含在ClickHouse服务器中。此命令仅在独立的ClickHouse Keeper服务器上需要。

单独安装ClickHouse Keeper

yum install -y clickhouse-keeper

启用并启动ClickHouse Keeper

systemctl enable clickhouse-keeper
systemctl start clickhouse-keeper
systemctl status clickhouse-keeper

ClickHouse-Keeper方式搭建CK集群

ClickHouse-Keeper嵌入式

嵌入式模式代表不需要额外部署和启动服务,在ClickHouse中配置启用,启动ClickHouse就可以启动嵌入式Keeper

修改 /etc/clickhouse-server/config.xml

将 /etc/clickhouse-keeper/keeper_config.xml 配置文件里的 <keeper_server>******</keeper_server> 加入clickhouse-serverconfig.xml里即可

<clickhouse>

# 省略其他...

...
    <keeper_server>
            <tcp_port>9181</tcp_port>

            <!-- Must be unique among all keeper serves -->
            <server_id>1</server_id>

            <log_storage_path>/var/lib/clickhouse/coordination/logs</log_storage_path>
            <snapshot_storage_path>/var/lib/clickhouse/coordination/snapshots</snapshot_storage_path>

            <coordination_settings>
                <operation_timeout_ms>10000</operation_timeout_ms>
                <min_session_timeout_ms>10000</min_session_timeout_ms>
                <session_timeout_ms>100000</session_timeout_ms>
                <raft_logs_level>information</raft_logs_level>
                <compress_logs>false</compress_logs>
                <!-- All settings listed in https://github.com/ClickHouse/ClickHouse/blob/master/src/Coordination/CoordinationSettings.h -->
            </coordination_settings>

            <!-- enable sanity hostname checks for cluster configuration (e.g. if localhost is used with remote endpoints) -->
            <hostname_checks_enabled>true</hostname_checks_enabled>
            <raft_configuration>
                <server>
                    <id>1</id>
                    <!-- Internal port and hostname -->
                    <hostname>example1</hostname>
                    <port>9234</port>
                </server>
                <server>
                    <id>2</id>
                    <!-- Internal port and hostname -->
                    <hostname>example2</hostname>
                    <port>9234</port>
                </server>
                <server>
                    <id>3</id>
                    <!-- Internal port and hostname -->
                    <hostname>example3</hostname>
                    <port>9234</port>
                </server>

                <!-- Add more servers here -->

            </raft_configuration>
    </keeper_server>
...
   <zookeeper>
        <node>
            <host>example1</host>
            <port>2181</port>
        </node>
        <node>
            <host>example2</host>
            <port>2181</port>
        </node>
        <node>
            <host>example3</host>
            <port>2181</port>
        </node>
     </zookeeper>
</clickhouse>

启动直接是采用 clickhouse 的启动方式,systemctl start clickhouse-server(启动 clickhouse-server 新旧版有几种方式均可)

此外同样的部署多个服务节点,需调整 <zookeeper> 和 <server> 下的地址配置,设置合理的分片和副本

  • 15
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这段代码是用 JavaScript 编写的,主要实现了创建一个用于观看视频的按钮并判断是否有未处理的普通链接。下面是每行代码的解释: 1. `function createWatchButton(url, isForPlain = false) {` 定义一个名为 `createWatchButton` 的函数,它接受两个参数 `url` 和 `isForPlain`,其中 `isForPlain` 的默认值为 `false`。 2. `let button = document.createElement("button");` 创建一个名为 `button` 的变量,它是一个 HTML 按钮元素。 3. `button.setAttribute('data-wtmzjk-mag-url', url);` 为按钮设置一个名为 `data-wtmzjk-mag-url` 的自定义数据属性,它的值为 `url` 参数。 4. `if (isForPlain) button.setAttribute('data-wtmzjk-button-for-plain', '');` 如果 `isForPlain` 参数为 `true`,则为按钮设置一个名为 `data-wtmzjk-button-for-plain` 的自定义数据属性,它的值为空字符串。 5. `button.innerHTML = <span>${T.play}</span><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Pro 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path d="M73 39c-14.8-9.1-33.4-9.4-48.5-.9S0 62.6 0 80V432c0 17.4 9.4 33.4 24.5 41.9s33.7 8.1 48.5-.9L361 297c14.3-8.7 23-24.2 23-41s-8.7-32.2-23-41L73 39z"/></svg>;` 设置按钮的 HTML 内容,它包含一个 `<span>` 元素和一个 SVG 图标。 6. `return button;` 返回创建的按钮元素。 7. `function hasPlainMagUrlThatNotHandled() {` 定义一个名为 `hasPlainMagUrlThatNotHandled` 的函数,它没有参数。 8. `let m = document.body.textContent.match(new RegExp(reg, 'g'));` 创建一个名为 `m` 的变量,它是一个正则表达式匹配结果的数组。这里使用了一个未定义的 `reg` 变量,所以这行代码存在错误。 9. `return document.querySelectorAll([data-wtmzjk-button-for-plain]).length != (m ? m.length : 0);` 返回一个布尔值,表示是否存在未处理的普通链接。它通过查询包含自定义数据属性 `data-wtmzjk-button-for-plain` 的元素数量和匹配结果数组的长度来进行比较。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值