如何检查应用程序是否以MongodB从辅助节点读取? [英] How to check application is reading from Secondary Node in MongodB?

查看:177
本文介绍了如何检查应用程序是否以MongodB从辅助节点读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个成员副本集。读取首选项设置为次要首选。如何检查应用程序是否以MongodB从次要节点读取?请提出建议。

I have a 3 member replica set. Read preference is set as "Secondary Preferred" How to check application is reading from Secondary Node in MongodB? Please suggest.

推荐答案

首先,您可以配置性能分析。为此,您需要使用选项-profile 2 启动mongodb服务器并配置日志文件。它将记录所有查询。
之后,您可以读取每个实例数据库的日志。简单示例:

Firstly you can configure profiling. For that you need to start your mongodb servers with option --profile 2 and configure log file. It'll log all queries. After that you can read log for each instance db. Simple example:

db.your_collection.profile.find({ns: "name_your_db.your_collection"})

第二步,您可以使用 mongotop 。您需要为每个mongodb服务器启动它。
例如:

Secondly you can use mongotop. You need to start it for each mongodb server. For example:

mongotop -h server_ip:server_port seconds
mongotop -h 127.0.0.1:27017 5

它将在每个指定的时间段打印日志,您可以在其中读取读取的时间或对每个集合进行写操作。

It'll print every specified period of time log, where you can read how much time for read or write is taken for each collection.

这篇关于如何检查应用程序是否以MongodB从辅助节点读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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