On this page
connPoolStats
在本页面
Definition
connPoolStats
- 命令connPoolStats返回有关从当前数据库实例到sharded cluster或replica set的其他成员的打开的传出连接的信息。
要运行connPoolStats
,请使用db.runCommand( { <command> })方法。
Note
connPoolStats仅针对分片群集中的mongos实例和mongod实例返回有意义的结果。
该命令采用以下形式:
db.runCommand( { "connPoolStats" : 1 } )
参数的值(即1
)不会影响命令的输出。
Behavior
connPoolStats在其输出中包括汇总的统计信息:
Note
为避免干扰任何正在运行的操作,connPoolStats不进行任何锁定。因此,随着connPoolStats收集信息,计数可能会略有变化,从而导致hosts和pools连接计数之间略有差异。
Example
以下操作使用db.runCommand()方法在分片群集的mongos上运行connPoolStats命令。分片群集具有 2 个分片,每个分片都是一个单成员副本集和一个配置服务器副本集。 mongos在四核计算机上运行。
db.runCommand( { "connPoolStats" : 1 } )
该命令返回以下形式的输出:
Note
connPoolStats输出取决于部署和您要针对其运行connPoolStats的成员以及其他因素。
{
"numClientConnections" : <num>,
"numAScopedConnections" : <num>,
"totalInUse" : <num>,
"totalAvailable" : <num>,
"totalCreated" : <num>,
"totalRefreshing" : <num>,
"pools" : {
"NetworkInterfaceASIO-TaskExecutorPool-0" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceASIO-TaskExecutorPool-1" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceASIO-TaskExecutorPool-2" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceASIO-TaskExecutorPool-3" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceASIO-ShardRegistry" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg2.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg3.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard1.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard2.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"global" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg3.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg2.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard2.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard1.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
}
},
"hosts" : {
"cfg3.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg2.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard2.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard1.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"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
- 报告从当前mongod/mongos实例到sharded cluster或replica set的其他成员的可用传出连接总数。
connPoolStats.
totalCreated
- 报告当前mongod/mongos实例向sharded cluster或replica set的其他成员创建的传出连接总数。
connPoolStats.
totalInUse
- 报告从当前mongod/mongos实例到当前正在使用的sharded cluster或replica set其他成员的传出连接总数。
connPoolStats.
totalRefreshing
- 报告从当前mongod/mongos实例到sharded cluster或replica set当前正在刷新的其他成员的传出连接总数。
connPoolStats.
numClientConnection
- 报告从当前mongod/mongos实例到sharded cluster或replica set的其他成员的活动的和已存储的传出“同步”连接数。
这些连接是池的一部分,该池是totalAvailable,totalCreated和totalInUse报告的数据的子集。
connPoolStats.
numAScopedConnection
- 报告从当前mongod/mongos实例到sharded cluster或replica set的其他成员的活动和存储的传出“作用域同步”连接的数量。
这些连接是池的一部分,该池是totalAvailable,totalCreated和totalInUse报告的数据的子集。
connPoolStats.
pools
基于 DBClient 的池(“写路径”)和
基于 NetworkInterfaceASIO 的池(“读取路径”)。
对于每个池,该命令将返回类似于以下内容的文档:
{
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"[host1]" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" : <num> },
"[host2]" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" : <num> },
...
}
Note
如果特定池没有任何连接(正在使用/可用/已创建/刷新),则connPoolStats不会返回该池的统计信息。
connPoolStats.pools.
NetworkInterfaceASIO-TaskExecutorPool-[n]
- 显示与 TaskExecutor 池相关的连接静态信息。通常,每个核心只有一个 TaskExecutorPool,例如
NetworkInterfaceASIO-TaskExecutorPool-0
…NetworkInterfaceASIO-TaskExecutorPool-7
(用于 8 核处理器)。
- 显示与 TaskExecutor 池相关的连接静态信息。通常,每个核心只有一个 TaskExecutorPool,例如
See also
connPoolStats.pools.
NetworkInterfaceASIO-ShardRegistry
- *如果命令在分片群集的成员上运行,则可用。
显示当前mongod/mongos实例与分片群集的其他成员之间的连接的池统计信息。
connPoolStats.pools.
NetworkInterfaceASIO-Replication
- 如果命令在副本集的成员上运行,则可用.
显示当前mongod实例与副本集的其他成员之间的连接的池统计信息。
connPoolStats.pools.
global
- 显示基于 DBClient 的池统计信息。
connPoolStats.
hosts
- 报告按主机分组的连接统计信息(正在使用/可用/已创建/刷新)。
包含documents,代表当前mongod/mongos实例与sharded cluster或replica set的每个成员之间的连接报告。
connPoolStats.hosts.[host].
available
- 报告可用于连接到
[host]
的连接总数。
- 报告可用于连接到
connPoolStats.hosts.[host].
created
- 报告与曾经创建的
[host]
的连接数。
- 报告与曾经创建的
connPoolStats.hosts.[host].
inUse
- 报告当前正在使用的与
[host]
的连接数。
- 报告当前正在使用的与
connPoolStats.
replicaSets
connPoolStats.replicaSets.
replicaSet
- 有关连接到当前mongod/mongos的每个replica set的报告。
connPoolStats.replicaSets.[replicaSets].
hosts
- 包含一个documents数组,该数组报告replica set中的每个成员。
这些值来自副本集状态值。
connPoolStats.replicaSets.[replicaSet].hosts[n].
addr
-以[hostname]:[port]
格式报告replica set成员的地址。connPoolStats.replicaSets.[replicaSet].hosts[n].
ok
-在以下情况下报告false
:
此字段仅供内部使用。
connPoolStats.replicaSets.[replicaSet].hosts[n].
ismaster
-如果此host
是replica set的primary成员,则报告true
。connPoolStats.replicaSets.[replicaSet].hosts[n].
secondary
-如果此host
是replica set的secondary成员,则报告true
。connPoolStats.replicaSets.[replicaSet].hosts[n].
pingTimeMillis
-报告从mongos或mongod到此host
的 ping 时间(以毫秒为单位)。
另请参见Response,以获取有关ok
状态字段,operationTime
字段和$clusterTime
字段的详细信息。