0

We need to have an in-memory key/value storage which can be replicated to other data centers.
Here is our requirements:
1. All data centers must have the same database (a little resynchronization is acceptable like 30-60 seconds). I know that we can have only one master server and it is OK. Only one database in one data center will be a master. But if the master server dies then we need to elect a new master.
2. We need to be able to send write requests to any of the slave nodes and it will send it to the master node directly.

I know that there is a Redis cluster which can accept all write requests but it isn't suitable for us because data are distributed among nodes (So, all servers in all data centers will handle different data but we need to have the same data in all data centers because we have only 5% of writes and 95% of reads).

Is it possible to realize with the Redis?

Oleksandr
  • 3,574
  • 8
  • 41
  • 78
  • Even if you set `slave-read-only no`, any writes to slave won't be synced to the master. Instead, these writes will be deleted when the slave syncs with the master. – for_stack Oct 26 '16 at 14:38

1 Answers1

0

I wasn't right. I found out that it actually can be done with Redis Cluster. We have to create one master node and assign all hash slots to it. After that we have to create slave nodes and replicate the master. In this situation we will have an automatic failover and all nodes will keep the same data.

To set a slave node. I.e. replicate a master we need to use the following:

./redis-trib.rb add-node --slave --master-id {master_id} {master_ip}:{master_port} {slave_ip}:{slave_port}

Or we can add a new empty master:

./redis-trib.rb add-node {any_node_ip_in_cluster}:{port} {new_node_ip}:{port}

And then turn it to the slave:

redis {master_ip}:{master_port}> cluster replicate {master_id}

P.S. Redis has a requirement to have a minimum of 3 masters but it isn't a hard limit of the cluster. We still can have only one master node and it will be totally fine.

Oleksandr
  • 3,574
  • 8
  • 41
  • 78