Git Product home page Git Product logo

leonchen83 / redis-rdb-cli Goto Github PK

View Code? Open in Web Editor NEW
394.0 25.0 81.0 7.9 MB

Redis rdb CLI : A CLI tool that can parse, filter, split, merge rdb and analyze memory usage offline. It can also sync 2 redis data and allow user define their own sink service to migrate redis data to somewhere.

License: Apache License 2.0

Java 95.91% Shell 2.24% Batchfile 1.74% Dockerfile 0.12%
redis rdb memory cli migrate analyze dashboard

redis-rdb-cli's Introduction

redis-rdb-cli

Buy Me A Coffee

A tool that can parse, filter, split, merge rdb and analyze memory usage offline. It can also sync 2 redis data and allow user define there own sink service to migrate redis data to somewhere.

Java CI Gitter Hex.pm

Chat with author

Join the chat at https://gitter.im/leonchen83/redis-rdb-cli

Contract the author

[email protected]

Binary release

binary releases

Runtime requirement

jdk 1.8+

Install

$ wget https://github.com/leonchen83/redis-rdb-cli/releases/download/${version}/redis-rdb-cli-release.zip
$ unzip redis-rdb-cli-release.zip
$ cd ./redis-rdb-cli/bin
$ ./rct -h

Compile requirement


jdk 1.8+
maven-3.3.1+

Compile & run

$ git clone https://github.com/leonchen83/redis-rdb-cli.git
$ cd redis-rdb-cli
$ mvn clean install -Dmaven.test.skip=true
$ cd target/redis-rdb-cli-release/redis-rdb-cli/bin
$ ./rct -h 

Run in docker

# run with jvm
$ docker run -it --rm redisrdbcli/redis-rdb-cli:latest
$ rct -V

# run without jvm
$ docker run -it --rm redisrdbcli/redis-rdb-cli:latest-native
$ rct -V

Build native image via graalvm in docker

$ docker build -m 8g -f DockerfileNative -t redisrdbcli:redis-rdb-cli .
$ docker run -it redisrdbcli:redis-rdb-cli bash
$ bash-5.1# rct -V

Windows Environment Variables

Add /path/to/redis-rdb-cli/bin to Path environment variable

Usage

Redis mass insertion

$ rct -f dump -s /path/to/dump.rdb -o /path/to/dump.aof -r
$ cat /path/to/dump.aof | /redis/src/redis-cli -p 6379 --pipe

Convert rdb to dump format

$ rct -f dump -s /path/to/dump.rdb -o /path/to/dump.aof

Convert rdb to json format

$ rct -f json -s /path/to/dump.rdb -o /path/to/dump.json

Numbers of key in rdb

$ rct -f count -s /path/to/dump.rdb -o /path/to/dump.csv

Find top 50 largest keys

$ rct -f mem -s /path/to/dump.rdb -o /path/to/dump.mem -l 50

Diff rdb

$ rct -f diff -s /path/to/dump1.rdb -o /path/to/dump1.diff
$ rct -f diff -s /path/to/dump2.rdb -o /path/to/dump2.diff
$ diff /path/to/dump1.diff /path/to/dump2.diff

Convert rdb to RESP

$ rct -f resp -s /path/to/dump.rdb -o /path/to/appendonly.aof

Sync with 2 redis

$ rst -s redis://127.0.0.1:6379 -m redis://127.0.0.1:6380 -r

Sync single redis to redis cluster

$ rst -s redis://127.0.0.1:6379 -m redis://127.0.0.1:30001 -r -d 0

Handle infinite loop in rst command

# set client-output-buffer-limit in source redis
$ redis-cli config set client-output-buffer-limit "slave 0 0 0"
$ rst -s redis://127.0.0.1:6379 -m redis://127.0.0.1:6380 -r

Migrate rdb to remote redis

$ rmt -s /path/to/dump.rdb -m redis://192.168.1.105:6379 -r

Downgrade migration

# Migrate data from redis-7 to redis-6
# About dump_rdb_version please see comment in redis-rdb-cli.conf
$ sed -i 's/dump_rdb_version=-1/dump_rdb_version=9/g' /path/to/redis-rdb-cli/conf/redis-rdb-cli.conf
$ rmt -s redis://com.redis7:6379 -m redis://com.redis6:6379 -r

Handle big key in migration

# set proto-max-bulk-len in target redis
$ redis-cli -h ${host} -p 6380 -a ${pwd} config set proto-max-bulk-len 2048mb

# set Xms Xmx in redis-rdb-cli node
$ export JAVA_TOOL_OPTIONS="-Xms8g -Xmx8g"

# execute migration
$ rmt -s redis://127.0.0.1:6379 -m redis://127.0.0.1:6380 -r

Migrate rdb to remote redis cluster

$ rmt -s /path/to/dump.rdb -c ./nodes-30001.conf -r

or simply use following cmd without nodes-30001.conf

$ rmt -s /path/to/dump.rdb -m redis://127.0.0.1:30001 -r

Backup remote rdb

$ rdt -b redis://192.168.1.105:6379 -o /path/to/dump.rdb

Backup remote rdb and convert db to dest db

$ rdt -b redis://192.168.1.105:6379 -o /path/to/dump.rdb --goal 3

Filter rdb

$ rdt -b /path/to/dump.rdb -o /path/to/filtered-dump.rdb -d 0 -t string

Split rdb via cluster's nodes.conf

$ rdt -s ./dump.rdb -c ./nodes.conf -o /path/to/folder -d 0

Merge multi rdb to one

$ rdt -m ./dump1.rdb ./dump2.rdb -o ./dump.rdb -t hash

Cut aof-use-rdb-preamble file to rdb file and aof file

$ rcut -s ./aof-use-rdb-preamble.aof -r ./dump.rdb -a ./appendonly.aof

Other parameter

More configurable parameter can be modified in /path/to/redis-rdb-cli/conf/redis-rdb-cli.conf

Filter

  1. rct, rdt and rmt these 3 commands support data filter by type,db and key RegEx(Java style).
  2. rst this command only support data filter by db.

