On this page本页内容
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 the db.runCommand( { <command> } ) method.connPoolStats,请使用db.runCommand( { <command> } )方法。
connPoolStats only returns meaningful results for 只为mongos instances and for mongod instances in sharded clusters.mongos实例和分片集群中的mongod实例返回有意义的结果。
The command takes the following form:该命令采用以下形式:
db.runCommand( { "connPoolStats" : 1 } )
The value of the argument (i.e. 参数的值(即1 ) does not affect the output of the command.1)不会影响命令的输出。
connPoolStats includes aggregated statistics in its output:在其输出中包括汇总统计信息:
hosts field displays the information aggregated by host.hosts字段显示主机聚合的信息。pools 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和pools连接计数之间的细微差异。
The following operation uses the 以下操作使用db.runCommand() method to run the connPoolStats command on a mongos of a sharded cluster. db.runCommand()方法在分片集群的mongo上运行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>,
"totalCreated" : <num>,
"totalRefreshing" : <num>,
"replicaSetMatchingStrategy" : <string>,
"pools" : {
"NetworkInterfaceTL-TaskExecutorPool-0" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceTL-TaskExecutorPool-1" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceTL-TaskExecutorPool-2" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceTL-TaskExecutorPool-3" : {
"poolInUse" : <num>,
"poolAvailable" : <num>,
"poolCreated" : <num>,
"poolRefreshing" : <num>,
"cfg1.example.net:27019" : {
"inUse" : <num>,
"available" : <num>,
"created" : <num>,
"refreshing" :<num>
}
},
"NetworkInterfaceTL-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>
}
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.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.mongod/mongos实例到当前正在刷新的分片集群或副本集的其他成员的传出连接总数。
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 for mongos and mongod can be set with the ShardingTaskExecutorPoolReplicaSetMatching parameter.mongos和mongod的策略可以使用ShardingTaskExecutorPoolReplicaSetMatching参数设置。
If the 如果ShardingTaskExecutorPoolReplicaSetMatching is set to "automatic", the replicaSetMatchingStrategy still describes the actual policy being used, not "automatic". ShardingTaskExecutorPoolReplicaSetMatching设置为"automatic",则replicaSetMatchingStrategy仍然描述实际使用的策略,而不是“自动”。To find the value of the 要查找ShardingTaskExecutorPoolReplicaSetMatching, use getParameter which returns the value of the server parameter:ShardingTaskExecutorPoolReplicaSetMatching的值,请使用getParameter返回服务器参数的值:
db.adminCommand( { getParameter : 1, "ShardingTaskExecutorPoolReplicaSetMatching" : 1 } )
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, and totalInUse.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.mongod/mongos实例到分片集群或副本集其他成员的活动和存储的传出作用域同步连接数。
These connections are a part of a pool that is a subset of the data reported by 这些连接是池的一部分,池是totalAvailable, totalCreated, and totalInUse.totalAvailable、totalCreated和totalInUse报告的数据的子集。
connPoolStats.pools Reports on connection statistics (in use/available/created/refreshing) grouped by the connection pools. 按连接池分组的连接统计信息(使用中/可用/创建/刷新)报告。A mongod or mongos has two distinct families of outgoing connection pools:mongod或mongos有两个不同的输出连接池家族:
NetworkInterfaceTL的池(“读取路径”)。For each pool, the command returns a document that resembles the following:对于每个池,该命令返回一个类似于以下内容的文档:
{
"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> },
...
}
If there are no connections (in use/available/created/refreshing) for a particular pool, the 如果特定池没有连接(正在使用/可用/创建/刷新),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.TaskExecutiorPool,例如pools.NetworkInterfaceTL-TaskExecutorPool-0 ... pools.NetworkInterfaceTL-TaskExecutorPool-7用于8核处理器。
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.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.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:false:
mongos or mongod cannot connect to instance.mongos或mongod无法连接到实例。mongos or mongod received a connection exception or error.mongos或mongod收到连接异常或错误。This field is for internal use.此字段供内部使用。
connPoolStats.replicaSets.[replicaSet].hosts[n].ismaster Reports 如果此true if this host is the primary member of the replica set.host是副本集的主要成员,则报告为true。
connPoolStats.replicaSets.[replicaSet].hosts[n].hidden Reports 如果此true if this host is a hidden member of the replica set.host是副本集的隐藏成员,则报告为true。
connPoolStats.replicaSets.[replicaSet].hosts[n].secondary Reports 如果此true if this host is a secondary member of the replica set.host是副本集的secondary成员,则报告为true。
connPoolStats.replicaSets.[replicaSet].hosts[n].pingTimeMillis Reports the ping time in milliseconds from the 报告从mongos or mongod to this host.mongos或mongod到该host的ping时间(以毫秒为单位)。
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状态字段、ok status field, the operationTime field and the $clusterTime field.operationTime字段和$clusterTime字段的详细信息,请参阅Response。