Database Manual / Reference / Database Commands / Administration

getClusterParameter (database command数据库命令)

Definition定义

getClusterParameter

getClusterParameter is an administrative command for retrieving the values of cluster parameters. Cluster parameters are configurable parameters that affect all nodes in a sharded cluster.是一个用于检索集群参数值的管理命令。集群参数是影响分片集群中所有节点的可配置参数。

To run getClusterParameter, use the db.adminCommand( { command } ) method.要运行getClusterParameter,请使用db.adminCommand( { command } )方法。

Compatibility兼容性

This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务

Note

This command is supported in all MongoDB Atlas clusters. 所有MongoDB Atlas集群都支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令

  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本
  • MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本

Syntax语法

The command has the following syntax:该命令具有以下语法:

db.adminCommand(
{
getClusterParameter: <parameter> | [<parameter>, <parameter>] | "'*'"
}
)

Command Fields命令字段

The command takes the following fields:该命令包含以下字段:

Field字段Type类型Description描述
<parameter>String or array of strings字符串或字符串数组

You can specify one of the following:您可以指定以下选项之一:

  • The name of the parameter you want to retrieve.要检索的参数的名称。
  • An array with the names of multiple parameters.具有多个参数名称的数组。
  • '*', to return values for all parameters available to getClusterParameter.,返回getClusterParameter可用的所有参数的值。

Behavior行为

  • You can only run getClusterParameter on the admin database. If you run the command on any other database, MongoDB returns an error.您只能在管理数据库上运行getClusterParameter。如果在任何其他数据库上运行该命令,MongoDB将返回错误。
  • You can run getClusterParameter on any node in a replica set or sharded cluster.您可以在副本集或分片集群中的任何节点上运行getClusterParameter
  • When you run getClusterParameter on mongod, getClusterParameter returns cached parameter values.
  • When you run getClusterParameter on mongos, getClusterParameter returns the durable value of the cluster parameter from the config server.

Access Control访问控制

When authentication is enabled, getClusterParameter only works when authenticated as a user with a role that has access to the getClusterParameter action.

MongoDB Atlas users must have the atlasAdmin role.MongoDB Atlas用户必须具有atlasAdmin角色。

Examples示例

Note

The output of the following examples may vary depending on the specific configuration of the running MongoDB deployment.以下示例的输出可能因正在运行的MongoDB部署的具体配置而异。

Retrieve Single Cluster Parameter检索单个集群参数

The following operation runs getClusterParameter on the admin database using a value of hostName to retrieve the value for a hypothetical cluster parameter named hostName:以下操作使用hostName的值在admin数据库上运行getClusterParameter,以检索名为hostName的假设集群参数的值:

use admin
db.adminCommand( { getClusterParameter : "hostName" } )

Retrieve Multiple Cluster Parameters检索多个群集参数

The following operation runs getClusterParameter on the admin database using the values hostName and testParameter to retrieve the values for hypothetical cluster parameters named hostName and testParameter:

use admin
db.adminCommand( { getClusterParameter: [ "hostName", "testParameter" ] } )

Retrieve All Cluster Parameters检索所有群集参数

The following operation runs getClusterParameter with a value of '*' to retrieve the values from all cluster parameters:以下操作运行值为'*'getClusterParameter,以从所有集群参数中检索值:

use admin
db.adminCommand( { getClusterParameter : '*' } )

Tip

setClusterParameter for more about these parameters.有关这些参数的更多信息。