对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

connPoolStats(数据库命令)

connPoolStats

The command connPoolStats returns information regarding the open outgoing connections from the current database instance to other members of the sharded cluster or replica set.

要运行 connPoolStats,请使用 db.runCommand( { <command> } ) 方法。

注意

connPoolStats only returns meaningful results for mongos instances and for mongod instances in sharded clusters.

此命令可用于以下环境中托管的部署:

  • MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务

注意

所有 MongoDB Atlas 集群都支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令

该命令具有以下语法:

db.runCommand(
{
connPoolStats: 1
}
)

参数的值(即 1 )不会影响命令的输出。

connPoolStats 在其输出中包含聚合统计信息:

  • The hosts field displays the information aggregated by host.

  • The pools field displays the information aggregated by pool.

注意

To avoid interference with any running operations, connPoolStats does not take any locks. As such, the counts may change slightly as connPoolStats gathers information, resulting in slight differences between the hosts and pools connection counts.

以下操作使用 方法在分片集群的db.runCommand()connPoolStats mongos上运行 命令。分片集群有2 个分片,每个分片都有一个单节点副本集和一个配置服务器副本集。mongos 在具有4 核心的机器上运行。

db.runCommand( { "connPoolStats" : 1 } )

该命令返回以下形式的输出:

注意

The connPoolStats output varies depending on the deployment and the member against which you run connPoolStats among other factors.

{
"numClientConnections" : <num>,
"numAScopedConnections" : <num>,
"totalInUse" : <num>,
"totalAvailable" : <num>,
"totalLeased" : <num>,
"totalCreated" : <num>,
"totalRefreshing" : <num>,
"replicaSetMatchingStrategy" : <string>,
"acquisitionWaitTimes" : { // Added in MongoDB 6.3
"(-inf, 0ms)" : { "count" : <num> },
"[0ms, 50ms)" : { "count" : <num> },
"[50ms, 100ms)" : { "count" : <num> },
"[100ms, 150ms)" : { "count" : <num> },
"[150ms, 200ms)" : { "count" : <num> },
"[200ms, 250ms)" : { "count" : <num> },
"[250ms, 300ms)" : { "count" : <num> },
"[300ms, 350ms)" : { "count" : <num> },
"[350ms, 400ms)" : { "count" : <num> },
"[400ms, 450ms)" : { "count" : <num> },
"[450ms, 500ms)" : { "count" : <num> },
"[500ms, 550ms)" : { "count" : <num> },
"[550ms, 600ms)" : { "count" : <num> },
"[600ms, 650ms)" : { "count" : <num> },
"[650ms, 700ms)" : { "count" : <num> },
"[700ms, 750ms)" : { "count" : <num> },
"[750ms, 800ms)" : { "count" : <num> },
"[800ms, 850ms)" : { "count" : <num> },
"[850ms, 900ms)" : { "count" : <num> },
"[900ms, 950ms)" : { "count" : <num> },
"[950ms, 1000ms)" : { "count" : <num> },
"[1000ms, inf)" : { "count" : <num> },
"totalCount" : <num>
},
"pools" : {
"NetworkInterfaceTL-TaskExecutorPool-0" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"acquisitionWaitTimes" : <document>, // Added in MongoDB 6.3
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
},
"NetworkInterfaceTL-TaskExecutorPool-1" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"acquisitionWaitTimes" : <document>, // Added in MongoDB 6.3
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
}
},
"NetworkInterfaceTL-TaskExecutorPool-2" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"acquisitionWaitTimes" : <document>, // Added in MongoDB 6.3
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
}
},
"NetworkInterfaceTL-TaskExecutorPool-3" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"acquisitionWaitTimes" : <document>, // Added in MongoDB 6.3
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
}
},
"NetworkInterfaceTL-ShardRegistry" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"acquisitionWaitTimes" : <document>, // Added in MongoDB 6.3
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"cfg2.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"cfg3.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"shard1.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"shard2.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
}
},
"global" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"acquisitionWaitTimes" : <document>, // Added in MongoDB 6.3
"cfg3.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"cfg2.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"shard2.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"shard1.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
}
}
},
"hosts" : {
"cfg3.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"cfg2.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"shard2.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"shard1.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
}
},
"replicaSets" : {
"csRS" : {
"hosts" : [
{
"addr" : "cfg1.example.net:27019",
"ok" : <bool>,
"ismaster" : <bool>,
"hidden" : <bool>,
"secondary" : <bool>,
"pingTimeMillis" : <num>
},
{
"addr" : "cfg2.example.net:27019",
"ok" : <bool>,
"ismaster" : <bool>,
"hidden" : <bool>,
"secondary" : <bool>,
"pingTimeMillis" : <num>
},
{
"addr" : "cfg3.example.net:27019",
"ok" : <bool>,
"ismaster" : <bool>,
"hidden" : <bool>,
"secondary" : <bool>,
"pingTimeMillis" : <num>
}
]
},
"shardB" : {
"hosts" : [
{
"addr" : "shard2.example.net:27018",
"ok" : <bool>,
"ismaster" : <bool>,
"hidden" : <bool>,
"secondary" : <bool>,
"pingTimeMillis" : <num>
}
]
},
"shardA" : {
"hosts" : [
{
"addr" : "shard1.example.net:27018",
"ok" : <bool>,
"ismaster" : <bool>,
"hidden" : <bool>,
"secondary" : <bool>,
"pingTimeMillis" : <num>
}
]
}
},
"ok" : 1,
"$clusterTime" : {
"clusterTime" : <timestamp>,
"signature" : <document>
},
"operationTime" : <timestamp>
}
connPoolStats.totalAvailable

