定义
getClusterParametergetClusterParameter是用于检索集群参数值的管理命令。 集群参数是可配置的参数,会影响分片分片集群中的所有节点。要运行
getClusterParameter,请使用db.adminCommand( { command } )方法。getClusterParameter命令仅在自托管安装中可用。getClusterParameter命令在 MongoDB Atlas 中不可用。
兼容性
此命令可用于以下环境中托管的部署:
MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
注意
所有 MongoDB Atlas 集群都支持此命令。有关 Atlas 对所有命令的支持的信息,请参阅不支持的命令。
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
该命令具有以下语法:
db.adminCommand( { getClusterParameter: <parameter> | [<parameter>, <parameter>] | "'*'" } )
命令字段
该命令接受以下字段:
字段 | 类型 | 说明 |
|---|---|---|
| 字符串或字符串数组 | 您可以指定以下其中一项:
|
行为
您只能在
admin数据库上运行getClusterParameter。 如果在任何其他数据库上运行该命令,MongoDB 都会返回错误。您可以在副本集或分片集群中的任何节点上运行
getClusterParameter。当您对
mongod运行getClusterParameter时,getClusterParameter会返回缓存的参数值。当您在 上运行 时, 会从
getClusterParametermongosgetClusterParameter配置服务器 返回集群参数的 持久 值。
访问控制
启用身份验证后, getClusterParameter仅当用户身份验证为具有有权访问getClusterParameter操作的角色时才起作用。
示例
注意
以下示例的输出可能会有所不同,具体取决于正在运行的 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 了解有关这些参数的更多信息。