ClickHouse Keeper: Coordination without the drawbacks没有缺点的分布式协作系统

ClickHouse Keeper 介绍

现代分布式系统需要一个共享和可靠的信息存储库和共识系统来协调和同步分布式操作。对于ClickHouse来说,ZooKeeper最初是被选中的。它的广泛使用是可靠的,提供了简单而强大的API,并提供了合理的性能。

然而,不仅仅是性能,资源效率和可扩展性一直是ClickHouse的首要考虑因素。ZooKeeper作为一个Java生态系统项目,并不能很好地适应我们主要的c++代码库,当ClickHouse在越来越大的规模上使用它时,ClickHouse开始遇到资源使用和运营方面的挑战。为了克服ZooKeeper的这些缺点,ClickHouse团队从零开始构建ClickHouse Keeper,考虑到ClickHouse项目需要解决的额外需求和目标。

ClickHouse Keeper是什么?

没有缺点的分布式协作系统,在ClickHouse集群中,可以直接替换zookeeper
Open-source coordination that scales
ClickHouse Keeper solves the well-known drawbacks of ZooKeeper and makes many additional improvements.
详见官网介绍

从官网给出的性能测试看,Keeper在内存利用率方面完胜zookeeper
在这里插入图片描述

ClickHouse Keeper的优点

为了克服ZooKeeper的一些缺点,ClickHouse开始根据自己的需求从头开始构建ClickHouse原生Keeper,并针对ClickHouse的使用进行了优化。

  • Easier setup and operation
  • No overflow issues
  • Better compression
  • Faster recovery
  • Less memory used
  • Additional guarantees

是否可直接替换zookeeper

Keeper是用c++编写的ZooKeeper的替代品,具有完全兼容的客户端协议和相同的数据模型,并具有这些改进

  • Compatible client protocol (all clients work out of the box)
  • The same state machine (data model)
  • Better guarantees (optionally allows linearizable reads)
  • Uses Raft algorithm (NuRaft implementation)
  • Optional TLS for clients and internal communication

什么场景下适合替换?

在这里插入图片描述

与zookeeper协同算法的主要区别?

  • ZooKeeper是用Java实现的,它的协调算法:ZooKeeper Atomic Broadcast (ZAB),不提供读的线性性保证。
  • 与ZooKeeper不同,ClickHouse Keeper是用c++编写的,并使用RAFT算法实现。该算法允许读写的线性化,并且有几种不同语言的开源实现。
    详细比较参见:ClickHouse Keeper: A ZooKeeper alternative written in C++

如何安装部署

详见clickhouse-keeper

主要配置文件

  • clickhouse-keeper.xml

    <keeper_server>
        <tcp_port>2181</tcp_port>
        <server_id>1</server_id>
        <log_storage_path>/var/lib/clickhouse/coordination/log</log_storage_path>
        <snapshot_storage_path>/var/lib/clickhouse/coordination/snapshots</snapshot_storage_path>
    
        <coordination_settings>
            <operation_timeout_ms>10000</operation_timeout_ms>
            <session_timeout_ms>30000</session_timeout_ms>
            <raft_logs_level>trace</raft_logs_level>
        </coordination_settings>
    
        <raft_configuration>
            <server>
                <id>1</id>
                <hostname>zoo1</hostname>
                <port>9234</port>
            </server>
            <server>
                <id>2</id>
                <hostname>zoo2</hostname>
                <port>9234</port>
            </server>
            <server>
                <id>3</id>
                <hostname>zoo3</hostname>
                <port>9234</port>
            </server>
        </raft_configuration>
    </keeper_server>
    
  • 在clickhouse集群的配置文件metrika.xml文件中增加如下配置:

        <zookeeper-servers>
            <node>
                <host>chnode1.domain.com</host>
                <port>9181</port>
            </node>
            <node>
                <host>chnode2.domain.com</host>
                <port>9181</port>
            </node>
            <node>
                <host>chnode3.domain.com</host>
                <port>9181</port>
            </node>
        </zookeeper-servers>
    

Four Letter Word Commands

ClickHouse Keeper还提供4字命令,这与Zookeeper几乎相同。每个命令由四个字母组成,如mntr、stat等。还有一些更有趣的命令:stat提供一些关于服务器和连接的客户端的一般信息,而srvr和cons分别提供关于服务器和连接的详细信息。

4lw命令有一个白名单配置,默认值为conf、cons、crst、envi、ruok、srst、srvr、stat、wchs、dirs、mntr、isro、rcvr、apiv、csnp、lif、rqld、ydld。

echo mntr | nc localhost 2181

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

enjoy编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值