简体   繁体   English

Redis群集中“磁盘支持的”复制如何工作

[英]how does “Disk-backed” replication work in redis cluster

the redis.conf says: redis.conf说:

1) Disk-backed: The Redis master creates a new process that writes the RDB file on disk. 1)支持磁盘:Redis主服务器创建一个新过程,将RDB文件写入磁盘。 Later the file is transferred by the parent process to the slaves incrementally 之后,文件由父进程逐步传输到从属服务器

I just dont know what does "transferred by the parent process to the slaves" mean? 我只是不知道“由父进程转移到奴隶”是什么意思?

thank you 谢谢

It is simple. 很简单。 First read the RDB file into a buffer, and use socket.write to send this to salve's port which is listenning this. 首先,将RDB文件读入缓冲区,然后使用socket.write将其发送到正在监听的Salve端口。

The implemention is more complex than what I said. 实现比我说的要复杂。 But this is what redis do. 但这就是redis所做的。 You can refer the replication.c in redis/src for more details. 您可以在redis / src中引用replication.c以获得更多详细信息。

EDITED: 编辑:

Yes, the disk-less mechanism just use the child process directly sends the RDB over the wire to slaves, without using the disk as intermediate storage. 是的, 无磁盘机制仅使用子进程,而不使用磁盘作为中间存储,而直接通过电线将RDB发送到从属。
Actually, if you use disk to save the RDB and redis master can serve many slaves at the same time without queuing. 实际上,如果您使用磁盘保存RDB,则redis主服务器可以同时为多个从服务器提供服务而无需排队。 Once the disk-less replication serve on slave, and if another slave comes and want do a full sync, it need to be queued to wait for the first slave to finish. 无盘复制一旦在从属服务器上运行,并且如果另一个从属服务器出现并要进行完全同步,则需要将其排队等待第一个从属服务器完成。 So there are another settings repl-diskless-sync-delay to wait more slave to do this parallel. 因此,还有另一个设置repl-diskless-sync-delay来等待更多从属服务器并行执行此操作。

And these two method only occur after something wrong happens. 并且这两种方法仅在发生错误后才发生。 In the normal case, the redis master and salve through a well connected wire to replicate the redis command the slave to keep the same between the master and slave. 在正常情况下,redis主机和主机通过一条连接良好的导线进行复制以复制redis命令从机,以使主机和从机之间保持相同。 And if the wire is break or the slave fall down, then need do a partial resync action to obtain the part slave missed. 并且如果电线断线或从机掉线,则需要执行部分重新同步操作以获得丢失的部分从机。 If the psync is not possible to achieve, it will try do full resync. 如果无法实现psync,它将尝试执行完全重新同步。 The full resync is what we talked about. 完全重新同步就是我们所说的。

This is how a full synchronization works in more details: 完整同步的工作方式如下:

The master starts a background saving process in order to produce an RDB file. 主机开始后台保存过程以生成RDB文件。 At the same time it starts to buffer all new write commands received from the clients. 同时,它开始缓冲从客户端收到的所有新写命令。 When the background saving is complete, the master transfers the database file to the slave, which saves it on disk, and then loads it into memory. 后台保存完成后,主服务器将数据库文件传输到从服务器,从服务器将其保存在磁盘上,然后将其加载到内存中。 The master will then send all buffered commands to the slave. 然后,主机将所有缓冲命令发送到从机。 This is done as a stream of commands and is in the same format of the Redis protocol itself. 这是作为命令流完成的,并且与Redis协议本身的格式相同。

And the disk-less replication is just a new feature which supports the full-resync in that case to deal with the slow disk stress. 无盘复制只是一项新功能,在这种情况下,它支持完全重新同步以应对缓慢的磁盘压力。 More about it refer to https://redis.io/topics/replication . 有关它的更多信息,请参阅https://redis.io/topics/replication such as how do psync and why psync will fail, you can find answer from this article. 例如如何做psync以及为什么psync会失败,您可以从本文中找到答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM