shardConnPoolStats
定义
shardConnPoolStats
自MongoDB 5.0起删除。 使用
connPoolStats
代替。返回关于分片连接池中池化和缓存的连接的信息。该命令还返回关于连接池中每个线程的连接缓存的信息。
命令
shardConnPoolStats
使用以下语法{ shardConnPoolStats: 1 } 分片连接池是特定于分片集群成员之间的连接。集群中的mongos实例使用连接池来执行客户端的读取和写入。集群中的mongod实例在执行
mapReduce
时使用该池来查询其他分片上的临时集合。当集群需要连接时,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
曾创建到集群其他成员的连接数。