how to make two Redis server to replicate to each other?

1,707 views
Skip to first unread message

了凡四训

unread,
Nov 10, 2011, 5:22:00 PM11/10/11
to Redis DB
Hi,

I have set up two redis server: A:6379, B:6379. each one works fine.

then I set up A 'slaveof' B by changing A's configure file, and B's
content is replicated to A.

then I set up B 'slaveof' A too, now, 1) A's content is not replicated
to B, 2) B's content is not replicated to A too.

Anyway to accomplish to let A and B to sync content with each other?

Thanks!

Josiah Carlson

unread,
Nov 10, 2011, 7:20:34 PM11/10/11
to redi...@googlegroups.com
There is currently no way to have Redis automatically replicate
between two instances. The cycle you have set up will prevent any new
data from being added, and will most likely result in both instances
trying to use as much CPU and network as they possibly can.

You may want to look into Redis cluster, it may offer you what you need.

Regards,
- Josiah

2011/11/10 了凡四训 <xiaom...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>
>

Eric Piraux

unread,
Oct 1, 2015, 11:58:30 AM10/1/15
to Redis DB
Is it possible to host 4 redis nodes (2 master and 2 slaves) on a cluster of 2 servers :

  • Server 1 
    • Master Node 1 
    • Slave of Master 2
  • Server 2
    • Master Node 2
    • Slave of Master 1
?

Something like this (found on Alachisoft, NCache site)

Greg Andrews

unread,
Oct 1, 2015, 1:50:11 PM10/1/15
to redi...@googlegroups.com
At the present time this won't work.  The Redis instances end up with no data or are constantly busy flushing their databases and syncing (pulling) data from the other instance, which is doing the same flush/load with the first instance.

IIRC, Antirez is evaluating approaches that would allow dual master servers to replicate to each other as you described, or a slave to replicate from multiple masters.  Until then, the best approach to handle the single point of failure would be to use Sentinel to automatically handle a failed master (by promoting a slave to be the new master, point the other slaves to it, and point clients to the new master and slaves).  Or perhaps to use Cluster.

  -Greg

To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.

To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Javier Guerra Giraldez

unread,
Oct 1, 2015, 1:53:47 PM10/1/15
to redi...@googlegroups.com
On Thu, Oct 1, 2015 at 12:49 PM, Greg Andrews <hva...@gmail.com> wrote:
>
> At the present time this won't work. The Redis instances end up with no data or are constantly busy flushing their databases and syncing (pulling) data from the other instance, which is doing the same flush/load with the first instance.


AFAICT, the setup puts a master and a slave on each host, on host A
runs Master1 and Slave2, while on hostB it's Slave1 and Master2.

i haven't tried such a scheme, but i think it should work.


--
Javier

Greg Andrews

unread,
Oct 1, 2015, 2:14:47 PM10/1/15
to redi...@googlegroups.com
Thanks Javier, I misread Eric's message.

It's certainly possible to have two instances on the same server.  Just make sure there's enough ram for them, and any persistence settings don't overload the disk i/o.  To avoid interfering with each other. each instance on the server will have to be configured to listen on a different TCP port number or on a different IP address.

The client software will have to be written to look for data on both Redis instances on the server, and to resolve any situations where each Redis instance has the same key but with different values.  This can be more complex than having a single master and 2+ slaves managed by Sentinel.  Or cluster, as Josiah suggested in the other thread.

  -Greg

Reply all
Reply to author
Forward
0 new messages