报告从当前mongod / mongos实例到分片集群副本集其他成员的可用传出连接总数。

connPoolStats.totalLeased

报告从池中借用并预期返回的连接总数。 这些连接可能不会在租约期间保持活动状态,因此被排除在相关指标之外。 这些连接在租约期间不可用。

connPoolStats.totalCreated

报告当前mongod / mongos实例曾向分片集群副本集的其他成员创建的传出连接总数。

connPoolStats.totalInUse

报告从当前mongod / mongos实例到当前正在使用的分片集群副本集的其他成员的传出连接总数。

connPoolStats.totalRefreshing

报告从当前mongod / mongos实例到当前正在刷新的分片集群副本集的其他成员的传出连接总数。

connPoolStats.totalWasNeverUsed

报告从当前mongod / mongos实例到分片集群副本集的其他成员的传出连接总数,这些连接因从未使用过而关闭。

connPoolStats.replicaSetMatchingStrategy

版本 5.0 中的新增功能。

mongos实例上,此值报告该实例用于确定其连接池到副本集中节点的最小大小限制的策略。

mongod实例上,此值报告该实例用于确定其与其他副本集中的节点的连接池的最小大小限制的策略。

可以使用 mongosmongodShardingTaskExecutorPoolReplicaSetMatching参数设置针对 和 的策略。

注意

If the ShardingTaskExecutorPoolReplicaSetMatching is set to "automatic", the replicaSetMatchingStrategy still describes the actual policy being used, not "automatic". To find the value of the ShardingTaskExecutorPoolReplicaSetMatching, use getParameter which returns the value of the server parameter:

db.adminCommand( { getParameter : 1, "ShardingTaskExecutorPoolReplicaSetMatching" : 1 } )
connPoolStats.acquisitionWaitTimes

6.3版本新增。

文档报告一个直方图,其中包含从mongosmongod获取连接的请求的等待时间:

  • 该文档包含以毫秒为单位的时间范围以及每个范围内的连接请求数。

  • -inf 为负无穷大, (-inf, 0ms)范围内的连接请求不会等待。

  • inf 为正无穷大,并且[1000ms, inf)范围内的连接请求等待时间大于或等于 1,000 毫秒。

  • totalCount 是所有时间范围内的连接请求总数。

"acquisitionWaitTimes" : {
"(-inf, 0ms)" : { "count" : <num> },
"[0ms, 50ms)" : { "count" : <num> },
"[50ms, 100ms)" : { "count" : <num> },
"[100ms, 150ms)" : { "count" : <num> },
"[150ms, 200ms)" : { "count" : <num> },
"[200ms, 250ms)" : { "count" : <num> },
"[250ms, 300ms)" : { "count" : <num> },
"[300ms, 350ms)" : { "count" : <num> },
"[350ms, 400ms)" : { "count" : <num> },
"[400ms, 450ms)" : { "count" : <num> },
"[450ms, 500ms)" : { "count" : <num> },
"[500ms, 550ms)" : { "count" : <num> },
"[550ms, 600ms)" : { "count" : <num> },
"[600ms, 650ms)" : { "count" : <num> },
"[650ms, 700ms)" : { "count" : <num> },
"[700ms, 750ms)" : { "count" : <num> },
"[750ms, 800ms)" : { "count" : <num> },
"[800ms, 850ms)" : { "count" : <num> },
"[850ms, 900ms)" : { "count" : <num> },
"[900ms, 950ms)" : { "count" : <num> },
"[950ms, 1000ms)" : { "count" : <num> },
"[1000ms, inf)" : { "count" : <num> },
"totalCount" : <num>
}
connPoolStats.numClientConnection

报告从当前mongod / mongos实例到分片集群副本集其他成员的活动和存储的传出同步连接的数量。

These connections are a part of a pool that is a subset of the data reported by totalAvailable, totalCreated, and totalInUse.

connPoolStats.numAScopedConnection

