简体   繁体   English

Mongodb oplog同步

[英]Mongodb oplog synchronization

I am evaluating Mongo DB with Apache Storm. 我正在用Apache Storm评估Mongo DB。 My use case is such that I've to read data from MongoDB in Apache Storm, do some processing in the bolt and dump it into Neo4J graph database. 我的用例是这样的,我将在Apache Storm中从MongoDB读取数据,在bolt中进行一些处理并将其转储到Neo4J图形数据库中。

I am using a Mongo Spout, which will read the data from the oplog file. 我正在使用Mongo Spout,它将从oplog文件中读取数据。 I went through the documentation which says the primary node writes data to oplog file and replica reads will happen from it asynchronously. 我查看了文档,其中说主节点将数据写入oplog文件,并且副本读取将异步发生。 I know that the oplog is a capped collection(specified size), data is being written to oplog at a very high velocity and synchronization to replica set is a bit slow. 我知道oplog是一个上限集合(指定大小),数据以非常高的速度写入oplog,同步到副本集有点慢。 If the oplog reaches its max size, it overwrites the documents from the beginning of the file. 如果oplog达到其最大大小,它将覆盖文件开头的文档。 During async process, if we get some other data and if the replication is still in-complete, there is a possibility of losing replication set since it will not be synchronized. 在异步过程中,如果我们获得了一些其他数据,并且复制仍未完成,则可能会丢失复制集,因为它不会被同步。

My question here is 我的问题是

1) Is there any way to overcome this? 1)有没有办法克服这个问题?

2) How better can we make use of this capped collection when using with Apache Storm? 2)在使用Apache Storm时,我们如何更好地利用这个上限集合?

3) If i give maximum oplog size for eg i give 500GB and oplog has 1gb of data will it occupy and reserve 500gb of size? 3)如果我给出最大的oplog大小,例如我给500GB而oplog有1GB的数据它会占用并保留500gb的大小?

4) Is this the right solution for my use case? 4)这是我用例的正确解决方案吗?

Thanks in advance!!! 提前致谢!!!

Yes, you can overcome this by increasing the size of the oplog. 是的,您可以通过增加oplog的大小来克服这个问题。 This requires a shutdown of the mongo instance to take effect. 这需要关闭mongo实例才能生效。

I recently worked on a proof of concept similar what you're doing using a tailed cursor in Mongo to subscribe to any changes made in the oplog of a primary and migrate them to another database. 我最近研究了一个类似于你在Mongo中使用尾部游标进行的概念验证,以订阅在主要的oplog中进行的任何更改并将它们迁移到另一个数据库。 We too ultimately looked into Storm to do this in a cleaner fashion. 我们也最终调查了Storm,以更清洁的方式做到这一点。 We were not 100% sold on Storm for this use case either but the tailed cursor was a bit ugly and unreliable. 对于这个用例,我们并没有100%在Storm上销售,但是尾部游标有点难看且不可靠。 I'd use Storm before a tailed cursor. 我会在尾灯前使用Storm。

You can better make use of this capped collection with Storm by having Storm only pick up new commands. 你可以通过Storm只使用Storm来获取新的命令,从而更好地利用Storm的这个上限集合。 The replication issues you touch upon appear to be mutually exclusive from the task of picking up a new command from the Oplog on a primary and executing those operations of interest into Neo4j. 您接触到的复制问题似乎与从主服务器上的Oplog中获取新命令以及将感兴趣的操作执行到Neo4j中的任务相互排斥。 If you were reading from the oplog on a secondary, I would better understand this to be an issue regarding what you claim the objective is (ie writing the data to Neo4j). 如果您正在读取辅助中的oplog,我会更好地理解这是关于您声称目标是什么的问题(即将数据写入Neo4j)。 Since you are reading from the Primary's oplog, and can just process the newest commands as they come into it, I am not sure there is an issue here. 由于您正在阅读Primary的oplog,并且可以在它们进入时处理最新的命令,因此我不确定这里是否存在问题。

Regarding the RS sync issues you raised; 关于您提出的RS同步问题; if your secondaries are that out of sync that you are losing replication then there are issues that should be resolved well in advance. 如果您的辅助设备不同步而您正在丢失复制,那么有些问题应该提前解决。 I do understand and appreciate your point but a system designed to allow that to happen is in need of some TLC. 我理解并理解你的观点,但设计允许这种情况发生的系统需要一些TLC。

As you said, the oplog is a capped collection. 正如你所说,oplog是一个上限集合。 When it runs out of space it will make room for any new commands to be executed. 当它用完空间时,它将为任何新命令的执行腾出空间。 Nothing is reserved as you put it. 你说的没有什么是保留的。 Your secondaries would not be able to have those commands applied to them and require a full resync. 您的辅助设备将无法将这些命令应用于它们并需要完全重新同步。 You need to be concerned with the "replication oplog window" which denotes 1. That's the amount of time an operation will remain in the oplog before being overwritten by a new entry. 您需要关注“复制oplog窗口” ,它表示1.这是操作在被新条目覆盖之前保留在oplog中的时间。 2. how long a secondary member can be offline and still catch up to the primary without doing a full resync. 2.辅助成员可以脱机多长时间,并且仍然可以在不执行完全重新同步的情况下赶上主要成员。

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

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