For example:

$ rct -f dump -s /path/to/dump.rdb -o /path/to/dump.aof -d 0
$ rct -f dump -s /path/to/dump.rdb -o /path/to/dump.aof -t string hash
$ rmt -s /path/to/dump.rdb -m redis://192.168.1.105:6379 -r -d 0 1 -t list
$ rst -s redis://127.0.0.1:6379 -m redis://127.0.0.1:6380 -d 0

Monitor redis server

# step1 
# open file `/path/to/redis-rdb-cli/conf/redis-rdb-cli.conf`
# change property `metric_gateway from `none` to `influxdb`
#
# step2
$ cd /path/to/redis-rdb-cli/dashboard
$ docker-compose up -d
#
# step3
$ rmonitor -s redis://127.0.0.1:6379 -n standalone
$ rmonitor -s redis://127.0.0.1:30001 -n cluster
$ rmonitor -s redis-sentinel://sntnl-usr:[email protected]:26379?master=mymaster&authUser=usr&authPassword=pwd -n sentinel
#
# step4
# open url `http://localhost:3000/d/monitor/monitor`, login grafana use `admin`, `admin` and check monitor result.

monitor

Difference between rmt and rst

  1. When rmt started. source redis first do BGSAVE and generate a snapshot rdb file. rmt command migrate this snapshot file to target redis. after this process done, rmt terminated.
  2. rst not only migrate snapshot rdb file but also incremental data from source redis. so rst never terminated except type CTRL+C. rst only support db filter more details please refer to Limitation of migration

Dashboard

Since v0.1.9, the rct -f mem support showing result in grafana dashboard like the following:
memory

If you want to turn it on. you MUST install docker and docker-compose first, the installation please refer to docker
Then run the following command:

$ cd /path/to/redis-rdb-cli/dashboard

# start
$ docker-compose up -d

# stop
$ docker-compose down

cd /path/to/redis-rdb-cli/conf/redis-rdb-cli.conf
Then change parameter metric_gateway from none to influxdb.

Open http://localhost:3000 to check the rct -f mem's result.

If you deployed this tool in multi instance, you need to change parameter metric_instance to make sure unique between instances.

Redis 6

Redis 6 SSL

  1. use openssl to generate keystore
$ cd /path/to/redis-6.0-rc1
$ ./utils/gen-test-certs.sh
$ cd tests/tls
$ openssl pkcs12 -export -CAfile ca.crt -in redis.crt -inkey redis.key -out redis.p12
  1. If source redis and target redis use the same keystore. then config following parameters
    source_keystore_path and target_keystore_path to point to /path/to/redis-6.0-rc1/tests/tls/redis.p12
    set source_keystore_pass and target_keystore_pass

  2. after config ssl parameters use rediss://host:port in your command to open ssl, for example: rst -s rediss://127.0.0.1:6379 -m rediss://127.0.0.1:30001 -r -d 0

Redis 6 ACL

  1. use following URI to open redis ACL support
$ rst -s redis://user:[email protected]:6379 -m redis://user:[email protected]:6380 -r -d 0
  1. user MUST have +@all permission to handle commands

Hack rmt

Rmt threading model

The rmt command use the following 4 parameters(redis-rdb-cli.conf) to migrate data to remote.

migrate_batch_size=4096
migrate_threads=4
migrate_flush=yes
migrate_retries=1

The most important parameter is migrate_threads=4. this means we use the following threading model to migrate data.


single redis ----> single redis

+--------------+         +----------+     thread 1      +--------------+
|              |    +----| Endpoint |-------------------|              |
|              |    |    +----------+                   |              |
|              |    |                                   |              |
|              |    |    +----------+     thread 2      |              |
|              |    |----| Endpoint |-------------------|              |
|              |    |    +----------+                   |              |
| Source Redis |----|                                   | Target Redis |
|              |    |    +----------+     thread 3      |              |
|              |    |----| Endpoint |-------------------|              |
|              |    |    +----------+                   |              |
|              |    |                                   |              |
|              |    |    +----------+     thread 4      |              |
|              |    +----| Endpoint |-------------------|              |
+--------------+         +----------+                   +--------------+


single redis ----> redis cluster

+--------------+         +----------+     thread 1      +--------------+
|              |    +----| Endpoints|-------------------|              |
|              |    |    +----------+                   |              |
|              |    |                                   |              |
|              |    |    +----------+     thread 2      |              |
|              |    |----| Endpoints|-------------------|              |
|              |    |    +----------+                   |              |
| Source Redis |----|                                   | Redis cluster|
|              |    |    +----------+     thread 3      |              |
|              |    |----| Endpoints|-------------------|              |
|              |    |    +----------+                   |              |
|              |    |                                   |              |
|              |    |    +----------+     thread 4      |              |
|              |    +----| Endpoints|-------------------|              |
+--------------+         +----------+                   +--------------+

The difference between cluster migration and single migration is Endpoint and Endpoints. In cluster migration the Endpoints contains multi Endpoint to point to every master instance in cluster. For example:

3 masters 3 replicas redis cluster. if migrate_threads=4 then we have 3 * 4 = 12 connections that connected with master instance.

Migration performance

The following 3 parameters affect migration performance

migrate_batch_size=4096
migrate_retries=1
migrate_flush=yes
  1. migrate_batch_size: By default we use redis pipeline to migrate data to remote. the migrate_batch_size is the pipeline batch size. if migrate_batch_size=1 then the pipeline devolved into 1 single command to sent and wait the response from remote.
  2. migrate_retries: The migrate_retries=1 means if socket error occurred. we recreate a new socket and retry to send that failed command to target redis with migrate_retries times.
  3. migrate_flush: The migrate_flush=yes means we write every 1 command to socket. then we invoke SocketOutputStream.flush() immediately. if migrate_flush=no we invoke SocketOutputStream.flush() when write to socket every 64KB. notice that this parameter also affect migrate_retries. the migrate_retries only take effect when migrate_flush=yes.

Migration principle


