Definition定义
setClusterParametersetClusterParameteris an administrative command for modifying values of cluster parameters. Cluster parameters are configurable parameters which affect all nodes in a replica set or sharded cluster.是一个用于修改集群参数值的管理命令。集群参数是可配置的参数,会影响副本集或分片集群中的所有节点。You must issue the您必须对setClusterParametercommand against theadmindatabase.admin数据库发出setClusterParameter命令。
Compatibility兼容性
This command is available in deployments hosted in the following environments:此命令在以下环境中托管的部署中可用:
- MongoDB Enterprise
: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本 - MongoDB Community
: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本
Important
This command is not supported in MongoDB Atlas clusters. MongoDB Atlas集群不支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令。
Syntax语法
db.adminCommand(
{
setClusterParameter: { <parameter>: <value> }
}
)
For the available cluster parameters, including examples, see Cluster Parameters for a Self-Managed Deployment.有关可用的集群参数(包括示例),请参阅自我管理部署的集群参数。
Behavior行为
You can only run您只能在setClusterParameteron theadmindatabase. If you run the command on any other database, MongoDB returns an error.admin数据库上运行setClusterParameter。如果在任何其他数据库上运行该命令,MongoDB将返回错误。You can only run您只能在副本集主集群或分片集群上运行setClusterParameteron a replica set primary or on a sharded cluster.setClusterParameter。You cannot run您不能在独立部署上运行setClusterParameteron a standalone deployment.setClusterParameter。setClusterParameteraccepts only one parameter at a time.一次只接受一个参数。
Accesss Control访问控制
When authentication is enabled, 启用身份验证后,setClusterParameter only works when authenticated as a user with a role that has access to the setClusterParameter action.setClusterParameter仅在作为具有访问setClusterParameter操作的角色的用户进行身份验证时才有效。
Persistence坚持
The parameter modifications made using 使用setClusterParameter are persisted on replica sets and sharded clusters. This ensures that parameter modifications made using setClusterParameter survive restarts.setClusterParameter进行的参数修改将持久化在副本集和分片集群上。这确保了使用setClusterParameter进行的参数修改在重新启动后仍然有效。
Stable APIAPI稳定
When using Stable API V1 with apiStrict set to 当使用apiStrict设置为true, you cannot use setClusterParameter to modify cluster parameters.true的Stable API V1时,不能使用setClusterParameter修改集群参数。