-
Notifications
You must be signed in to change notification settings - Fork 278
Replication
yinqiwen edited this page Sep 8, 2013
·
7 revisions
Ardb replication is compatible with redis 2.6/2.8, so Ardb instance can be configured as a slave of a Redis instance and vice versa.
Since redis 2.8 has new feature about 'partial replication', it's a little difference when ardb talking with Redis 2.6/2.8. The following would discuss the inner details about replication in ardb.
Ardb's replication design is based on redis 2.8 replication design, and have some changes to make it more reliable. Refer redis's replication topic for more details. The following would talking about the changes in ardb. http://redis.io/topics/replication
- The inner baklog buffer for master is mapping from a disk file(use mmap). And the replication states(offsets, size, ...) are also mapping from a disk file. If master is restarted, master would resumed from last state.
- Slave's replication states are also mapping from disk file.
- Master/Slave replication states are persisted periodically.
- Master would dump redis's rdb format file for redis slaves.
- Master would send raw key-value to ardb slaves for full syncing.
- Master:Ardb Slave:Redis 2.6
- Slave send 'sync' to master
- Master mark slave as redis 2.6 slave, dump all data in a redis dump file, then send this file to slave.
- After sending dump file, master mark slave's state as syncing from backlog buffer.
- Master send caching data from the dumping offset. After sending cached data, master mark slave's state as ready. Then all commands changed data would be sent to this ready slave.
- If slave reconnect master, it would send 'sync' again.
- Master:Ardb Slave:Redis 2.8
- Slave send 'psync offset' to master
- If the runid is unmated current master or the offset is invalid, master would send 'FULLRESYNC offset' to slave, or other wise master just send '+Continue' to slave.
- If Master send '+Continue', then send cached data from offset in 'psync'.
- If Master send 'FULLRESYNC offset', it would dump data to a file then send it to slave.
- Master:Redis 2.6 Slave:Ardb
- Refer 'Master:Ardb Slave Redis 2.6'
- Master:Redis 2.8 Slave:Ardb
- Refer 'Master:Ardb Slave:Redis 2.8'
- Master:Ardb Slave:Ardb
- Slave send 'psync2 offset' to master. (It master received 'psync2', the master treat slave as Ardb slave).
- If the runid is unmated current master or the offset is invalid, master would send 'FULLRESYNC offset' to slave, or other wise master just send '+Continue' to slave.
- If Master send '+Continue', then send cached data from offset in 'psync2'.
- If Master send 'FULLRESYNC offset', it would iterate storage-engine and send raw key-value data to slave.