+---------------+             +-------------------+    restore      +---------------+ 
|               |             | redis dump format |---------------->|               |
|               |             |-------------------|    restore      |               |
|               |   convert   | redis dump format |---------------->|               |
|    Dump rdb   |------------>|-------------------|    restore      |  Targe Redis  |
|               |             | redis dump format |---------------->|               |
|               |             |-------------------|    restore      |               |
|               |             | redis dump format |---------------->|               |
+---------------+             +-------------------+                 +---------------+

Limitation of migration

  1. We use cluster's nodes.conf to migrate data to cluster. because of we didn't handle the MOVED ASK redirection. so limitation of cluster migration is that the cluster MUST in stable state during the migration. this means the cluster MUST have no migrating, importing slot and no switch slave to master.
  2. If use rst migrate data to cluster. the following commands not supported PUBLISH,SWAPDB,MOVE,FLUSHALL,FLUSHDB,MULTI,EXEC,SCRIPT FLUSH,SCRIPT LOAD,EVAL,EVALSHA. and the following commands RPOPLPUSH,SDIFFSTORE,SINTERSTORE,SMOVE,ZINTERSTORE,ZUNIONSTORE,DEL,UNLINK,RENAME,RENAMENX,PFMERGE,PFCOUNT,MSETNX,BRPOPLPUSH,BITOP,MSET,COPY,BLMOVE,LMOVE,ZDIFFSTORE,GEOSEARCHSTORE ONLY SUPPORT WHEN THESE COMMAND KEYS IN THE SAME SLOT(eg: del {user}:1 {user}:2)

Hack ret

What ret command do

  1. ret command that allow user define there own sink service like sink redis data to mysql or mongodb.
  2. ret command using Java SPI extension to do this job.

How to implement a sink service

User should follow the steps below to implement a sink service.

  1. create a java project using maven pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>com.your.company</groupId>
    <artifactId>your-sink-service</artifactId>
    <version>1.0.0</version>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.moilioncircle</groupId>
            <artifactId>redis-rdb-cli-api</artifactId>
            <version>1.8.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.moilioncircle</groupId>
            <artifactId>redis-replicator</artifactId>
            <version>[3.6.4, )</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
            <scope>provided</scope>
        </dependency>
        
        <!-- 
        <dependency>
            other dependencies
        </dependency>
        -->
        
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
  1. implement SinkService interface
public class YourSinkService implements SinkService {

    @Override
    public String sink() {
        return "your-sink-service";
    }

    @Override
    public void init(File config) throws IOException {
        // parse your external sink config
    }

    @Override
    public void onEvent(Replicator replicator, Event event) {
        // your sink business
    }
}
  1. register this service using Java SPI
# create com.moilioncircle.redis.rdb.cli.api.sink.SinkService file in src/main/resources/META-INF/services/

|-src
|____main
| |____resources
| | |____META-INF
| | | |____services
| | | | |____com.moilioncircle.redis.rdb.cli.api.sink.SinkService

# add following content in com.moilioncircle.redis.rdb.cli.api.sink.SinkService

your.package.YourSinkService

  1. package and deploy
$ mvn clean install

$ cp ./target/your-sink-service-1.0.0-jar-with-dependencies.jar /path/to/redis-rdb-cli/lib
  1. run your sink service
$ ret -s redis://127.0.0.1:6379 -c config.conf -n your-sink-service
  1. debug your sink service
    public static void main(String[] args) throws Exception {
        Replicator replicator = new RedisReplicator("redis://127.0.0.1:6379");
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            Replicators.closeQuietly(replicator);
        }));
        replicator.addExceptionListener((rep, tx, e) -> {
            throw new RuntimeException(tx.getMessage(), tx);
        });
        SinkService sink = new YourSinkService();
        sink.init(new File("/path/to/your-sink.conf"));
        replicator.addEventListener(new AsyncEventListener(sink, replicator, 4, Executors.defaultThreadFactory()));
        replicator.open();
    }

How to implement a formatter service

  1. create YourFormatterService extend AbstractFormatterService
public class YourFormatterService extends AbstractFormatterService {

    @Override
    public String format() {
        return "test";
    }

    @Override
    public Event applyString(Replicator replicator, RedisInputStream in, int version, byte[] key, int type, ContextKeyValuePair context) throws IOException {
        byte[] val = new DefaultRdbValueVisitor(replicator).applyString(in, version);
        getEscaper().encode(key, getOutputStream());
        getEscaper().encode(val, getOutputStream());
        getOutputStream().write('\n');
        return context;
    }
}
  1. register this formatter using Java SPI
# create com.moilioncircle.redis.rdb.cli.api.format.FormatterService file in src/main/resources/META-INF/services/

|-src
|____main
| |____resources
| | |____META-INF
| | | |____services
| | | | |____com.moilioncircle.redis.rdb.cli.api.format.FormatterService

# add following content in com.moilioncircle.redis.rdb.cli.api.format.FormatterService

your.package.YourFormatterService

  1. package and deploy
$ mvn clean install

$ cp ./target/your-service-1.0.0-jar-with-dependencies.jar /path/to/redis-rdb-cli/lib
  1. run your formatter service
$ rct -f test -s redis://127.0.0.1:6379 -o ./out.csv -t string -d 0 -e json

Contributors

Consulting

Commercial support for redis-rdb-cli is available. The following services are currently available:

  • Onsite consulting. $10,000 per day
  • Onsite training. $10,000 per day

You may also contact Baoyi Chen directly, mail to [email protected].

Supported by 宁文君

27 January 2023, A sad day that I lost my mother 宁文君, She was encouraging and supporting me in developing this tool. Every time a company uses this tool, she got excited like a child and encouraged me to keep going. Without her I couldn't have maintained this tool for so many years. Even I didn't achieve much but she is still proud of me, R.I.P and hope God bless her.

Supported by IntelliJ IDEA

IntelliJ IDEA is a Java integrated development environment (IDE) for developing computer software.
It is developed by JetBrains (formerly known as IntelliJ), and is available as an Apache 2 Licensed community edition,
and in a proprietary commercial edition. Both can be used for commercial development.

