Cassandra repair 工具使用

本文涉及的产品
云数据库 MongoDB,独享型 2核8GB
推荐场景:
构建全方位客户视图
云原生多模数据库 Lindorm,多引擎 多规格 0-4节点
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介: 前言 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

相关文章
|
10月前
|
分布式计算 API 流计算
22MyCat - Spark/Storm 对join扩展(简略)
22MyCat - Spark/Storm 对join扩展(简略)
41 0
|
3月前
|
SQL 存储 固态存储
presto、impala、kudu相关优化整理
presto、impala、kudu相关优化整理
|
存储 NoSQL 算法
【Redis基础】Redis新数据类型(Bitmaps,HyperLoglog,Geospatial)命令简介与案例演示
【Redis基础】Redis新数据类型(Bitmaps,HyperLoglog,Geospatial)命令简介与案例演示
|
SQL HIVE 索引
Hive和Impala中substring用法差异
Hive和Impala中substring用法差异
215 0
|
分布式计算 资源调度 Kubernetes
Spark 集群搭建_Spark 集群结构_扩展|学习笔记
快速学习 Spark 集群搭建_Spark 集群结构_扩展
140 0
Spark 集群搭建_Spark 集群结构_扩展|学习笔记
|
固态存储 关系型数据库 MySQL
Apache Doris 动态分区介绍及使用方法
在某些使用场景下,用户会将表按照天进行分区划分,每天定时执行例行任务,这时需要使用方手动管理分区,否则可能由于使用方没有创建分区导致数据导入失败,这给使用方带来了额外的维护成本。
2933 0
Apache Doris 动态分区介绍及使用方法
|
SQL 分布式计算 关系型数据库
Apache doris Datax DorisWriter扩展使用方法
ataX 是阿里云 DataWorks数据集成 的开源版本,在阿里巴巴集团内被广泛使用的离线数据同步工具/平台。DataX 实现了包括 MySQL、Oracle、SqlServer、Postgre、HDFS、Hive、ADS、HBase、TableStore(OTS)、MaxCompute(ODPS)、Hologres、DRDS 等各种异构数据源之间高效的数据同步功能。
768 0
Apache doris Datax DorisWriter扩展使用方法
|
SQL 分布式计算 并行计算
PostgreSQL 并行计算解说 之22 - parallel append
标签 PostgreSQL , cpu 并行 , smp 并行 , 并行计算 , gpu 并行 , 并行过程支持 背景 PostgreSQL 11 优化器已经支持了非常多场合的并行。简单估计,已支持27余种场景的并行计算。 parallel seq scan
401 0
|
SQL 测试技术 HIVE
0039-如何使用Python Impyla客户端连接Hive和Impala
温馨提示:要看高清无码套图,请使用手机打开并单击图片放大查看。 1.文档编写目的 继上一章讲述如何在CDH集群安装Anaconda&搭建Python私有源后,本章节主要讲述如何使用Pyton Impyla客户端连接CDH集群的HiveServer2和Impala Daemon,并进行SQL操作。
3490 0
|
SQL 安全 分布式数据库
配置安全的Impala集群集成Sentry
本文主要记录配置安全的Impala集群集成Sentry的过程。Impala集群上配置了Kerberos认证,并且需要提前配置好Hive与Kerberos和Sentry的集成: 使用yum安装CDH Hadoop集群 Hive配置kerberos认证 Impala配置kerberos认证 配置
5547 1