getClusterParameter
定义
getClusterParameter
getClusterParameter
是一个用于检索 集群参数 的管理命令。集群参数是可配置参数,影响分片集群中的所有节点。要运行
getClusterParameter
,使用db.adminCommand( { command } )
方法。
兼容性
此命令在以下环境中托管的部署中可用
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
返回缓存的参数值。当您在
mongos
上运行getClusterParameter
时,getClusterParameter
返回来自 配置服务器 的集群参数的 持久 值。
访问控制
当启用了 身份验证 时,getClusterParameter
仅在作为具有访问 getClusterParameter
操作权限的用户进行身份验证时才有效。
MongoDB Atlas 用户必须具有 atlasAdmin
角色。
示例
注意
以下示例的输出可能因运行 MongoDB 部署的具体配置而异。
获取单个集群参数
以下操作在 admin
数据库上运行 getClusterParameter
,使用 hostName
的值来检索名为 hostName
的假设集群参数的值。
use admin db.adminCommand( { getClusterParameter : "hostName" } )
获取多个集群参数
以下操作在 admin
数据库上运行 getClusterParameter
,使用 hostName
和 testParameter
的值来检索名为 hostName
和 testParameter
的假设集群参数的值。
use admin db.adminCommand( { getClusterParameter: [ "hostName", "testParameter" ] } )
检索所有集群参数
以下操作运行 getClusterParameter
并以 '*'
的值来检索所有集群参数的值
use admin db.adminCommand( { getClusterParameter : '*' } )