redis-rdb-cli's People

Contributors

air3ijai avatar anishkny avatar cmdshepard avatar dependabot[bot] avatar guyzyl avatar leonchen83 avatar raghu-nandan-bs avatar tao12345666333 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

redis-rdb-cli's Issues

JSONL support?

Ask a question
Any possibility of getting JSONL export support? This is a common format used in big data tooling. JsonRdbVisitor.java could be modified to take a new constructor arg jsonl: Boolean. When enabled, it could be used to omit the wrapping array characters and use newlines instead of commas to separate the entries.

Thanks again for this great tool!

Feature Request: rmt sync from cluster to single redis

Hi,

I am looking for the best way to export a full redis-cluster to a single redis instance.

I know: rmt is able to sync a (given) cluster node to a single redis.
I also know that rmt is able to fetch the list of CLUSTER NODES and get only the masters with their IPs and Ports, because it's presumably what -m does, otherwise it would not work without the cluster.conf

AFAIK, there is no good/short/clean way to get the cluster masters into a bash list.

look how ugly it would be, to sync all keys from all cluster masters into a single redis:

HOSTS=$(redis-cli -a ${REDIS_DEST_PASS} -h ${REDIS_DEST} -p ${REDIS_DEST_PORT} -c cluster nodes | grep master | awk '{ print $2 }' | cut -f1 -d'@')

for HOST in $HOSTS
do
  rmt -s redis://default:${REDIS_DEST_PASS}@${HOST} -m redis://${REDIS_STAGE} -r -d 0
done

This works, but I'm curious if you could

  1. provide a command to output the list of cluster masters in a cleaner approach,
    and possibly,
  2. implement this loop (i mean, the complete sync/migration) with rmt , like this:
rmt -s redis://default:password@AnyClusterMember:Port -m redis://Target-Single-Redis:Port -r

I think, rmt should safely be able to always check if the source is a cluster or not and proceed to work as "expected"
where in case source is a single, proceed as usual.
in case its a cluster, fetch the masters, and loop over them repeating the usual bgsave and dump to target. This should seemlessly work, even if the target is also a cluster

rst's password maybe can't contain #

1. Basic information
1)source db version:3.2
2)dest db version: 5.0
3)redis-rdb-cli version: 0.9.4

redis rdb cli: v0.9.4 (3d5974f848a1b7694327c53d0bd717534cb561ae: 2023-08-16T07:01:27+0000)
home: /usr/local/redis-rdb-cli/bin/..
java version: 17.0.8.1, vendor: Azul Systems, Inc.
java home: /usr/lib/jvm/java-17-zulu-openjdk-jdk
default locale: en, platform encoding: UTF-8
os name: Linux, version: 3.10.0-1160.88.1.el7.x86_64, arch: amd64

2.Problem description
cmd like:
rst -s redis://192.168.7.87:7393?authPassword=*** -m redis://192.168.146.22:7402?authPassword=qaz#wsx -r
When dest db's pasword contain '#',ie qaz#wsx ,rst will output

java.lang.RuntimeException: failed to connect to ***.***.***.***:***, reason ERR invalid password
        at com.moilioncircle.redis.rdb.cli.cmd.XRst.getRdbVisitor(XRst.java:257)
        at com.moilioncircle.redis.rdb.cli.cmd.XRst.call(XRst.java:207)
        at com.moilioncircle.redis.rdb.cli.cmd.XRst.call(XRst.java:149)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at com.moilioncircle.redis.rdb.cli.Rst.main(Rst.java:28)

When i use redis-cli to connect dest db,it‘s’ no problem
redis-cli -h 192.168.146.22 -p 7402 -a qaz#wsx

When I change dest db's(the same instance) pasword to a pasword which do not contain '#',it will be no problem

Missing required option: '--source <source>'

Ask a question
Feel free to ask any question about this tool. no need to fill following table.

Describe the bug
A clear and concise description of what the bug is.
image
image

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Version(run rct --version or rct -V and paste the information):
v0.8.2
Additional context
Add any other context about the problem here.

merge two rdb files with repeated key

dump1.rdblike this:
[{"key":"device","value":{"device1":"IOS"},"db":0,"type":"hash"}]

dump2.rdblike this:
[{"key":"device","value":{"device2":"macOS"},"db":0,"type":"hash"}]

After rdt -m ./dump1.rdb ./dump2.rdb -o ./dump.rdb -t hash I got:

[
{"key":"device","value":{"device1":"IOS"},"db":0,"type":"hash"},
{"key":"device","value":{"device2":"macOS"},"db":0,"type":"hash"}
]

But I want:
[{"key":"device","value":{"device1":"IOS","device2":"macOS"},"db":0,"type":"hash"}]

Can redis-rdb-cli do it?
Thank u very much!

建议size_in_bytes字段以字节单位输出,不格式化,方便脚本分析

问题1:
rct -f mem 命令 输出 的 size_in_bytes字段 单位不是字节,是格式化后的,不方便用脚本分析。
建议添加 选项,可控制输出格式是 字节还是格式化。

问题2:
rct的size_in_bytes 字段和rdb、USAGE testSet等工具 差距较大。

rct的输出
0,set,"testSet","92.4kB",hash,1000,"10 B",""

python rdb 的输出
0,set,testSet,36436,hashtable,1000,8,

Value at:0x7f94aa585eb0 refcount:1 encoding:hashtable serializedlength:5002 lru:16434941 lru_seconds_idle:425

MEMORY USAGE testSet SAMPLES 0
(integer) 44337

Allow for output to stdout?

Ask a question
The -o output file parameter is a required option in rct. It would be useful to allow an option to output to standard out. This would allow the tool to be used in typical unix piping on the command line. For instance, I could then compress the output such as:
rct -f jsonl -s backup.rdb -k 'somekey:.*' | bzip2 > output.jsonl.bz2

And of course this would open up all the unix tools such as head, sort, awk, sed, etc... What do you think?

`rmt -r` does not work in versions prior to Redis 3.0

The RESTORE command add in Redis 2.6, REPLACE option add in Redis 3.0.

