Cassandra repair 工具使用

简介: 前言 Cassandra是一款去中心化的分布式数据库。一份数据会分布在多个对等的节点上,即有多个副本。我们需要定期的对多个副本检查,看是否有不一致的情况。比如因为磁盘损坏,可能会导致副本丢失,这样同一份数据的多个副本就会出现不一致。

前言

Cassandra是一款去中心化的分布式数据库。一份数据会分布在多个对等的节点上,即有多个副本。我们需要定期的对多个副本检查,看是否有不一致的情况。比如因为磁盘损坏,可能会导致副本丢失,这样同一份数据的多个副本就会出现不一致。

nodetool repair

Cassandra提供的nodetool中提供了repair这个工具,可以用来日常巡检数据的一致性。或者当修修改了keysapce 副本配置时,也需要运行此工具。

可以通过nodetool help 'repair'查看命令帮助,如下:

NAME
        nodetool repair - Repair one or more tables

SYNOPSIS
        nodetool [(-h <host> | --host <host>)] [(-p <port> | --port <port>)]
                [(-pw <password> | --password <password>)]
                [(-pwf <passwordFilePath> | --password-file <passwordFilePath>)]
                [(-u <username> | --username <username>)] repair
                [(-dc <specific_dc> | --in-dc <specific_dc>)...]
                [(-dcpar | --dc-parallel)] [(-et <end_token> | --end-token <end_token>)]
                [(-full | --full)]
                [(-hosts <specific_host> | --in-hosts <specific_host>)...]
                [(-j <job_threads> | --job-threads <job_threads>)]
                [(-local | --in-local-dc)] [(-pl | --pull)]
                [(-pr | --partitioner-range)] [(-seq | --sequential)]
                [(-st <start_token> | --start-token <start_token>)] [(-tr | --trace)]
                [--] [<keyspace> <tables>...]

