Git Product home page Git Product logo

tracenature / rediscompare Goto Github PK

View Code? Open in Web Editor NEW
209.0 28.0 12.0 31.5 MB

rediscompare is a tool for chech two redis db data consistency. 是用来对比、校验redis 多个数据库数据一致性的命令行工具,支持单实例到单实例、单实例到原生集群、多实例多库到单实例等场景。

License: MIT License

Go 98.02% Makefile 1.98%
redis data compare ttl report check consistency

rediscompare's Introduction

rediscompare

简体中文

rediscompare is a command line tool used to compare redis database data consistency

showuse

Verification mechanism

rediscompare scans the data in the source database and compares it with the target database through the scan command, and checks it from dimensions such as value length, value, and ttl. Finally, a result file is generated, which contains the key of the data inconsistency and the reason for the inconsistency.

In actual scenarios, some keys may be inconsistent in the first comparison due to transmission delay issues. Rediscompare supports multiple comparisons in a cycle, which is based on the inconsistent keys in the last comparison and generates a result file. The number of cycles can be passed "--comparetimes" "Parameter specification

Scenario

rediscompare provides a comparison plan for the following scenarios according to the different types of targets and sources

  • compare parameters To compare diff of parameters between two redis insance

  • single2single Comparison of redis single instance to single instance. Used to compare the data consistency of a single instance single database

  • single2cluster Used to compare the data consistency between a db in a single instance and the redis native cluster

  • cluster2cluster Used to compare the data consistency between redis native cluster and native cluster

  • multisingle2single Used to compare the data consistency between a collection of multiple databases in multiple single instances and a database in a single instance

  • multisingle2cluster Used to compare the data consistency between multiple databases collections in multiple single instances and a single instance database

quick start

build execute file

git clone https://github.com/TraceNature/rediscompare.git
cd rediscompare
go mod tidy
go mod vendor
go build -o rediscompare

Usage example

rediscompare supports command line mode and interactive mode, interactive mode supports command prompt. The comparison command supports direct command input and yaml customization. Let's introduce the basic usage of each scene according to the scene.

Use the -i parameter to enter the interactive mode "rediscompare -i"

compare subcommand

  • parameters

      rediscompare compare parameters --saddr 10.0.0.1:6379 --spassword "redistest0102" --taddr 10.0.0.2:6379 --tpassword "testredis0102"
  • single2single

    • 命令模式 Command mode

       rediscompare compare single2single  --saddr "10.0.0.1:6379"    --spassword  "redistest0102"  --taddr "10.0.0.2:6379"   --tpassword  "redistest0102" --comparetimes 3
  • single2cluster

    • Command mode

      rediscompare compare single2cluster  --saddr  "10.0.0.1:6379"    --spassword  "redistest0102"  --taddr "10.0.1.1:16379,10.0.1.1:16380,10.0.1.2:16379,10.0.1.2:16380,10.0.1.3:16379,10.0.1.3:16380"   --tpassword  "testredis0102" --comparetimes 3
  • cluster2cluster

    • Command mode

      rediscompare  compare cluster2cluster  --saddr  "10.0.0.1:36379,10.0.0.2:36379,10.0.0.3:36379"    --spassword  "testredis0102"  --taddr "10.0.1.1:16379,10.0.1.1:16380,10.0.1.2:16379,10.0.1.2:16380,10.0.1.3:16379,10.0.1.3:16380"   --tpassword  "testredis0102" --comparetimes 3
  • multisingle2single

    • Execute yaml file

      # multisingle2single yaml file
      saddr:
       - addr: "10.0.0.1:6379"
         password: "redistest0102"
         dbs:
           - 0
           - 2
           - 3
       - addr: "10.0.0.2:6379"
         password: "redistest0102"
         dbs:
           - 1
           - 5
           - 9
      taddr: "10.0.0.3:6379"
      tpassword: "redistest0102"
      batchsize: 30
      threads: 2
      ttldiff: 10000
      comparetimes: 3
      report:  true
      scenario: "multisingle2single"
      rediscompare compare exec  path/miltisingle2single.yml
  • multisingle2cluster

    • Execute yaml file

      # multisingle2cluster yaml file
      saddr:
        - addr: "10.0.0.1:6379"
          password: "redistest0102"
          dbs:
            - 0
            - 2
            - 3
        - addr: "10.0.0.2:6379"
          password: "redistest0102"
          dbs:
            - 1
            - 5
            - 9
      taddr: "10.0.1.1:16379,10.0.1.1:16380,10.0.1.2:16379,10.0.1.2:16380,10.0.1.3:16379,10.0.1.3:16380"
      tpassword: "testredis0102"
      batchsize: 30
      threads: 2
      ttldiff: 10000
      comparetimes: 3
      report:  true
      scenario: "multisingle2cluster"
      rediscompare compare exec  path/miltisingle2cluster.yml

The two scenarios of multisingle2single and multisingle2cluster are difficult to express due to the complex mapping relationship of the databases. Currently, only yaml file execution is supported; single2single, single2cluster, cluster2cluster support command line and yaml file mode.

yaml example

For yaml example files, please refer to the .yml file in the execyamlexample directory

result subcommand

The result subcommand is used to format a .result or .rep file. The file is the comparison result, json plaintext. The result command converts the file into a two-dimensional table to increase readability

rediscompare result parse compare_xxxxxxxx.rep

rediscompare's People

Contributors

jiashiwen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.