If we use rmt -r in versions prior to Redis 3.0, it doesn't work fine.

https://github.com/leonchen83/redis-rdb-cli/blob/master/src/main/java/com/moilioncircle/redis/rdb/cli/ext/rmt/SingleRdbVisitor.java#L95-L99

if (!replace) {  
    endpoint.get().batch(flush, RESTORE, dkv.getKey(), expire, dkv.getValue());  
} else {  
    endpoint.get().batch(flush, RESTORE, dkv.getKey(), expire, dkv.getValue(), REPLACE);  
}  

Should we replace the implementation of Replace with Lua?

Hash values with control characters are not encoded properly in JSON

Describe the bug
If a hash value contains a special character, it is not encoded properly when converting to JSON. Subsequent parsing of the JSON file fails.

To Reproduce
Set a hash value with a special character such as hex 1a (control-z) utf-8.

Export the dump to JSON:
$ ./rct -f json -s backup.rdb -o dump.json

Parse the JSON using jq:
$ jq dump.json

Error:
parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 121026, column 899

Expected behavior
The exported JSON should adhere to the JSON spec and be parseable by common tools such as jq.

Version(please run rct -v and paste the information):
java -version is less than 1.8
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
redis rdb cli: v0.3.1 (63171da: 2020-02-29T01:47:06+0000)
rct home: /home/crook/Downloads/redis-rdb-cli/bin/..
java version: 11.0.6, vendor: Oracle Corporation
java home: /usr/lib/jvm/java-11-openjdk
default locale: en, platform encoding: UTF8
os name: Linux, version: 5.5.6-arch1-1, arch: amd64

Additional context
Example utf-8 bytes that cause the issue:

Compatibility of redis-rdb-cli with Redis and KeyDB versions

Ask a question

Hi,
I have the following setup and question regarding data migration:

Current setup:
Redis DB: REDIS0011 with redis-ver7.2.4

Target setup:
KeyDB: REDIS0009 with redis-ver6.3.4

I would like to migrate from Redis to KeyDB and I am planning to use redis-rdb-cli for this process. My question is: will redis-rdb-cli understand the dump format from REDIS0011 (redis-ver7.2.4)?

Thank you for your assistance.

Best regards,
zpomal

exit code incorrect

Describe the bug

The exit code incorrect when remote host is unreachable or Redis instance is shutdown.

To Reproduce

(MoeLove) ➜  ~ docker pull redisrdbcli/redis-rdb-cli:v0.1.15
v0.1.15: Pulling from redisrdbcli/redis-rdb-cli
501dc83b5664: Already exists 
481fef4b79f2: Already exists 
2244fc6cc072: Already exists 
09612e383bad: Pull complete 
7a5b1246b03b: Pull complete 
86b44717f545: Pull complete 
Digest: sha256:1d029806a1b085b9bcc3615c0300c15e0f5a31bd99f453f98a0f9ea320cd62b9
Status: Downloaded newer image for redisrdbcli/redis-rdb-cli:v0.1.15
(MoeLove) ➜  ~ docker run --rm -it -v /work/rdb/down/manual.rdb:/tmp/dump.rdb redisrdbcli/redis-rdb-cli:v0.1.15 bash
bash-4.4# rmt -s /tmp/dump.rdb -m redis://172.17.0.2:6379

java.net.ConnectException: Connection refused (Connection refused)
bash-4.4# echo $?
0
bash-4.4# 
bash-4.4# rmt -s /tmp/dump.rdb -m redis://172.17.0.4:6379

java.net.NoRouteToHostException: Host is unreachable (Host unreachable)
bash-4.4# echo $?
0


Expected behavior

The exit code shouldn't be 0.

Version:

bash-4.4# rmt -v
redis rdb cli: v0.1.15 (a09d40c333f0796476a8e0eb6fbd43c4dc085559: 2019-02-24T07:27:35+0000)
rct home: /app/redis-rdb-cli/bin/..
java version: 1.8.0_171, vendor: Oracle Corporation
java home: /usr/lib/jvm/java-1.8-openjdk/jre
default locale: en, platform encoding: UTF-8
os name: Linux, version: 4.16.8-300.fc28.x86_64, arch: amd64

Check migrated data consistency

Ask a question
We would like to ask to add an option which will help to check migrated data consistency.

It may be very usefully especially when we have an important data and should guarantee that all is in place.

Also, sometimes, during RDB format versions migration, we may need to confirm that all is in place and was migrated correctly.

Additional context
As for now, we use info keyspace to compare number of keys between source and destination, but it's probably is not a better way.

Thank you!

Invalid json when hash value contains double-quote

Describe the bug
Exported JSON is not valid when hash value contains a double-quote.

To Reproduce

  1. Set a hash value which contains a double-quote
  2. Export the redis db to rdb
  3. Use rct to convert to json
$ ./rct -f json -s dump.rdb -o dump.json
  1. Try to parse the json
$ jq . dump.json 
  1. See parse error.
parse error: Invalid numeric literal at line 7, column 1849

In my case, the value in question appears in the exported JSON as:

"geo":"["WW"]"

Expected behavior
Exported JSON must be valid. The contents of hash values must be escaped properly in the exported JSON.

Version(please run rct -v and paste the information):
$ ./rct -v
java -version is less than 1.8
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
redis rdb cli: v0.3.0 (d0237a6: 2020-01-13T06:55:45+0000)
rct home: ~/redis-rdb-cli/bin/..
java version: 11.0.6, vendor: Oracle Corporation
java home: /usr/lib/jvm/java-11-openjdk
default locale: en, platform encoding: UTF8
os name: Linux, version: 5.5.1-arch1-1, arch: amd64

Redis remote backup import failing

Hi, i'm facing some issue with your tool. I Don't see what's wrong with this. Because this ip is reacheable from this host. So i don't really understand this error.

Thanks

/app/redis-rdb-cli # rmt -s /data/your_backup.rdb -r -m redis://10.104.49.4:6378

