connPoolStats
On this page本页内容
Definition定义
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
返回关于从当前数据库实例到分片集群或副本集的其他成员的打开的传出连接的信息。To run要运行connPoolStats
, use thedb.runCommand( { <command> } )
method.connPoolStats
,请使用db.runCommand( { <command> } )
方法。NoteconnPoolStats
only returns meaningful results for仅为mongos
instances and formongod
instances in sharded clusters.mongos
实例和分片集群中的mongod
实例返回有意义的结果。
Syntax语法
The command has the following syntax:该命令具有以下语法:
db.runCommand(
{
connPoolStats: 1
}
)
The value of the argument (i.e. 参数的值(即1
) does not affect the output of the command.1
)不会影响命令的输出。
Behavior行为
connPoolStats
includes aggregated statistics in its output:在其输出中包括汇总统计数据:
Thehosts
field displays the information aggregated by host.hosts
字段显示按主机聚合的信息。Thepools
field displays the information aggregated by pool.pools
字段显示按池聚合的信息。
To avoid interference with any running operations, 为了避免干扰任何正在运行的操作,connPoolStats
does not take any locks. connPoolStats
不接受任何锁。As such, the counts may change slightly as 因此,当connPoolStats
gathers information, resulting in slight differences between the hosts
and pools
connection counts.connPoolStats
集合信息时,计数可能会略有变化,从而导致hosts
和池连接计数之间略有差异。
Example实例
The following operation uses the 以下操作使用db.runCommand()
method to run the connPoolStats
command on a mongos
of a sharded cluster. db.runCommand()
方法在分片集群的mongos
上运行connPoolStats
命令。The sharded cluster has 2 shards, each a single-member replica set, and a config server replica set. 分片集群有2个分片,每个分片都有一个成员副本集和一个配置服务器副本集。The mongos
runs on a 4-core machine.mongos
在4核机器上运行。
db.runCommand( { "connPoolStats" : 1 } )
The command returns the output of the following form:该命令返回以下形式的输出:
The connPoolStats
output varies depending on the deployment and the member against which you run connPoolStats
among other factors.connPoolStats
的输出因部署和运行connPoolStats
所针对的成员以及其他因素而异。
{
"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>
}
Output输出
connPoolStats.totalAvailable
-
Reports the total number of available outgoing connections from the current报告从当前mongod
/mongos
instance to other members of the sharded cluster or replica set.mongod
/mongos
实例到分片集群或副本集的其他成员的可用传出连接总数。
connPoolStats.totalLeased
-
Reports the total number of connections borrowed from a pool and expected to return.报告从池借用并预期返回的连接总数。These connections might not remain active through the duration of a lease, and are excluded from the related metrics.这些连接可能在租赁期间不会保持活动状态,并且被排除在相关指标之外。These connections are unavailble through the duration of the lease.这些连接在租赁期间是无效的。
connPoolStats.totalCreated
-
Reports the total number of outgoing connections ever created by the current报告当前mongod
/mongos
instance to other members of the sharded cluster or replica set.mongod
/mongos
实例创建的到分片集群或副本集的其他成员的传出连接的总数。
connPoolStats.totalInUse
-
Reports the total number of outgoing connections from the current报告从当前mongod
/mongos
instance to other members of the sharded cluster or replica set that are currently in use.mongod
/mongos
实例到当前正在使用的分片集群或副本集的其他成员的传出连接的总数。
connPoolStats.totalRefreshing
-
Reports the total number of outgoing connections from the current
mongod
/mongos
instance to other members of the sharded cluster or replica set that are currently being refreshed.
connPoolStats.totalWasNeverUsed
-
Reports the total number of outgoing connections from the current
mongod
/mongos
instance to other members of the sharded cluster or replica set that were closed having never been used.
connPoolStats.replicaSetMatchingStrategy
-
New in version 5.0:5.0版新增:(Also available starting in 4.4.5 and 4.2.13)On a在mongos
instance, this value reports the policy used by the instance to determine the minimum size limit of its connection pools to nodes within replica sets.mongos
实例上,此值报告实例用于确定其到副本集中节点的连接池的最小大小限制的策略。On a在mongod
instance, this value reports the policy used by the instance to determine the minimum size limit of its connection pools to nodes within other replica sets.mongod
实例上,此值报告实例用于确定其连接池到其他副本集中节点的最小大小限制的策略。The policy formongos
andmongod
can be set with theShardingTaskExecutorPoolReplicaSetMatching
parameter.mongos
和mongod
的策略可以使用ShardingTaskExecutorPoolReplicaSetMatching
参数设置。NoteIf the
ShardingTaskExecutorPoolReplicaSetMatching
is set to"automatic"
, thereplicaSetMatchingStrategy
still describes the actual policy being used, not"automatic"
.To find the value of the要查找ShardingTaskExecutorPoolReplicaSetMatching
, usegetParameter
which returns the value of the server parameter:ShardingTaskExecutorPoolReplicaSetMatching
的值,请使用getParameter
返回服务器参数的值:db.adminCommand( { getParameter : 1, "ShardingTaskExecutorPoolReplicaSetMatching" : 1 } )
connPoolStats.acquisitionWaitTimes
New in version 6.3.6.3版新增。Document reports a histogram with the wait times for requests to acquire a connection fromDocument报告了一个直方图,其中包含请求获取从mongos
tomongod
:mongos
到mongod
的连接的等待时间:The document contains time ranges in milliseconds and the number of connection requests in each range.文档包含以毫秒为单位的时间范围以及每个范围内的连接请求数。-inf
is negative infinity and connection requests in the range为负无穷大,并且范围(-inf, 0ms)
did not wait.(-inf, 0ms)
内的连接请求没有等待。inf
is positive infinity and connection requests in the range是正无穷大,并且范围[1000ms, inf)
waited a time greater than or equal to 1,000 milliseconds.[1000ms, inf)
内的连接请求等待的时间大于或等于1000毫秒。totalCount
is the total number of connection requests for all time ranges.是所有时间范围的连接请求总数。
"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
-
Reports the number of active and stored outgoing synchronous connections from the current报告从当前mongod
/mongos
instance to other members of the sharded cluster or replica set.mongod
/mongos
实例到分片集群或副本集的其他成员的活动和存储的传出同步连接的数量。These connections are a part of a pool that is a subset of the data reported by这些连接是池的一部分,该池是totalAvailable
,totalCreated
, andtotalInUse
.totalAvailable
、totalCreated
和totalInUse
报告的数据的子集。
connPoolStats.numAScopedConnection
-
Reports the number of active and stored outgoing scoped synchronous connections from the current
mongod
/mongos
instance to other members of the sharded cluster or replica set.These connections are a part of a pool that is a subset of the data reported by这些连接是池的一部分,该池是totalAvailable
,totalCreated
, andtotalInUse
.totalAvailable
、totalCreated
和totalInUse
报告的数据的子集。
connPoolStats.pools
-
Reports on connection statistics (in use/available/created/refreshing) grouped by the connection pools. A按连接池分组的连接统计信息(正在使用/可用/已创建/正在刷新)的报告。mongod
ormongos
has two distinct families of outgoing connection pools:mongod
或mongos
有两个不同的传出连接池族:- DBClient-based pools (the "write path") and
- NetworkInterfaceTL-based pools (the "read path").
For each pool, the command returns a document that resembles the following:对于每个池,该命令返回一个类似于以下内容的文档:{
"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
},
...
}NoteIf there are no connections (in use/available/created/refreshing) for a particular pool, the如果某个特定池没有连接(正在使用/available/created/refreshing),则connPoolStats
does not return statistics for that pool.connPoolStats
不会返回该池的统计信息。connPoolStats.pools.NetworkInterfaceTL-TaskExecutorPool-[n]
-
Displays connection statics related to TaskExecutor pools.显示与TaskExecutor池相关的连接静态信息。Typically, there will be one TaskExecutorPool per core, e.g.pools.NetworkInterfaceTL-TaskExecutorPool-0
...pools.NetworkInterfaceTL-TaskExecutorPool-7
for an 8-core processor.TipSee also:另请参阅:
connPoolStats.pools.NetworkInterfaceTL-ShardRegistry
-
Available if the command is run on a member of a sharded cluster.
Displays the pool statistics for the connections between the current显示当前mongod
/mongos
instance and other members of the sharded cluster.mongod
/mongos
实例与分片集群的其他成员之间连接的池统计信息。
connPoolStats.pools.NetworkInterfaceTL-Replication
-
Available if the command is run on a member of a replica set.如果在复制副本集的成员上运行该命令,则该命令可用。Displays the pool statistics for the connections between the current显示当前mongod
instance and the other members of the replica set.mongod
实例与副本集的其他成员之间连接的池统计信息。
connPoolStats.pools.[pool].poolWasNeverUsed
-
Displays the number of connections in this connection pool that were closed having never been used.显示此连接池中已关闭但从未使用过的连接数。
connPoolStats.pools.[pool].acquisitionWaitTimes
New in version 6.3.6.3版新增。Reports the wait times for requests to acquire a connection from报告请求获取从mongos
tomongod
. For details, seeconnPoolStats.acquisitionWaitTimes
.mongos
到mongod
的连接的等待时间。有关详细信息,请参阅connPoolStats.acquisitionWaitTimes
。
connPoolStats.hosts
-
Reports on connection statistics (in use/available/created/refreshing) grouped by the hosts.按主机分组的连接统计信息(正在使用/可用/已创建/正在刷新)的报告。Contains documents that represent a report of connections between the current包含表示当前mongod
/mongos
instance and each member of the sharded cluster or replica set.mongod
/mongos
实例与分片集群或副本集的每个成员之间的连接报告的文档。connPoolStats.hosts.[host].available
-
Reports the total number of connections available for connecting to the报告可用于连接到[host]
.[host]
的连接总数。
connPoolStats.hosts.[host].leased
-
Reports the total number of connections to the host borrowed from a pool and expected to return. These connections might not remain active through the duration of a lease, and are excluded from the related metrics. These connections are unavailble through the duration of the lease.报告从池借用并预期返回的主机连接总数。这些连接可能在租赁期间不会保持活动状态,并且被排除在相关指标之外。这些连接在租赁期间是无效的。
connPoolStats.hosts.[host].created
-
Reports the number of connections to the报告已创建的与[host]
ever created.[host]
的连接数。
connPoolStats.hosts.[host].inUse
-
Reports the number of connections to the报告当前正在使用的到[host]
that are currently in use.[host]
的连接数。
connPoolStats.hosts.[host].wasNeverUsed
-
Reports the total number of outgoing connections from报告从host
to other members of the sharded cluster or replica set that were closed having never been used.host
到分片集群或副本集的其他成员的传出连接的总数,这些连接已关闭但从未使用过。
connPoolStats.hosts.[host].acquisitionWaitTimes
New in version 6.3.6.3版新增。Reports the wait times for requests to acquire a connection from报告请求获取从mongos
tomongod
. For details, seeconnPoolStats.acquisitionWaitTimes
.mongos
到mongod
的连接的等待时间。有关详细信息,请参阅connPoolStats.acquisitionWaitTimes
。
connPoolStats.replicaSets
-
Contains documents that represent a report of information related to each replica set connected to the current包含表示与连接到当前mongod
/mongos
.mongod
/mongos
的每个副本集相关的信息报告的文档。connPoolStats.replicaSets.replicaSet
-
Reports on each replica set connected to the current报告连接到当前mongod
/mongos
.mongod
/mongos
的每个副本集。
connPoolStats.replicaSets.[replicaSets].hosts
-
Holds an array of documents that reports on each member in the replica set.保存一组文档,这些文档报告副本集中的每个成员。These values derive from the replica set status values.这些值源自复制副本集状态值。connPoolStats.replicaSets.[replicaSet].hosts[n].addr
-
Reports the address for the member in the replica set in以[hostname]:[port]
format.[hostname]:[port]
格式报告副本集中成员的地址。
connPoolStats.replicaSets.[replicaSet].hosts[n].ok
-
Reports
false
when:- the current
mongos
ormongod
cannot connect to instance. - the current
mongos
ormongod
received a connection exception or error.
This field is for internal use.此字段仅供内部使用。 - the current
connPoolStats.replicaSets.[replicaSet].hosts[n].ismaster
-
Reports
true
if thishost
is the primary member of the replica set.
connPoolStats.replicaSets.[replicaSet].hosts[n].hidden
-
Reports
true
if thishost
is a hidden member of the replica set.
connPoolStats.replicaSets.[replicaSet].hosts[n].secondary
-
Reports
true
if thishost
is a secondary member of the replica set.
connPoolStats.replicaSets.[replicaSet].hosts[n].pingTimeMillis
-
Reports the ping time in milliseconds from the
mongos
ormongod
to thishost
.
connPoolStats.replicaSets.[replicaSet].hosts[n].tags
-
Reports the如果集合的此成员配置了标记,则报告members[n].tags
, if this member of the set has tags configured.members[n].tags
。
See also Response for details on the 有关ok
status field, the operationTime
field and the $clusterTime
field.ok
状态字段、operationTime
字段和$clusterTime
字段的详细信息,请参阅Response。