“文档” 菜单
文档首页
/
MongoDB Manual
/ / /

connPoolStats

在此页面上

  • 定义
  • 语法
  • 行为
  • 例子
  • 输出
connPoolStats

connPoolStats命令返回有关从当前数据库实例到分片集群副本集其他成员的打开传出连接的信息。

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

注意

connPoolStats仅对分片集群中的mongos实例和mongod实例返回有意义的结果。

该命令具有以下语法:

db.runCommand(
{
connPoolStats: 1
}
)

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

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

  • hosts字段显示按主机聚合的信息。

  • pools字段显示按池聚合的信息。

注意

为避免干扰任何运行操作,connPoolStats 不采用任何锁。因此,随着 connPoolStats 收集信息,计数可能会略有变化,导致 hostspools 的连接计数略有不同。

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

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

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

注意

connPoolStats输出会有所不同,具体取决于部署以及运行connPoolStats所针对的成员等因素。

{
"numClientConnections" : <num>,
"numAScopedConnections" : <num>,
"totalInUse" : <num>,
"totalAvailable" : <num>,
"totalLeased" : <num>,
"totalCreated" : <num>,
"totalRefreshing" : <num>,
"replicaSetMatchingStrategy" : <string>,
"pools" : {
"NetworkInterfaceTL-TaskExecutorPool-0" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceTL-TaskExecutorPool-1" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceTL-TaskExecutorPool-2" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceTL-TaskExecutorPool-3" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceTL-ShardRegistry" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg2.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg3.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard1.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard2.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"global" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg3.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg2.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard2.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard1.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
}
}
},
"hosts" : {
"cfg3.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"cfg2.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard2.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <num>,
"created" : <num>,
"refreshing" :<num>
},
"shard1.example.net:27018" : {
"inUse" : <num>,
"available" : <num>,
"leased" : <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>
}
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参数设置针对 和 的策略。

注意

如果ShardingTaskExecutorPoolReplicaSetMatching设置为"automatic" ,则replicaSetMatchingStrategy仍然描述实际使用的策略,而不是"automatic" 。要查找ShardingTaskExecutorPoolReplicaSetMatching的值,请使用getParameter返回服务器参数的值:

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

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

这些连接是 totalAvailabletotalCreatedtotalInUse 报告的数据子集池的一部分。

connPoolStats.numAScopedConnection

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

这些连接是 totalAvailabletotalCreatedtotalInUse 报告的数据子集池的一部分。

connPoolStats.pools

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

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

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

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

{
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolLeased" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"[host1]" : { "inUse" : <num>, "available" : <num>, "leased" : <num>, "created" : <num>, "refreshing" : <num> },
"[host2]" : { "inUse" : <num>, "available" : <num>, "leased" : <num>, "created" : <num>, "refreshing" : <num> },
...
}

注意

如果某个数据池没有连接(使用中/可用/已创建/正刷新),connPoolStats 不会返回该数据池的统计数据。

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.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.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

true如果此host 副本集 主要 成员,则报告 。

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

如果此 host副本集隐藏节点,则报告 true

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

如果此 host副本集节点,则报告 true

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

报告从mongosmongod到此host的 ping 时间(以毫秒为单位)。

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

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

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

host

← collStats