java.lang.RuntimeException: failed to connect to 10.104.49.4:6378, reason expect [$,:,*,+,-] but:
	at com.moilioncircle.redis.rdb.cli.cmd.XRmt.getRdbVisitor(XRmt.java:169)
	at com.moilioncircle.redis.rdb.cli.cmd.XRmt.call(XRmt.java:117)
	at com.moilioncircle.redis.rdb.cli.cmd.XRmt.call(XRmt.java:57)
	at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
	at picocli.CommandLine.access$1300(CommandLine.java:145)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
	at picocli.CommandLine.execute(CommandLine.java:2078)
	at com.moilioncircle.redis.rdb.cli.Rmt.main(Rmt.java:28)
	at com.moilioncircle.redis.rdb.cli.Main.main(Main.java:41)

test failure - com.moilioncircle.redis.rdb.cli.ext.rct.FormatterRdbVisitorTest - array lengths differed

[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.moilioncircle.redis.rdb.cli.ext.rct.FormatterRdbVisitorTest
[ 5 B| 2 B/s]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.85 s <<< FAILURE! - in com.moilioncircle.redis.rdb.cli.ext.rct.FormatterRdbVisitorTest
[ERROR] test(com.moilioncircle.redis.rdb.cli.ext.rct.FormatterRdbVisitorTest) Time elapsed: 2.845 s <<< FAILURE!
org.junit.internal.ArrayComparisonFailure: array lengths differed, expected.length=299 actual.length=283; arrays first differed at element [10]; expected:<13> but was:<10>
at com.moilioncircle.redis.rdb.cli.ext.rct.FormatterRdbVisitorTest.test(FormatterRdbVisitorTest.java:41)
Caused by: java.lang.AssertionError: expected:<13> but was:<10>
at com.moilioncircle.redis.rdb.cli.ext.rct.FormatterRdbVisitorTest.test(FormatterRdbVisitorTest.java:41)

[INFO] Running com.moilioncircle.redis.rdb.cli.glossary.JsonEscapeTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in com.moilioncircle.redis.rdb.cli.glossary.JsonEscapeTest
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] FormatterRdbVisitorTest.test:41 array lengths differed, expected.length=299 actual.length=283; arrays first differed at element [10]; expected:<13> but was:<10>
[INFO]
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.599 s
[INFO] Finished at: 2020-11-25T23:03:18-05:00
[INFO] Final Memory: 27M/412M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project redis-rdb-cli: There are test failures.
[ERROR]
[ERROR] Please refer to C:\tutorials\Redis\export-import\redis-rdb-cli\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Bloom keys not synced to target redis instance

When Syncing redis instances with "rst" the data and bloom filters and its keys in initial snapshot are being migrated to target instance. But during further sync the new created bloom keys are not being synced. The normal keys are synced seamlessly.

So can we also have the bloom keys be synced? Is there anyway to do this? @leonchen83

Problem installing

Ask a question
Feel free to ask any question about this tool. no need to fill following table.

Describe the bug
A clear and concise description of what the bug is.

The download is not working when I run the command:
wget https://github.com/leonchen83/redis-rdb-cli/releases/download/${version}/redis-rdb-cli-release.zip
--2021-12-22 16:54:09-- https://github.com/leonchen83/redis-rdb-cli/releases/download//redis-rdb-cli-release.zip
Resolvendo github.com (github.com)... 20.201.28.151
Conectando-se a github.com (github.com)|20.201.28.151|:443... conectado.
A requisição HTTP foi enviada, aguardando resposta... 404 Not Found
2021-12-22 16:54:10 ERRO 404: Not Found.

What should be the version informed? I tried running to v0.7.2 and still with no success:
wget https://github.com/leonchen83/redis-rdb-cli/releases/v0.7.2/redis-rdb-cli-release.zip

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Version(run rct --version or rct -V and paste the information):

Additional context
Add any other context about the problem here.

Adding any -k parameter returns an empty list

Ask a question
Can't get key filter to work with rct

rct -f json -s dump.rdb -o anno.json -k annotations:thing:*

To Reproduce
Steps to reproduce the behavior:

Result without -k parameter set

[
  {
    "key": "annotations:thing:2b5b90aa",
    "value": "{}",
    "db": 0,
    "type": "string",
    "expiry": 1691764906330
  }
]

Result with -k annotations:thing:*, or -k *.

[]

Expected behavior
-k should filter in the "key" value

Version(run rct --version or rct -V and paste the information):

Running in the redisrdbcli/redis-rdb-cli:latest-native container.

redis rdb cli: v0.9.5 (0e2d1c5: 2023-12-11T04:01:33+0000)
home: /app/redis-rdb-cli/bin/..
java version: 11.0.15, vendor: Oracle Corporation
platform encoding: UTF-8
os name: Linux, version: 6.1.0-17-amd64, arch: amd64

expiry is not right

Describe the bug
the expiry is not right in mem report, example:

database,type,key,size_in_bytes,encoding,num_elements,len_largest_element,expiry
0,hash,"run:car:2020091710022104:2020082910002300:1","145 B",ziplist,1,"10 B","+52842-04-02 16:00:00.000"

Version(run rct --version or rct -V and paste the information):
redis rdb cli: v0.9.1 (1f96c81: 2022-05-01T08:10:04+0000)
home: /ccdata/codis_rdb/test/redis-rdb-cli/bin/..
java version: 1.8.0_152, vendor: Oracle Corporation
java home: /opt/src/jdk1.8.0_152/jre
default locale: en, platform encoding: UTF-8
os name: Linux, version: 3.10.0-693.11.6.el7.x86_64, arch: amd64

password can't have "%"

Describe the bug
when password is "abcde%", output of rct is:

$ ./rct -f resp -s redis://127.0.0.1:6379?authPassword=abcde% -o appendonly.aof
Invalid options: '--source=<source>'

when password is "abc%de", output of rct is:

$ ./rct -f resp -s redis://127.0.0.1:6379?authPassword=abc%de -o appendonly.aof

