问题描述
我使用 db.serverStatus().connections
检查到我的 MongoDB 服务器的连接数并得到以下结果:
I checked number of connections to my MongoDB server using db.serverStatus().connections
and got this result:
matrix:PRIMARY> db.serverStatus().connections
{
"current" : 45,
"available" : 51155,
"totalCreated" : NumberLong(1886475)
}
但是,当我尝试按照这个答案检查连接了哪些客户端时,我得到了这个结果:
However when I tried to check which clients are connected by following this answer, I got this result:
$ sudo lsof | grep mongod | grep TCP | wc -l
5390
以上哪一个是正确的,为什么两个输出有巨大差异?
Which one of the above is correct and why is there a huge difference in the two outputs?
推荐答案
这只是 lsof
输出的问题.lsof
在输出中包含文件的偏移量:https://unix.stackexchange.com/questions/60422/how-to-interpret-this-output-of-lsof-command.因此,输出中的同一连接有多个条目.一旦我删除它,来自 lsof 的客户端数量与 db.serverStatus().connections
报告的相同.
This was just a problem with the lsof
output. lsof
includes the offset of the file in the output: https://unix.stackexchange.com/questions/60422/how-to-interpret-this-output-of-lsof-command. So there are multiple entries for the same connection in the output. Once I removed that, number of clients from lsof was same as that reported by db.serverStatus().connections
.
这篇关于与 MongoDB 服务器的连接数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!