Cut over: migrate from Redis to KiviDB
The order is the same whichever method follows the writes (replication, RedisShake sync, or a live copy tool).
Cutover runbook
The order is the same whichever method follows the writes (replication,
RedisShake sync, or a live copy tool).
-
Rehearse. Run the whole move against a copy, with your application's test suite pointed at KiviDB. Note how long the full copy takes.
-
Start the copy and wait until it follows the writes:
master_link_status:upand equal offsets for replication,syncing aof, diff=[0]for RedisShake. -
Verify with the script below while writes continue. A few keys written in the last second may differ; nothing else should.
-
Lower your client timeouts and retries if they are long, so the switch is quick.
-
Stop writes to Redis. Either stop the writers, or block them at the server:
redis-cli -h redis.internal CLIENT PAUSE 60000 WRITECLIENT PAUSE … WRITE(Redis 6.2+) holds every write for up to 60 seconds, while reads keep working and replication keeps flowing. -
Check the last writes arrived: offsets equal again, or
diff=[0]again. RunDBSIZEon both. -
Promote KiviDB (replication only):
redis-cli -p 6380 REPLICAOF NO ONEWith RedisShake, stop the process.
-
Point the clients at KiviDB: change the setting and restart or reload, or move the DNS name the clients use. Clients that were held by
CLIENT PAUSEtime out and reconnect. -
Verify again and watch the application's error rate and KiviDB's log.
-
Keep Redis running, without writes, until you are sure. When the pause runs out, Redis accepts writes again, so make sure nothing still points at it:
INFO clientsshowsconnected_clients, andCLIENT LISTshows who.
Rollback. Until clients write to KiviDB, rolling back is CLIENT UNPAUSE
on Redis and pointing the clients back. Decide before the switch how you would
roll back after that, because the way back is narrower than the way in:
- A Redis or Valkey replica of KiviDB doesn't work: the full sync fails with
Wrong signature trying to load DB from file, because KiviDB sends its own snapshot format. RedisShake can't read it either, and Redis and Valkey refuse KiviDB'sDUMPpayloads (DUMP payload version or checksum are wrong), soscan_readerand RIOT's default mode copy nothing. - RIOT with
--structcopies KiviDB back with ordinary commands. It reads with Lua scripts, so it needs theluaorfullbuild on the KiviDB side; against a build without Lua it copies nothing and still exits with status 0, so check the result with the verify script. Stream consumer groups and hash field expiry are not copied. - HyperLogLogs written by KiviDB are in KiviDB's own layout unless KiviDB runs
with
--hll-write-format redis; Redis rejects them otherwise (INVALIDOBJ Corrupted HLL object). Set it from the start if you might roll back.
riot replicate redis://kividb.internal:6380 redis://redis.internal:6379 \
--source-pass "$KIVIDB_PASSWORD" --target-pass "$REDIS_PASSWORD" \
--struct --compare NONE
So until you are confident, keep the way back short: switch reads first and keep writing to Redis, or have the application write to both for a while (see dual-write), and keep Redis intact.
After the switch
- Watch KiviDB's log for warnings: each says what to do, and the errors page explains them.
- Keep the old Redis, without writes, until you are sure.
- To compare throughput on your own hardware first, the benchmark guide runs the same tests we publish.