简体   繁体   English

平衡读取带有rmongodb的MongoDB副本集

[英]Balance reads in a MongoDB replica set with rmongodb

I have a MongoDB as a replica set with one master and one slave. 我有一个MongoDB作为副本集,其中包含一个主服务器和一个从属服务器。 I am using RmongoDB and I want to explicitly send a query to each machine using a parallelized for loop. 我正在使用RmongoDB,并且想使用并行化的for循环向每台计算机显式发送查询。

I succesfully created a conection with all the hosts: 我成功创建了包含所有主机的连接:

mongo <- mongo.create(host=c("mastermng01:27001","slavemng01:27001"),
                      name="myRS",
                      username="user",
                      password="pass",
                      db="myDB")
ns_actual <- "myDB.MyCollection"

Then, I run a query like this: 然后,我运行如下查询:

cursor <- mongo.find(mongo,ns=ns_actual,query=list(var1="value"),
                    options=mongo.find.slave.ok)

So far, R knows the slave hosts and it is allowed to query them. 到目前为止,R知道从属主机,并且可以查询它们。 But when it is going to do it? 但是什么时候去做呢? Can I force R to balance the queries among the hosts? 我可以强制R在主机之间平衡查询吗?

Sorry, no solution so far. 抱歉,到目前为止没有解决方案。 The underlying C connector is not supporting this functionality. 基础C连接器不支持此功能。 There is a new mongoC library available which supports this. 有一个新的mongoC库可支持此功能。 But moving rmongodb to this library will take a lot of time which is currently not available. 但是将rmongodb移至该库将花费大量时间,目前尚不可用。

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

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