检查当前与MongoDb的连接数 [英] Check the current number of connections to MongoDb

查看:713
本文介绍了检查当前与MongoDb的连接数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取连接到特定MongoDB服务器的客户端数量的命令是什么?

What is the command to get the number of clients connected to a particular MongoDB server?

推荐答案

连接到管理数据库并运行db.serverStatus():

connect to the admin database and run db.serverStatus():

> var status = db.serverStatus()
> status.connections
   {"current" : 21, "available" : 15979}
> 

您可以通过查询直接获得

You can directly get by querying

db.serverStatus().connections

要了解MongoDb的db.serverStatus().connections响应是什么意思,请在此处阅读文档.

To understand what does MongoDb's db.serverStatus().connections response mean, read the documentation here.

连接

"connections" : {
   "current" : <num>,
   "available" : <num>,
   "totalCreated" : NumberLong(<num>)
},

连接 报告连接状态的文档.使用这些值可以评估服务器当前的负载和容量要求.

connections A document that reports on the status of the connections. Use these values to assess the current load and capacity requirements of the server.

connections.current 从客户端到数据库服务器的传入连接数.此数字包括当前的Shell会话.考虑connections的值.可用于向该基准添加更多上下文.

connections.current The number of incoming connections from clients to the database server . This number includes the current shell session. Consider the value of connections.available to add more context to this datum.

该值将包括所有传入连接,包括任何外壳程序连接或来自其他服务器的连接,例如副本集成员或mongos实例.

可用的连接 可用的未使用的传入连接数.将此值与connections.current的值结合使用,以了解数据库上的连接负载,以及UNIX ulimit设置文档,以获取有关可用连接上的系统阈值的更多信息.

connections.available The number of unused incoming connections available. Consider this value in combination with the value of connections.current to understand the connection load on the database, and the UNIX ulimit Settings document for more information about system thresholds on available connections.

connections.totalCreated 创建到服务器的所有传入连接的计数.此数字包括此后已关闭的连接.

connections.totalCreated Count of all incoming connections created to the server. This number includes connections that have since closed.

这篇关于检查当前与MongoDb的连接数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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