0

I am running redis in cluster mode with one master and two replicas. I have a host where for some reason all redis instances were down and when I do ps -ef|grep redis , I would get nothing. Then I start redis manually using redis-server command as follows.

sudo redis-server /p1/p2/conf/redis-3021.conf
sudo redis-server /p1/p2/conf/redis-3022.conf
sudo redis-server /p1/p2/conf/redis-3023.conf

when I do ps -ef|grep redis, I see the above three instances created.

When I check the cluster nodes command as below,

redis-cli -h localhost -p 3021 cluster nodes|grep myself 

I get the below output.

599ca9dae5sdfb52dc8b5ca460fbb2e3c4 <localhostIp>:3021@13021 myself,slave 88fb2ewer1f0asfew520d20cb3c57e994be914 0 1664316404000 87 connected

I get similar output for 3022 and 3033. All of them got added as replicas to existing cluster. I wanted to add 3021 as a new master node and 3022 and 3033 as replicas for some other master node. I tried deleting these nodes with redis-cli del-node command but did not work as it has some data. Is it the case that there was already some data on this instance when it was running before and when I bring up the instance, it loads it up from file system into memory? Appreciate your help. Thanks.

Zack
  • 2,078
  • 10
  • 33
  • 58

1 Answers1

0

Please refer - https://redis.io/docs/manual/replication/

To configure basic Redis replication: add the following line to the replica configuration file:

replicaof {masterNodeIpAddress} 6379
charybr
  • 1,888
  • 24
  • 29
  • When I created a cluster with three instances 3021, 3022 and 3023 , it had created 3021 as master and 3022 and 3023 as replicas. Is that automatic and randomly done by redis? Can redis choose 3022 as master and 3021 and 3023 as replicas? – Zack Sep 29 '22 at 22:12
  • if you want 3022 as master, then in config of 2021 and 3023, set replicaof property to - replicaof {masterNodeIpAddress} 3022 – charybr Oct 01 '22 at 12:17