流星怎么会知道 MongoDB 立即发生变化? [英] How could meteor know MongoDB changes instantly?

查看:24
本文介绍了流星怎么会知道 MongoDB 立即发生变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想知道 mongoDB 立即发生变化,我见过的最好的解决方案是拖尾 mongoDb 日志,我一直想知道直到遇到Meteor.

I had been wondering about knowing mongoDB changes instantly for a while and best solution that I have ever seen, is tailing mongoDb logs and I just had given wondering up till met Meteor.

mongoDB 以某种方式(通过 Meteor 或直接)发生更改时,Meteor 会立即了解更改并应用它们.我们可以在 publishing 更改或观察(observeobserveChange)更改时看到它.

When there is a changes on mongoDB somehow(through Meteor or directly), Meteor understands the changes instantly and apply them. We could see it on publishing changes or observing(observe or observeChange) changes.

我猜,Meteor 可以通过拖尾 mongoDB 日志来理解它,这是我见过的最佳解决方案所建议的.但是这个假设也让我问,Meteor 可以与在不同主机上运行的 mongoDB 一起运行,如果 Meteor 知道 MongoDB 立即更改的方式是拖尾日志,那怎么可能 mongoDBcode>Meteor 跟踪在不同机器(不同主机)上运行的 mongoDB 的日志并处理更改?在不同的主机上拖尾需要痛苦的事情,我认为 Meteor 不会遵循这种方式.

I guess that, Meteor could understand it by tailing mongoDB logs as the best solution that I have ever seen suggests. But this assumption also make me ask that, Meteor can run with a mongoDB running on different host and if the way that meteor knows MongoDB changes instantly is tailing logs, how could Meteor tails logs of mongoDB running on different machine(different host) and handle changes? Tailing on different host requires painful things and I think Meteor does not follow this way.

由于这个问题,我认为拖尾日志不是我的答案.

I think tailing logs is not my answer because of this question.

我对这些知识很好奇.因为,我认为,如果我拥有它,我可以在没有 Meteor 的情况下在我的其他作品中使用它.

I am curious about this knowledge. Cause, I think that, if I have it, I could use it on my other works without Meteor.

那么,Meteor 怎么能真正知道 mongoDB 立即发生变化?我想再问一次;立即了解 mongoDB 更改的最佳方法是什么?

So, how could really Meteor knows mongoDB changes instantly? And I wanna ask once again; what would be the best way to know about mongoDB changes instantly?

谢谢!

推荐答案

是的,这是来自新的 oplog 拖尾功能.Meteor 假装它是副本集中的 mongodb,它会跟踪 mongodb 的操作日志以获取它正在监控的集合.

Yes you are right this is from new new oplog tailing functionality. Meteor pretends that it is mongodb in a replica set and it tails mongodb's operation logs for collections it is monitoring.

通常数据库需要多台服务器,以便在其中一台出现故障时可以保持运行.MongoDB 在副本集中具有此功能.

Usually databases need multiple servers so that they can stay up in case one fails. MongoDB has this functionality in a replica set.

所以这就是meteor的用武之地.Meteor伪装成一个mongodb副本数据库,所以当这个操作日志上的任何数据发生变化以供其他副本查看时,Meteor知道数据发生了变化,并且可以将这些新数据推送给客户端瞬间.

So this is where meteor comes in. Meteor pretends to be a mongodb replica database so when any data changes on this operations log for other copies to see, Meteor knows that data has changed and can push this new data down to the client instantly.

您可以在设置 MONGO_OPLOG_URL 时使用具有此新功能的不同 mongo 数据库.您需要先将mongodb设置为副本集,以便启用操作日志

You can use a different mongo database with this new functionality as you set MONGO_OPLOG_URL. You will need to set mongodb as a replica set first so that the operations log is enabled

这是上周在 0.7 版本中的最新介绍,您可以在下方查看有关它的博文

This was a very recent introduction put in just last week in version 0.7 you can see the blog post about it below

关于它的更多链接:

这篇关于流星怎么会知道 MongoDB 立即发生变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