定义
getClusterParametergetClusterParameteris an administrative command for retrieving the values of cluster parameters. Cluster parameters are configurable parameters that affect all nodes in a sharded cluster.要运行
getClusterParameter,请使用db.adminCommand( { command } )方法。
兼容性
此命令可用于以下环境中托管的部署:
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
注意
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.adminCommand( { getClusterParameter: <parameter> | [<parameter>, <parameter>] | "'*'" } )
命令字段
该命令接受以下字段:
字段 | 类型 | 说明 |
|---|---|---|
| 字符串或字符串数组 | 您可以指定以下其中一项:
|
行为
您只能在
admin数据库上运行getClusterParameter。 如果在任何其他数据库上运行该命令,MongoDB 都会返回错误。您可以在副本集或分片集群中的任何节点上运行
getClusterParameter。当您对
mongod运行getClusterParameter时,getClusterParameter会返回缓存的参数值。
访问控制
启用身份验证后, getClusterParameter仅当用户身份验证为具有有权访问getClusterParameter操作的角色时才起作用。
MongoDB Atlas用户必须具有atlasAdmin角色。
示例
注意
以下示例的输出可能会有所不同,具体取决于正在运行的 MongoDB 部署的具体配置。
检索单个集群参数
以下操作使用值hostName在admin数据库上运行getClusterParameter ,以检索名为hostName的假设集群参数的值:
use admin db.adminCommand( { getClusterParameter : "hostName" } )
检索多个集群参数
以下操作使用值hostName和testParameter在admin数据库上运行getClusterParameter ,以检索名为hostName和testParameter的假设集群参数的值:
use admin db.adminCommand( { getClusterParameter: [ "hostName", "testParameter" ] } )
检索所有集群参数
以下操作运行值为'*'的getClusterParameter ,以检索所有集群参数的值:
use admin db.adminCommand( { getClusterParameter : '*' } )
提示
setClusterParameter 了解有关这些参数的更多信息。