Exception in thread "main" java.lang.AssertionError: [AUTH #5644a22d4cf293351dea2b983513cd2985ea02e42e486c03596c97fe210aeb45] failed. WRONGPASS invalid username-password pair or user is disabled.
        at com.moilioncircle.redis.replicator.RedisSocketReplicator.auth(RedisSocketReplicator.java:215)
        at com.moilioncircle.redis.replicator.RedisSocketReplicator.establishConnection(RedisSocketReplicator.java:184)
        at com.moilioncircle.redis.replicator.RedisSocketReplicator$RedisSocketReplicatorRetrier.connect(RedisSocketReplicator.java:377)
        at com.moilioncircle.redis.replicator.AbstractReplicatorRetrier.retry(AbstractReplicatorRetrier.java:46)
        at com.moilioncircle.redis.replicator.RedisSocketReplicator.open(RedisSocketReplicator.java:115)
        at com.moilioncircle.redis.rdb.cli.ext.CliRedisReplicator.open(CliRedisReplicator.java:212)
        at com.moilioncircle.redis.rdb.cli.cmd.XRct.call(XRct.java:119)
        at com.moilioncircle.redis.rdb.cli.cmd.XRct.call(XRct.java:47)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2311)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at com.moilioncircle.redis.rdb.cli.Rct.main(Rct.java:28)

Version:

$ ./rct -V
redis rdb cli: v0.7.0 (339cd58f3d8a07c41682e55f92842bd055523c33: 2021-07-20T14:02:15+0000)
home: /mnt/d/code/java/redis-rdb-cli-release/bin/..
java version: 17, vendor: Private Build
java home: /usr/lib/jvm/java-17-openjdk-amd64
default locale: en, platform encoding: UTF-8
os name: Linux, version: 4.4.0-19041-Microsoft, arch: amd64

java.lang.RuntimeException: java.lang.NumberFormatException: null

[root@aaa ~]# rmonitor -s redis://redis地址:6379?authPassword=密码 -n test-monito
java.lang.RuntimeException: java.lang.NumberFormatException: null
at com.moilioncircle.redis.rdb.cli.ext.rmonitor.impl.XMonitorMasterSlave.createMonitorCommands(XMonitorMasterSlave.java:91)
at com.moilioncircle.redis.rdb.cli.ext.rmonitor.impl.XMonitorMasterSlave.(XMonitorMasterSlave.java:58)
at com.moilioncircle.redis.rdb.cli.ext.rmonitor.XMonitorCommand.(XMonitorCommand.java:54)
at com.moilioncircle.redis.rdb.cli.cmd.XRMonitor.call(XRMonitor.java:57)
at com.moilioncircle.redis.rdb.cli.cmd.XRMonitor.call(XRMonitor.java:31)
at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
at picocli.CommandLine.access$1300(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
at picocli.CommandLine.execute(CommandLine.java:2078)
at com.moilioncircle.redis.rdb.cli.RMonitor.main(RMonitor.java:28)
Caused by: java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at com.moilioncircle.redis.rdb.cli.ext.rmonitor.impl.XMonitorMasterSlave.createMonitorCommands(XMonitorMasterSlave.java:76)
... 13 more

不管是监控还是备份redis都执行失败,感觉是连接不上阿里云的redis,出现上面这个报错,用redis-cli命令是可以连接的。另外我用docker搭建的redis是可以监控并备份的。麻烦各位大大帮忙看下这个问题

Invalid parsing result after upgrade to redis 6.0.9

Describe the bug
Parsing an rdb file from redis version 6.0.9 is producing invalid json using the rct command with jsonl format. Previously we were running 5.0.5.
Example invalid result:

{"key":"m:17","value":{"tags":"","":"","":"","description":""},"db":0,"type":"hash"}

In another case I see that the source value of "status":"active" shows up in json as "":"active".

To Reproduce
I have a very large rdb file which I cannot send you for security reasons. I can DM you a dump of one of the broken keys, please let me know where I could send this.

Expected behavior
Redis 6+ rdb files should parse correctly.

Version(run rct -v and paste the information):
redis rdb cli: v0.4.2

Dynamic custom formatters

It might be nice to allow for custom formatters to be developed without the need to fork the repository. Currently, if you want to develop a custom formatter, the main repository needs to be forked and re-built after adding the new formatter to Format.java

For instance:
billcrook@b3cce93#diff-2133dffbf4513d74abdacb9132f74a312f6775830f0763a67c83098c25fc06edR78

An alternative approach might be to allow for dynamic formatters at the command line using a fully qualified path to the new formatter. For instance:
rct -f com.company.rdb.MyAwesomeFormatter ...

MyAwesomeFormatter could be part of a new jar that is placed in the classpath.

Thanks again for the great tool. I've been using it successfully in production for a number of months now - parsing many gigabytes of rdb files every day.

Sync data between KeyDB v6 - Redis v7

Describe the bug
We just tried to Sync data from Redis v7 to the KeyDB v6, but looks like this is not supported.

To Reproduce

  1. Run KeyDB v6

  2. Run Redis v7 and add some data

  3. Run the command

    rst -s redis://redis-v7:6379 -m redis://keydb-v6:6379
    
  4. Application starting to process the data and finish to process the whole dataset

    \[483.3MB| 36.4MB/s]
    
  5. At the same time we see the following errors in the log

    2022-12-29 17:15:03,462 INFO c.m.r.r.r.DefaultRdbVisitor [main] RDB redis-ver: 7.0.5
    2022-12-29 17:15:03,463 INFO c.m.r.r.r.DefaultRdbVisitor [main] RDB redis-bits: 64
    2022-12-29 17:15:03,463 INFO c.m.r.r.r.DefaultRdbVisitor [main] RDB ctime: 1672334103
    2022-12-29 17:15:03,463 INFO c.m.r.r.r.DefaultRdbVisitor [main] RDB used-mem: 24348794648
    2022-12-29 17:15:03,463 INFO c.m.r.r.r.DefaultRdbVisitor [main] RDB repl-stream-db: 0
    2022-12-29 17:15:03,463 INFO c.m.r.r.r.DefaultRdbVisitor [main] RDB repl-id: 5a705558dc170011c96162558e3e21af9d3fecbc
    2022-12-29 17:15:03,463 INFO c.m.r.r.r.DefaultRdbVisitor [main] RDB repl-offset: 4382
    2022-12-29 17:15:03,464 INFO c.m.r.r.r.DefaultRdbVisitor [main] RDB aof-base: 0
    2022-12-29 17:15:04,882 ERROR c.m.r.r.c.n.i.XEndpoint [sync-worker-4] ERR DUMP payload version or checksum are wrong
    2022-12-29 17:15:04,882 ERROR c.m.r.r.c.n.i.XEndpoint [sync-worker-1] ERR DUMP payload version or checksum are wrong
    2022-12-29 17:15:04,882 ERROR c.m.r.r.c.n.i.XEndpoint [sync-worker-3] ERR DUMP payload version or checksum are wrong
    
  6. Keyspace is empty on KeyDB v6.

    keydb-cli info keyspace
    # Keyspace
    

Expected behavior
We should be able to sync data from Redis v7 and KeyDB v6

Version(run rct --version or rct -V and paste the information):

rct --version

redis rdb cli: v0.9.1 (1f96c81dd4935e2c7fc39f6bb227beede0c8ede4: 2022-05-01T08:10:04+0000)
home: /opt/redis-rdb-cli/bin/..
java version: 18.0.2-ea, vendor: Private Build
java home: /usr/lib/jvm/java-18-openjdk-amd64
default locale: en, platform encoding: UTF-8
os name: Linux, version: 5.11.20-300.fc34.x86_64, arch: amd64

Additional context
Probably the same things will happen with the Redis v6, because we were not able to restore RDB dump on v6 from v7 with the same massage as on KeyDB v6.

Can't handle RDB format version 10

Please see [NEW] Support Redis 7 (RDB format version 10) dumps

Terminating due to java.lang.OutOfMemoryError: Java heap space

Describe the bug
Migration failed due to the out of memory

To Reproduce

  1. Start to sync RDB (~ 21GB) to remote Redis

    rmt -s /data/dump.rdb -m redis://redis-7:6379
    
  2. Get the error

    \[ 18.4GB| 91.9MB/s]Terminating due to java.lang.OutOfMemoryError: Java heap space
    
  3. Information about free memory before and after OOM

    free -g
                  total        used        free      shared  buff/cache   available
    Mem:             62           9          26           0          26          51
    Swap:             0           0           0
    
    free -g
                  total        used        free      shared  buff/cache   available
    Mem:             62           3          32           0          26          58
    Swap:             0           0           0
    

Expected behavior
If application require more memory, we should be able to specify it

Version(run rct --version or rct -V and paste the information):

redis rdb cli: v0.9.1 (1f96c81dd4935e2c7fc39f6bb227beede0c8ede4: 2022-05-01T08:10:04+0000)
home: /data/redis-rdb-cli/bin/..
java version: 11.0.17, vendor: Ubuntu
java home: /usr/lib/jvm/java-11-openjdk-amd64
default locale: en, platform encoding: UTF-8
os name: Linux, version: 5.11.20-300.fc34.x86_64, arch: amd64

Additional context
We have tried to set export JAVA_OPTS="-Xmx30G", but nothing changed.

NOAUTH despite authPassword and/or ACL style on Redis 6.2.6

When trying to migrate a RDB file or a single-mode source redis to remote redis cluster (both 6.2.6)

docker run --pull=always -it --rm redisrdbcli/redis-rdb-cli:latest-native bash

# rdt -b redis://192.168.200.177:6161 -o /tmp/data.rdb
/[  1.3GB| 11.6MB/s]

# rmt -s /tmp/data.rdb -m redis://default:[email protected]:6071 -r
\[    5 B|  333 B/s]failed to connect cluster nodes, reason : NOAUTH Authentication required.
failed to connect cluster nodes, reason : NOAUTH Authentication required.
failed to connect cluster nodes, reason : NOAUTH Authentication required.
failed to connect cluster nodes, reason : NOAUTH Authentication required.

Destination Redis Cluster has:

192.168.200.177:6071> ACL LIST
1) "user default on #7d18ca55910168baebd9e6304d988379163eb714a2f524c216299ab377e7451d ~* &* +@all"

