简体   繁体   English

如何检查在mongodb中读取了哪个副本集

[英]how to check which replica set is read in mongodb

I setup a mongodb replica set, and i have tested the insert operation, the secondary server can sync with the primary. 我设置了一个mongodb副本集,并且已经测试了插入操作,辅助服务器可以与主服务器同步。 Now, I want to check where i do the read operation, which server is handling the request. 现在,我想检查我在哪里执行读取操作,哪个服务器正在处理请求。 How can I check it? 我该如何检查? in mongodb log? 在mongodb日志中? or somewhere else. 或者别的地方。

Btw: My driver is Mongoid. 顺便说一句:我的司机是Mongoid。 many thanks 非常感谢

Use mongostat --discover . 使用mongostat --discover This will show you the statistics for all members in the replica set. 这将为您显示副本集中所有成员的统计信息。 When a read is performed you can see which member is servicing the request. 执行读取后,您可以看到哪个成员正在处理请求。

Note that reads will only go to the non-primary member if your queries use slaveOk 请注意,如果您的查询使用slaveOk ,则读操作将仅到达非主要成员

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

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