I am wanting to configure in-memory REDIS Master with a Slave providing the persistence to AOF and RDB.
In the event of a crash or reboot, is there an easy way to reload the in-memory master? To load from the AOF provided by the Slave instance?
Thanks
Related
I have configured two slaves and one master using sentinel.
I have turned off persistence on all the servers. Now the sync happens between master and slave using BGSAVE command.
So shall i assume that though i have persistence off redis is still persisting since it created rdb file for syncing data?
I guess you just have to use replication diskless to avoid Redis using BGSAVE. In fact diskless replication use socket instead of the file to send data on their slaves
https://deepsource.io/blog/redis-diskless-replication/
regard,
Our current Redis setup is a Web application client using Jedis to directly connect using one JedisPool for writes to a single Redis master and a second JedisPool for reads from a single Redis slave. The slave is setup to replicate the master.
We are in the process of moving to using the JedisSentinelPool on the client and introducing Sentinel(s) to handle failover more cleanly. As far as I know, it seems that the JedisSentinelPool only communicates with the currently elected master, so now all writes/reads go to the master. Compared to before when the reads could be distributed to the slave.
Is there any way using JedisSentinelPool to distribute the reads to the slave for load balancing purposes? Or it is necessary to implement this manually with a JedisPool (as before) In which case if the master failed, the JedisSentinelPool would now point to the old slave (new master) and the JedisPool would still dumbly point to the old slave, and effectively the old slave (new master) would now be handling reads AND writes?
Does the Redis Sentinel (or otherwise) have any load balancing (as opposed to failover) capabilities? We currently only have one slave, could adding more slaves be used for load balancing? And if so what are the recommended configurations?
Any advice, real-world experience here would be appreciated.
I write a new JedisSentinelPool , can read from slave with load balancing ,write from master ,it use the redis subscribe the slaves, I use it in my Web application , see code github sentinel-slave-jedis-pool
Redis have 2 persistence options: RDB and AOF. But not sure if it uses them to replicate data from masters to slaves. Should i keep one of them enabled for redis cluster or does it replicate data in some other way?
In documentation i found:
"If you wish, you can disable persistence at all, if you want your data to just exist as long as the server is running."
but not sure if this also true for cluster
Persistence is separate from replication; Redis uses the network for replication. You can disable persistence and still have replication from masters to slaves.
Starting with Redis 2.8,redis add a function named "Partial resynchronization".I read this official document,but i don't understand.who can help me?
It is about master-slave replication.
The normal behavior of a Redis slave (slave of command, or configuration) is to connect to the master, ask the master to accumulate master-slave traffic, request a complete dump on filesystem to the master, download this dump on the slave, load the dump, and finally play the accumulated traffic until the slave catches up with the master.
This mechanism is quite robust but not very efficient to cover transient connection drops between the slave and the master. If the master-slave link is down for a couple of seconds, the slave will request a full resynchronization (involving a dump, etc ...), even if only a few commands have been missed.
Starting with 2.8, Redis includes a partial replication mechanism so a slave can reconnect to the master, and if some conditions are met (like a transient connection drop), asks the master to resynchronize without having to dump the whole memory instance.
In order to support this feature, the master has to buffer and keep a backlog of commands, so they can be served to the slaves at any time if needed. If the slave is too late behind the master, the backlog may not contain anymore the required data. In that case, a normal full synchronization is done, as in previous versions.
Can I configure Redis slave to stop saving dumps? I have omitted all save instructions in config file but slave is still doing dumps.
So I assume you have checked in the configuration file of the slave that RDB is deactivated (all save lines commented out), and the slave has been restarted after the configuration file has been changed (so this configuration is active).
At this point the background dump operation of the slave is deactivated, but it does not prevent the slave to write a dump file. Actually, the slave has to write a dump file at startup time: this is how it retrieves the data from the master in bulk mode.
When the slave starts, it sends a SYNC request to the master:
The master starts accumulating Redis commands.
The master performs a background dump
The master sends the dump file to the slave in bulk mode
The slave reads the dump file from the master and write it to the disk
When it is complete, the slave loads the dump file from the disk
The slave starts processing Redis commands accumulated by the master
Eventually, the slave will catch up
The slave is in sync with the master
That's why you can find dump files on slave side even if RDB is deactivated for the slaves.
A good reading is http://redis.io/topics/persistence
Redis has 2 kinds of persistence, you should disable AOF too:
Append-only file
Snapshotting is not very durable. If your computer running Redis
stops, your power line fails, or you accidentally kill -9 your
instance, the latest data written on Redis will get lost. While this
may not be a big deal for some applications, there are use cases for
full durability, and in these cases Redis was not a viable option. The
append-only file is an alternative, fully-durable strategy for Redis.
It became available in version 1.1.
You can turn on the AOF in your configuration file:
appendonly yes
From now on, every time Redis receives a command that changes the
dataset (e.g. SET) it will append it to the AOF. When you restart
Redis it will re-play the AOF to rebuild the state.