OPTIONS
        -dc <specific_dc>, --in-dc <specific_dc>
            Use -dc to repair specific datacenters

        -dcpar, --dc-parallel
            Use -dcpar to repair data centers in parallel.

        -et <end_token>, --end-token <end_token>
            Use -et to specify a token at which repair range ends

        -full, --full
            Use -full to issue a full repair.

        -h <host>, --host <host>
            Node hostname or ip address

        -hosts <specific_host>, --in-hosts <specific_host>
            Use -hosts to repair specific hosts

        -j <job_threads>, --job-threads <job_threads>
            Number of threads to run repair jobs. Usually this means number of
            CFs to repair concurrently. WARNING: increasing this puts more load
            on repairing nodes, so be careful. (default: 1, max: 4)

        -local, --in-local-dc
            Use -local to only repair against nodes in the same datacenter

        -p <port>, --port <port>
            Remote jmx agent port number

        -pl, --pull
            Use --pull to perform a one way repair where data is only streamed
            from a remote node to this node.

        -pr, --partitioner-range
            Use -pr to repair only the first range returned by the partitioner

        -pw <password>, --password <password>
            Remote jmx agent password

        -pwf <passwordFilePath>, --password-file <passwordFilePath>
            Path to the JMX password file

        -seq, --sequential
            Use -seq to carry out a sequential repair

        -st <start_token>, --start-token <start_token>
            Use -st to specify a token at which the repair range starts

        -tr, --trace
            Use -tr to trace the repair. Traces are logged to
            system_traces.events.

        -u <username>, --username <username>
            Remote jmx agent username

        --
            This option can be used to separate command-line options from the
            list of argument, (useful when arguments might be mistaken for
            command-line options

        [<keyspace> <tables>...]
            The keyspace followed by one or many tables

主要用法说明

nodetool repair mykeyspace mytable 检查并修复特定表

常用参数:
-j <job_threads>, --job-threads <job_threads>
后台并行运行的RepairSession个数,一个RepairSession对应一组节点以及节点共同维护的分区。这个谨慎调整,会增加集群负载。

-full, --full
全量检查并修复,2.2之后的版本引入增量修复功能(increment repair),默认都是走增量。增量修复会把已经repair过的数据从sstable里分离出来,分成2个sstable,一个是检修过的,一个是包含未检修数据(这个过程叫AntiCompaction)。这样下次运行repair只会检查没有修复过的那个sstable,减少磁盘带宽和建立MerkleTree开销,避免影响在线服务(repair过程是会读取数据并建立MerkleTree,然后在某一节点上对比不同节点上各自维护的副本的MerkleTree)。

-st <start_token>, --start-token <start_token>
-et <end_token>, --end-token <end_token>
自定义token范围,也就是分区(range)范围。比如(100,1000] 表示只检查一致性hash环上从100到1000这个区间段内分区段数据。默认无需指定,会检修运行repair命令的当前节点上所有token。指定了这个参数,相当于做一个subrange repair,会跳过AntiCompaction。一如果想避免AntiCompaction的影响,可以自己计算好token范围,自己做多个subrange repair。

-pr, --partitioner-range
只检修主要的range。主要range是什么?比如一行数据被hash到某个range,也就是对应了某个token(此token假设由节点A负责)。然后因为keyspace是多副本的,会根据keyspace配置的ReplicationStrategy,再选出多个token负责(这些token是不同节点维护的)存放副本。那么这个range对于节点A而言就是主要range。

此参数不做subrange repair才有效

-dc <specific_dc>, --in-dc <specific_dc>
检修只会涉及到指定dc中的节点

-hosts <specific_host>, --in-hosts <specific_host>
检修只会涉及到指定主机列表中的节点

写在最后

为了营造一个开放的Cassandra技术交流环境,社区建立了微信公众号和钉钉群。为广大用户提供专业的技术分享及问答,定期开展专家技术直播,欢迎大家加入。另云Cassandra免费火爆公测中,欢迎试用:https://www.aliyun.com/product/cds

cassandra_QR_code

相关文章
|
NoSQL 前端开发
cassandra nodetool常用命令介绍
简介 nodetool是cassandra自带的外围工具,通过JMX可以动态修改当前进程内存数据,注意cassandra是无主对等架构,默认的命令是操作本机当前进程,例如repair,如果需要做全集群修复,需要在每台机器上执行对应的nodetool命令。
4670 0
|
算法 Python
Pycharm里面的一些超级好用的功能——(TODO注释)用法防遗忘大法
Pycharm里面的一些超级好用的功能——(TODO注释)用法防遗忘大法
Pycharm里面的一些超级好用的功能——(TODO注释)用法防遗忘大法
|
存储 IDE 程序员
揭秘 IPython 的 5 种最佳调试方法
一个好的集成开发环境(IDE)附带的调试器是开发人员能够拥有的最强大的工具之一,但并不是每个人都在使用一个带有很棒代码调试器的集成发环境(IDE)。
|
7月前
|
存储 人工智能 弹性计算
揭秘千问 APP 千万级 AI 订单背后的记忆存储实践
2026年春节,千问 APP “春节请客计划” 9 小时破 1000 万单,依赖 Tablestore 构建的一站式记忆系统:支持短期/长期记忆统一管理、毫秒级读写、Serverless 弹性伸缩、多模态数据融合及原生向量检索,实现数十亿条记忆的高效存储与实时流转。
1904 119
|
7月前
|
人工智能 Java API
【SpringAIAlibaba新手村系列】(13)Tool Calling 函数工具调用技术
本文详细解析 Spring AI 的 Tool Calling 技术,阐明其如何弥补大模型“会说不会做”的局限。通过 @Tool 注解,开发者可轻松将 Java 方法暴露为 AI 工具。文中深入讲解了 ToolCallbacks.from() 注册工具的原理,以及工具方法在当前 Spring Boot 进程内通过反射动态执行的底层逻辑,强调了模型决策与框架执行的协同过程,为理解 AI 赋能实际操作奠定基础。
1750 0
|
XML 存储 前端开发
免费在线图片转Base64编码工具
利用图片转 Base64 编码工具(支持 PNG, GIF, JPEG 等格式)。操作极其简单:将目标图片拖拽至工具指定区域,即可自动完成转换并获得编码结果。
3991 3
|
11月前
|
网络协议 安全 应用服务中间件
Debian 11.1 安装Nginx 并开启HTTP3 详细教程
本文介绍如何在Linux系统中从源码编译安装支持HTTP/3的Nginx 1.25.5。涵盖系统更新、依赖安装、源码下载、配置编译参数(含HTTP/3模块)、安装及验证全过程,并提供启用HTTP/2与HTTP/3共存的nginx.conf配置示例,确保兼容性。最后提醒开放云服务器安全组的TCP/UDP 443端口以支持QUIC协议。
537 10
|
人工智能 自然语言处理 Java
从青铜到王者,DeepSeek+Spring AI 搭建 RAG 知识库
本文介绍了基于RAG(检索增强生成)技术构建知识库的原理与实现方法。RAG通过结合检索与生成模型,提升大语言模型在问答任务中的准确性与相关性,有效缓解“幻觉”问题。文章还详细讲解了如何利用DeepSeek与SpringAI搭建高效RAG系统,并提供了完整的Java代码示例,帮助开发者快速实现文档处理、向量存储与智能问答功能。适用于智能客服、内容生成、辅助决策等多个场景。
2792 2
|
Shell 开发工具 git
解决git bash报错:在仓库中检测到可疑的所有权
总的来说,解决“在仓库中检测到可疑的所有权”的报错,关键在于理解和调整文件或目录的所有权。只要我们正确地设置了文件或目录的所有权,那么我们就可以避免这种问题,让Git Bash正常工作。
959 22
|
存储 人工智能 Java
【图文详解】基于Spring AI的旅游大师应用开发、多轮对话、文件持久化、拦截器实现
【图文详解】基于Spring AI的旅游大师应用开发、多轮对话、文件持久化、拦截器实现

热门文章

最新文章