getClusterParameter
定义
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 thedb.adminCommand( { command } )
method.getClusterParameter
命令仅在自托管安装中可用。getClusterParameter
命令在 MongoDB Atlas 中不可用。
兼容性
此命令可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
注意
所有 MongoDB Atlas 集群都支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.adminCommand( { getClusterParameter: <parameter> | [<parameter>, <parameter>] | "'*'" } )
命令字段
该命令接受以下字段:
字段 | 类型 | 说明 |
---|---|---|
| String or array of strings | You can specify one of the following:
|
行为
You can only run
getClusterParameter
on theadmin
database. If you run the command on any other database, MongoDB returns an error.You can run
getClusterParameter
on any node in a replica set or sharded cluster.When you run
getClusterParameter
onmongod
,getClusterParameter
returns cached parameter values.When you run
getClusterParameter
onmongos
,getClusterParameter
returns the 持久性 value of the cluster parameter from the config server.
访问控制
When 身份验证 is enabled, getClusterParameter
only works when authenticated as a user with a role that has access to the
getClusterParameter
action.
示例
注意
The output of the following examples may vary depending on the specific configuration of the running MongoDB deployment.
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
:
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:
use admin db.adminCommand( { getClusterParameter : '*' } )