getParameter

On this page本页内容

getParameter

getParameter is an administrative command for retrieving the values of parameters. 是用于检索参数值的管理命令。Use the db.adminCommand( { command } ) method to run the getParameter command in the admin database.使用db.adminCommand( { command } )方法在admin数据库中运行getParameter命令。

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

{
   getParameter: <value>,
   <parameter> : <value>,
   comment: <any>
}

The command takes the following fields:该命令接受以下字段:

Field字段Type类型Description描述
getParameterint, string, document

Specify a value of:指定值:

  • 1 (or any integer value) to return the value for the specified <parameter>.(或任何整数值)返回指定<parameter>的值。
  • '*' to return values for all parameters available to getParameter, ignoring the <parameter> field.返回getParameter可用的所有参数的值,忽略<parameter>字段。
  • { showDetails: true } to return a document containing:返回包含以下内容的文档:

    • value, the value that <parameter> is set tovalue<parameter>设置为的值
    • settableAtRuntime, whether or not <parameter> can be set at runtime,是否可以在运行时设置<parameter>
    • settableAtStartup, whether or not <parameter> can be set at startup,是否可以在启动时设置<parameter>
  • { showDetails: true, allParameters: true } to return a document containing showDetails fields for all parameters.返回包含所有参数的showDetails fields的文档。
<parameter>string

String name of the parameter to retrieve.要检索的参数的字符串名称。

The value for <value> does not affect output.<value>的值不会影响输出。

commentany

Optional. 可选。A user-provided comment to attach to this command. 用户提供了附加到此命令的注释。Once set, this comment appears alongside records of this command in the following locations:设置后,此注释将与此命令的记录一起显示在以下位置:

A comment can be any valid BSON type(string, integer, object, array, etc).注释可以是任何有效的BSON类型(字符串、整数、对象、数组等)。

New in version 4.4.在版本4.4中新增

Behavior行为

getParameter runs on the admin database only, and returns an error if run on any other database.getParameter仅在admin数据库上运行,如果在任何其他数据库上运行则返回错误。

The possible value for <parameter> may vary depending on what version and storage engine in use. <parameter>的可能值可能因使用的版本和存储引擎而异。See Retrieve All Parameters for an example of listing the available parameters.有关列出可用参数的示例,请参阅检索所有参数

Examples示例

Retrieve Single Parameter检索单个参数

The following operation runs getParameter on the admin database using a value of saslHostName to retrieve the value for that parameter:以下操作使用saslHostName值在admin数据库上运行getParameter,以检索该参数的值:

db.adminCommand( { getParameter : 1, "saslHostName" : 1 } )

The command returns the following output:该命令返回以下输出:

Note注意

The output may vary depending on the version and specific configuration of your MongoDB instance.输出可能因MongoDB实例的版本和特定配置而异。

{ "saslHostName" : "www.example.net:27018", "ok" : 1 }

Retrieve All Parameters检索所有参数

The following operation runs getParameter with a value of '*' to retrieve all parameters:以下操作运行值为'*'getParameter以检索所有参数:

db.adminCommand( { getParameter : '*' } )
Note注意

The output may vary depending on the version of MongoDB and the specific configuration of the running MongoDB instance.输出可能会因MongoDB的版本和正在运行的MongoDB实例的特定配置而异。

Tip提示
See also: 参阅:

setParameter for more about these parameters.有关这些参数的详细信息。

Report Details on a Single Parameter报告单个参数的详细信息

The following example runs getParameter with {showDetails: true} to report details on saslHostName.以下示例使用{showDetails: true}运行getParameter以报告saslHostName的详细信息。

db.adminCommand( { getParameter : { showDetails: true }, "saslHostName" : 1 } )

Example output:示例输出:

{
  saslHostName: {
    value: '<hostname>',
    settableAtRuntime: false,
    settableAtStartup: true
  },
  ok: 1
}
Note注意

The output may vary depending on the version and specific configuration of your MongoDB instance.输出可能因MongoDB实例的版本和特定配置而异。

Report Details for All Parameters所有参数的报告详细信息

The following example runs getParameter with {showDetails: true, allParameters: true} to report details on all parameters.以下示例使用{showDetails: true, allParameters: true}运行getParameter以报告所有参数的详细信息

db.adminCommand( { getParameter : { showDetails: true, allParameters: true } } )
←  getDefaultRWConcernkillCursors →