How to do it...

The first way to perform a single Redis instance to another single Redis instance migration works as follows:

  1. First, let's start two Redis instances:
$ bin/redis-server conf/redis.conf$ bin/redis-server conf/redis2.conf$ ps -ef |grep redis-serverredis 361 32707 0 14:14 pts/5 00:00:00 grep redis-serverredis 21413 1 0 Dec10 ? 00:03:10 bin/redis-server 0.0.0.0:6379redis 32762 1 0 14:13 ? 00:00:00 bin/redis-server 0.0.0.0:6380127.0.0.1:6379> info Keyspace# Keyspacedb0:keys=1000000,expires=0,avg_ttl=922042600
  1. By acting as a slave of the source instance, we can replicate all the data from the source Redis:
127.0.0.1:6380> SLAVEOF 192.168.1.7 6379OK127.0.0.1:6380> info Keyspace# Keyspacedb0:keys=1000000,expires=0,avg_ttl=922042600 ...

Get Redis 4.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.