2
votes

I have 3 redis servers each on a different machine. Is it possible to sync between the 3 servers, i.e each server has the same data.

I thought of using a master slave model, i.e all writes go to a single server (A) which is the master. The other 2 servers(B,C) are the slaves from which you can read the data. But the problem is that when the master is up and you try to read from slave u get re directed to master - I want the read to be served by the slave.

How can I implement this requirement?

To answer the question below:-

As you can see below 10.200.37.106:7002 is a slave of master 10.200.37.172:7001.

cluster nodes

e79124fbedc01f8a7e939cfc97298ed8a915df5f 10.200.37.178:7001 slave 1836dd7a25773e6344c49a1219e70835b18ef29a 0 1438981146403 11 connected

2761f9d7a37e2cb749f7e0a7232057cb4df8091c 10.200.37.172:7002 slave e556a56c3fda6cd95dcd63ef53711cf25b29e5a5 0 1438981146904 6 connected

e556a56c3fda6cd95dcd63ef53711cf25b29e5a5 10.200.37.106:7001 master - 0 1438981145902 1 connected 0-5460

3dad620d271dc35ad1e156a4afdd238f5f1da60b 10.200.37.172:7001 myself,master - 0 0 13 connected 5461-10922

1836dd7a25773e6344c49a1219e70835b18ef29a 10.200.37.178:7002 master - 0 1438981144898 11 connected 10923-16383

bcc1f12de5d5924772519da3539f4bbdb331f5be 10.200.37.106:7002 slave 3dad620d271dc35ad1e156a4afdd238f5f1da60b 0 1438981146904 13 connected

But still the slave redirects me to the master.

SLAVE

[jai@SparkDev ~]$ redis-cli -p 7002 -h 10.200.37.106

10.200.37.106:7002> get name

(error) MOVED 5798 10.200.37.172:7001

10.200.37.106:7002> quit

MASTER

[jai@SparkDev ~]$ redis-cli -p 7001 -h 10.200.37.172

10.200.37.172:7001> get name

"jai"

1
"But the problem is that when the master is up and you try to read from slave u get re directed to master" - why would you think that? This isn't how Redis' master-slave replication works - Itamar Haber

1 Answers

0
votes

Quoting from http://redis.io/topics/cluster-spec#scaling-reads-using-slave-nodes:

Normally slave nodes will redirect clients to the authoritative master for the hash slot involved in a given command, however clients can use slaves in order to scale reads using the READONLY command.

READONLY tells a Redis Cluster slave node that the client is ok reading possibly stale data and is not interested in running write queries.