Halo, kalau kamu merasa tulisan saya ngebantu kamu, kamu bisa ucapkan terima kasih lewat saweria.

If you feel this website help you, you can donate at saweria.



If you want to move or clone your Redis instance, you can easily copy existing keys using RIOT.

Redis Input/Output Tools (RIOT) is a command-line utility designed to help you get data in and out of Redis.

  1. Download RIOT wget https://github.com/redis-developer/riot/releases/download/v3.1.5/riot-standalone-3.1.5-linux-x86_64.zip

  2. Unzip it unzip riot-standalone-3.1.5-linux-x86_64.zip, then go to the bin directory cd riot-standalone-3.1.5-linux-x86_64/bin

  3. To copy all Redis keys to another Redis instance, use

    
    ./riot -h 192.168.1.2 -p 6379 -a "Server1RedisPass" --db 0 replicate -h 192.168.1.3 -p 6379 -a "Server2RedisPass" --db 0 --batch 10000 \
    --scan-count 10000 \
    --threads 4 \
    --read-threads 4 \
    --read-batch 500 \
    --read-queue 2000 \
    --read-pool 4 
    
  4. If you want to use the export and import method

    #export all keys
    ./riot -h 192.168.1.2 -p 6379 -a "Server1RedisPass" \
    file-export /tmp/redis.json
    
    #then import all keys
    ./riot -h 192.168.1.3 -p 6379 -a "Server2RedisPass" \
    dump-import /tmp/redis.json
    
    Export Keys to JSON

    Export Keys to JSON

  5. If you want to use the RIOT Docker version

    docker run fieldengineering/riot  \
    -h 192.168.1.2 -p 6379 -a "Server1RedisPass" --db 0 replicate -h 192.168.1.3 -p 6379 -a "Server2RedisPass" --db 0 --batch 1000 \
    --scan-count 10000 \
    --threads 4 \
    --read-threads 4 \
    --read-batch 500 \
    --read-queue 2000 \
    --read-pool 4 
    
    Copy Key Success

    Copy Key Success

  6. If you want to copy from production (running redis instance) add --mode live

    docker run fieldengineering/riot  \
    -h 192.168.1.2 -p 6379 -a "Server1RedisPass" --db 0 replicate -h 192.168.1.3 -p 6379 -a "Server2RedisPass" --db 0 --batch 1000 \
    --scan-count 10000 \
    --threads 4 \
    --read-threads 4 \
    --read-batch 500 \
    --read-queue 2000 \
    --read-pool 4 
    --mode live
    

    If you not using --mode live, there will be error “Error executing step compare in job Replication: Verification failed”

    Don’t Forget To Add --mode live

    Don’t Forget To Add --mode live

References:

  1. Stack Overflow - Copy all keys from one db to another in Redis