O'Reilly logo

Redis 4.x Cookbook by Zuofei Wang, Pengcheng Huang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required