I want to change my redis slave to master so I read about SLAVEOF. But I don't understand this line:
"The form SLAVEOF NO ONE will stop replication, turning the server into a
MASTER, but will not discard the replication"
I believe that the following edit will help you understand:
The form SLAVEOF NO ONE will stop replication, turning the server into a MASTER, but will not discard the replicated data
That is now obsolete. Instead use REPLICAOF NO ONE. More infor can be found in here: https://redis.io/commands/replicaof/
Related
I found that Sentinel is mainly used for promoting slave to master automatically when master failed.
I also found that redis-4.0.11's cluster mode seemly also have this function itself.
So when I use redis-4.0.11's in cluster mode, do I need a Sentinel ?
NO, you don't need sentinels in cluster mode.
When a master is down, the cluster will promote one of its slaves to be the new master automatically.
I have a redis master-slave setup and the configuration of the slave is set to slave_read_only:1, but when I enter a PUBLISH command on the slave node it does not fail. I would expect an error, but it just takes the command and nothing else happens. The message is not propagated to the master either.
The question is, why is that? Did I mis-configure redis? Is that a feature? To what purpose? Or is it just a bug?
The problem arises in a setup where automatic failover occurs. A master may become a slave and clients of that slave may publish messages without realizing that it is no master any more. Do I have to check before each message is sent if the redis node is still master?
I use redis 3.0.5
You didn't misconfigure - this is the defined behavior as PUBLISH isn't considered a write command.
Also note, that when replicating published events are replicated from master to slaves (downstream, as usual), so if you're publishing to a slave only clients connected to it or to its slaves and subscribed to the relevant channel will get the message.
We have a redis cluster with a master and a slave managed by three sentinel processes, and an additional remote slave, hosted in a different datacenter, for transparent failover and data preservation in the case that something bad happens to the master and slave machines.
It may happen that a transient error takes down the master redis process only, and in this situation we would like to see the slave process promoted to master, and the remote slave reslaved to it. However, it seems that sentinel could just as easily promote the remote slave to master, and we have not found any way to prevent this.
Is there any way to mark a particular slave machine as unpromotable, so that sentinel will not try to make it the master in the event of a failover?
Yes. In the slave's config file set the slave-priority setting to zero (the number not the word).
I need to don't loss any data on redis and It has high write request,so I can't use AOF persistence.RDB can help be,but maybe It's possible to loss some of data from last backup.
Now I think about replication as backup,so when master crashed,restarted or anything else,I have synced data in slaves and can restore it again.
Now is there any way set master as slave,and slave as master at crashed time automatically,then sync them?
When your application comes to know that MASTER is down, application should issue below command on SLAVE:
SLAVEOF NO ONE
The above command would make the SLAVE as MASTER and your application could continue using this as MASTER now.
When your actual MASTER is up, issue following command:
SLAVEOF hostname port
Here hostname and port would be for the old SLAVE. With this the MASTER-SLAVE configuration is swapped.
We want to use Redis to distribute data to remote servers.
There is one master instance in the HQ and many remote slaves in our subsidiaries connected to the master.
Our applications are running in our subsidiaries. In 99% of the time there are read-only requests made to the slave instance.
But there is also the case of modifying data. Such a request is issued against the master.
Is there a way to ensure that the changes made to the master are replicated to the slave before the next read request?
I'm not sure if there is a way you can ensure this 100%, but you probably want to check in your redis.conf file and find this:
slave-serve-stale-data yes
Sounds like you'd want that set to no. The comments in the config file explain more about this directive.