mongoDB将特定数据添加到数据库副本 [英] mongoDB adding specific data to db Replica

查看:68
本文介绍了mongoDB将特定数据添加到数据库副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在寻找是否有人可以在mongodb数据库上复制给定的信息? 我的想法是仅发送某种类型的数据,例如,如果文档具有"height"字段,则仅将高度值大于10的文档发送到副本.

I'm currently looking if there is anyway for a person to replicate given info on a mongodb DB? my idea is to only send a certain type of data, let's say, if a document has the field "height", that only documents with a height value higher than let's say 10, would be sent to the replica.

这可能吗?如果可以的话,您能否解释一下或提供链接到正确记录的地方?

Is this possible? and if so, could you please explain or give a link to where this might be properly documented?

谢谢.

PS:这是用于java/jsp项目的,所以我添加了这些标签,以防Java驱动程序中有内置命令.

PS: this is for a java/jsp project, so I'm adding these tags in case there are built-in commands for this in the java driver.

推荐答案

答案为是"和否".

副本集将不提供此功能.副本集就是每个节点包含相同数据的一组副本或克隆.因此,没有简单的开箱即用"方式来完成您想要的事情.

Replica Sets will not provide this functionality. Replica Sets are just that a set of replicas or clones where each node contains the same data. So there's no easy "out of the box" way to do what you want.

但是,复制通过特殊的"oplog"集合起作用.这是数据库中的实际集合,其中包含对数据的所有最近更改.

However, replication works via a special "oplog" collection. This is an actual collection in the DB that contains all of the recent changes to the data.

理论上,您可以尾随"此oplog并有选择地应用更改.实际上,人们已经做到了.但是,这项功能并未得到广泛支持,因此肯定需要几个小时(或几天)的时间才能完成工作.

In theory you can "tail" this oplog and selectively apply changes. In fact people have done this. However, this is not a widely supported feature and it will definitely require several hours (or days) of effort to make work.

这篇关于mongoDB将特定数据添加到数据库副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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