redis cross data center replication
Asked Answered
H

3

8

I try to use redis for http session data replication. My Use case is as follows:

We have 2 indepentent datacenters(RZ and RR) each of them has 4 tomcat servers. I have installed redis cluster with sentinel (One Master, 2 slaves and 3 sentinels)on one dedicated server on each datacenter. Each cluster is working as expected.

Now I want to synchrinze data between the 2 Masters nodes (cross-datacenter replication), so if our loadbalancer decide to shwitch from DC RZ(Primary) to DC RR (secondary) session data is available and no session is lost.

I tried to install dynomite framework formy purpose but failling to install it. So My question can redis handle such senario without third party tools such dynomite?

Any Help to achieve the replication between datacenter is very willcome. Sorry for my bad english.

Thank you in Advance.

Herculie answered 21/8, 2017 at 10:3 Comment(0)
T
2

No, Redis does not offer master-master solution. See redis replication and cluster tutorial to understand how redis replication works

Triiodomethane answered 16/7, 2018 at 0:50 Comment(0)
T
1

No, there is no normal way to do this.

Threefold answered 26/9, 2017 at 11:20 Comment(0)
R
0

You can do it with Redisson with Sentinel or Cluster deployments located in different data centers. One deployment is active (read-write) and others are passive (read-only). Active-passive cross data center replication is managed on Redisson side an can be asynchronous or synchronous.

Config example for two Redis Clusters. More info here

Config config = new Config();
config.useMultiClusterServers()
    .setReplicationMode(ReplicationMode.ASYNC)
    // use "rediss://" for SSL connection
    .addAddress("redis://cluster1:7000", "redis://cluster2:70002");

RedissonClient redisson = Redisson.create(config);

Config example for two Redis Sentinels. More info here

Config config = new Config();
config.useMultiSentinelServers()
    .setReplicationMode(ReplicationMode.ASYNC)
    .setMasterName("mymaster")
    // use "rediss://" for SSL connection
    .addSentinelAddress("redis://sentinel_primary:26389", 
                        "redis://sentinel_secondary1:26379", 
                        "redis://sentinel_secondary2:26379")
Radically answered 21/5 at 6:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.