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

查看:47
本文介绍了流星怎么能立即知道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会立即了解更改并应用它们.我们可以在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一起运行,并且如果流星知道MongoDB的变化立即改变了尾部日志,那么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跟踪功能.流星假装它是副本集中的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.

所以这就是流星的来源.流星假装成mongodb副本数据库,因此当此操作上的任何数据更改记录下来供其他副本查看时,流星都知道数据已更改,可以将该新数据推送到客户端

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

有关它的更多链接:

  • https://www.meteor.com/blog/2013/12/17/meteor-070-scalable-database-queries-using-mongodb-oplog-instead-of-poll-and-diff
  • https://www.youtube.com/watch?v=_dzX_LEbZyI
  • https://github.com/meteor/meteor/wiki/Oplog-Observe-Driver

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

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