I also tried the authPassword and ACL style and both:

redis://default:[email protected]:6071?authPassword=UaY34A1KB
redis://192.168.200.177:6071?authPassword=UaY34A1KB

when I try to log in with a wrong password on purpose it recognized the password was wrong, so it works as expected:

java.lang.RuntimeException: failed to connect to 192.168.200.177:6071, reason WRONGPASS invalid username-password pair or user is disabled.
	at com.moilioncircle.redis.rdb.cli.cmd.XRmt.getRdbVisitor(XRmt.java:169)

It didn't work with the -c nodes.conf variant either.

Am I doing something wrong or is the tool not yet able to handle redis v 6.2.6 ?

output file don't work at "release 0.1.12"

output file don't work at "release 0.1.12"
output file size is zero in any case.

same command line is ok at "release 0.1.11"

centos 7.5
dump.rdb 1000M
openjdk version "1.8.0_191"

More information about applications

Ask a question
Hello,

I just found this toolset when searching a way to copy data between Redis master and Redis master with replication.
Basically it is about master/master copying.

I found the following binaries

rct            - Probably copying/exporting the data from Redis/RDB
rcut
rdt            - Probably working wit the DB
ret
rmonitor       - Based on the name it is about monitoring
rmt            - Migrate the data
rst            - Sync the data

But it is not clear from the provided examples what exactly they are doing. Can you please provide a short description about every of them. Also a a kind of Description: to the help output will be very usefully.

Another question is about sync and migration. Are they different or do the same stuff? Sync sounds like just a copying, when Migration is more about moving.

For example

rst -s redis://source:6379 -m redis://destination:6379

Will this command move all the keys from all DB's or will just copy all of them?

  -m, --migrate <uri>   Migrate to uri. eg:
                        redis://host:port?authPassword=foobar.

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.