报告从当前 /mongos 实例到分mongod 片集群 副本集 其他成员的活动和已存储传出 范围同步 连接的数量。

These connections are a part of a pool that is a subset of the data reported by totalAvailable, totalCreated, and totalInUse.

connPoolStats.pools

报告按连接池分组的连接统计信息(正在使用/可用/已创建/刷新)。 mongodmongos有两个不同的传出连接池系列:

  • 基于 DBClient 的池(“写入路径”)和

  • 基于 NetworkInterfaceTL 的池(“读取路径”)。

对于每个池,该命令都会返回一个类似于以下内容的文档:

{
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"acquisitionWaitTimes" : <document>, // Added in MongoDB 6.3
"[host1]" : {
"inUse" : <num>, "available" : <num>, "leased" : <num>, "created" : <num>, "refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
"[host2]" : {
"inUse" : <num>, "available" : <num>, "leased" : <num>, "created" : <num>, "refreshing" : <num>,
"acquisitionWaitTimes" : <document> // Added in MongoDB 6.3
},
...
}

注意

If there are no connections (in use/available/created/refreshing) for a particular pool, the connPoolStats does not return statistics for that pool.

connPoolStats.pools.NetworkInterfaceTL-TaskExecutorPool-[n]

显示与 TaskExecutor 池相关的连接统计信息。 通常,每个内核有一个 TaskExecutorPool,例如 pools.NetworkInterfaceTL-TaskExecutorPool-0 ... pools.NetworkInterfaceTL-TaskExecutorPool-7表示 8 核处理器。

connPoolStats.pools.NetworkInterfaceTL-ShardRegistry

如果对分片集群的成员运行该命令,则可用。

显示当前mongod / mongos实例与分片集群其他成员之间的连接池统计信息。

connPoolStats.pools.NetworkInterfaceTL-Replication

如果对副本集的成员运行该命令,则可用。

显示当前mongod实例与副本集其他成员之间的连接池统计信息。

connPoolStats.pools.global

显示基于 DBClient 的池统计信息。

connPoolStats.pools.[pool].poolWasNeverUsed

显示此连接池中因从未使用而关闭的连接数。

connPoolStats.pools.[pool].acquisitionWaitTimes

6.3版本新增。

Reports the wait times for requests to acquire a connection from mongos to mongod. For details, see connPoolStats.acquisitionWaitTimes.

connPoolStats.hosts

报告按主机分组的连接统计信息(正在使用/可用/已创建/正在刷新)。

包含文档,这些文档表示当前mongod / mongos实例与分片集群副本集的每个成员之间的连接报告。

connPoolStats.hosts.[host].available

报告可用于连接到[host]的连接总数。

connPoolStats.hosts.[host].leased

报告从池中借用并预期返回的主机的连接总数。 这些连接可能不会在租约期间保持活动状态,因此被排除在相关指标之外。 这些连接在租约期间不可用。

connPoolStats.hosts.[host].created

报告曾经创建的与[host]的连接数。

connPoolStats.hosts.[host].inUse

报告当前正在使用的与[host]的连接数。

connPoolStats.hosts.[host].wasNeverUsed

报告从host到分片集群副本集其他成员的传出连接总数,这些连接因从未使用过而被关闭。

connPoolStats.hosts.[host].acquisitionWaitTimes

6.3版本新增。

Reports the wait times for requests to acquire a connection from mongos to mongod. For details, see connPoolStats.acquisitionWaitTimes.

connPoolStats.replicaSets

包含表示与连接到当前 /mongod 的每个副本集相关的信息报告的 文档mongos

connPoolStats.replicaSets.replicaSet

报告连接到当前 / mongod的每个 副本集mongos

connPoolStats.replicaSets.[replicaSets].hosts

包含报告 副本集 每个成员的 文档 数组。

这些值派生自副本集状态值。

connPoolStats.replicaSets.[replicaSet].hosts[n].addr

[hostname]:[port]格式报告副本集节点的地址。

connPoolStats.replicaSets.[replicaSet].hosts[n].ok

在以下情况下报告false

此字段供内部使用。

connPoolStats.replicaSets.[replicaSet].hosts[n].ismaster

Reports true if this host is the primary member of the replica set.

connPoolStats.replicaSets.[replicaSet].hosts[n].hidden

Reports true if this host is a hidden member of the replica set.

connPoolStats.replicaSets.[replicaSet].hosts[n].secondary

Reports true if this host is a secondary member of the replica set.

connPoolStats.replicaSets.[replicaSet].hosts[n].pingTimeMillis

Reports the ping time in milliseconds from the mongos or mongod to this host.

connPoolStats.replicaSets.[replicaSet].hosts[n].tags

如果该集合的该成员配置了标签,则报告members[n].tags

有关 ok 状态字段、operationTime 字段和 $clusterTime 字段的详情,另请参阅响应

host

给本页内容打分