应用程序调用了副本集中的哪个 Mongo 实例? [英] Which Mongo instance in Replica Set did the application call?

查看:49
本文介绍了应用程序调用了副本集中的哪个 Mongo 实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Java 应用程序,它与 Mongo 副本集 配合使用.副本集由不同主机上的两个 Mongo 实例(primary 和 secondary)组成

I have a Java application, which works with a Mongo replica set. The replica set consists of two Mongo instances (primary and secondary) in different hosts

假设应用程序正在执行查询(例如在集合中查找文档).我不知道它使用什么阅读偏好.还假设 primarysecondary 实例存储相同的数据.

Suppose the application is executing a query (e.g. find a document in a collection). I don't know what read preference it uses. Suppose also that both primary and secondary instances store the same data.

现在我需要知道应用程序调用了哪个 Mongo 实例来执行查询:primarysecondary 或两者.

Now I need to know which Mongo instance the application has called to execute the query: the primary, the secondary, or the both.

我该怎么做?

我更喜欢不需要访问应用程序代码的解决方案.

I would prefer a solution, which does not require access to the application code.

推荐答案

默认的阅读偏好是主要的,所以如果你没有改变它,它就是阅读的地方.

The default read preference is primary so if you didn't change it, that's where it's reading.

这篇关于应用程序调用了副本集中的哪个 Mongo 实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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