Hi!
CharSyam skrev 2012-07-10 17:46:
> Thanks dvirsky.
>
> I worry about this situation.
That's good. You should. It depends on your application whether
asynchronous replication is acceptable or not.
>
> I suppose that I run 2 Redis server using replication.
>
> Master successfully processed a request, but M fails before M sent
> replication message to S.
>
> and I changed S to M. at the time. the data will be lost.
>
> Of course, I already know it is common situation with async-replication
>
> I just want to know that Is there another way to enhance consistency?
>
You're actually talking about durability here. There is only one way to
make sure you don't lose data on a failover and that is to use
synchronous replication of some sort. If the master returns success
before it knows that the command has arrived at the slave, then it will
always be possible that the master fails and the write is lost when
doing a failover (even though the client was told that the write
succeeded!).
When it comes to consistency, please keep in mind that it can mean a few
different things. The data at the slave is always "internally"
consistent in Redis (just like an RDB snapshot is too). What I mean is
that you will never see e.g. half-completed or reordered operations
applied at the slave. Due to asynchronous replication, the master and
the slave is not necessarily consistent in regard to each other, however
(the slave can lag behind). This kind of consistency is only required if
you need to send requests to both the master and the slave (and need
e.g. a write to the master to be guaranteed to show up in a subsequent
read to the slave). One way to implement this is to use synchronous
replication.
Redis does not support synchronous replication (at the moment) and
frankly, it's not primarily designed to be used when data durability is
extremely important. For maximum durability, you can use "appendfsync
always" in the configuration file and (if you need even more) you can
use e.g. DRBD to synchronously replicate the filesystem between two
machines (or use a SAN with synchronous replication built-in). This way
you will need to reload the data from (the replicated) disk on another
machine when doing a failover. Be warned, it will be slow! This is the
only (simple) way to guarantee zero data loss on a failover with Redis,
AFAIK.
Cheers,
Hampus
>
> On Tuesday, July 10, 2012 11:08:20 PM UTC+8, dvirsky wrote:
>
>
> On Tue, Jul 10, 2012 at 6:00 PM, CharSyam <
char...@gmail.com
> <mailto:
char...@gmail.com>> wrote:
>
> Hi. everyone.
>
> I am curious about redis replication.
>
> I heard that redis replication is async. at that time Does it
> guarantee consistency between master and slave?
>
>
> it guarantees eventual consistency, not immediate consistency. but
> most of the time it is near immediate.
>
>
> and if replication operation fails at that time, what happen?
> retry? or discard?
>
> if a slave disconnects, it will do a full resync with the master
> once it reconnects. you can control whether while resyncing it will
> server the old data or not.
>
> you can read a whole lot about it here, it will give you all the
> info you need.
> have fun!
>
http://redis.io/topics/replication <
http://redis.io/topics/replication>
> <
https://groups.google.com/d/msg/redis-db/-/ggq14O10DAkJ>.
> <mailto:
redi...@googlegroups.com>.
> To unsubscribe from this group, send email to
>
redis-db+u...@googlegroups.com
> <mailto:
redis-db%2Bunsu...@googlegroups.com>.
> <
http://groups.google.com/group/redis-db?hl=en>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Redis DB" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/redis-db/-/hX3PCTyTVsgJ.
>
redis-db+u...@googlegroups.com.