定义
- shardConnPoolStats
- 已在MongoDB 5.0中删除。 请改用 - connPoolStats。- 返回有关分片连接池中池化和缓存连接的信息。 该命令还会返回连接池中每线程连接缓存的信息。 - shardConnPoolStats命令使用以下语法:- { shardConnPoolStats: 1 } - 分片连接池特定于分片集群中成员之间的连接。 集群中的 - mongos实例使用连接池来执行客户端读取和写入。- mongod发出- mapReduce来查询其他分片上的临时collection时,集群中的 实例会使用该池。- 当集群需要连接时,MongoDB 会将连接从分片连接池拉取到每线程连接缓存中。 MongoDB 在每次操作后将连接返回到连接池。 
兼容性
此命令可用于以下环境中托管的部署:
- MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务 
- MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本 
- MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本 
输出
- shardConnPoolStats.hosts
- 显示集群中每个配置服务器、副本集和独立运行的实例的连接状态。 - shardConnPoolStats.hosts.<host>.available
- 该主机可用于连接到 - mongos的连接数。
 - shardConnPoolStats.hosts.<host>.created
- 主机为连接到 - mongos而创建的连接数。
 
- shardConnPoolStats.replicaSets
- 显示特定于副本集的信息。 - shardConnPoolStats.replicaSets.<name>.host
- 保存报告每个副本集成员的文档数组。 这些值派生自副本集状态值。 - shardConnPoolStats.replicaSets.<name>.host[n].ok
- 此字段供内部使用。 当 - mongos无法连接到实例或收到连接异常或错误时,报告- false。
 - shardConnPoolStats.replicaSets.<name>.host[n].ismaster
- 如果此值为 - true,则该主机是副本集的主节点。
 - shardConnPoolStats.replicaSets.<name>.host[n].hidden
- 如果此值为 - true,则主机是副本集的隐藏节点。
 - shardConnPoolStats.replicaSets.<name>.host[n].secondary
- 如果此值为 - true,则主机是副本集的隐藏节点。- 如果此值为 - true,则主机为副本集的从节点。
 - shardConnPoolStats.replicaSets.<name>.host[n].pingTimeMillis
- 从 - mongos到该成员的延迟(以毫秒为单位)。
 - shardConnPoolStats.replicaSets.<name>.host[n].tags
- 一份 - tags文档包含用户定义的副本集节点标签字段和值对。- { "<tag1>": "<string1>", "<tag2>": "<string2>",... } - 对于读取操作,您可以在读取偏好中指定标签集,以将操作定向到具有指定标签的副本集节点员。 
- 对于写入操作,您可以使用 - settings.getLastErrorModes和- settings.getLastErrorDefaults创建自定义写关注。
 - 有关更多信息,请参阅配置副本集标签集。 
 
 
- shardConnPoolStats.totalCreated
- mongos曾经创建的与集群其他节点的连接数。