Database Manual / Reference / Database Commands / Administration

setClusterParameter (database command数据库命令)

Definition定义

setClusterParameter

setClusterParameter is 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 setClusterParameter command against the admin database.您必须对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 setClusterParameter on the admin database. If you run the command on any other database, MongoDB returns an error.您只能在admin数据库上运行setClusterParameter。如果在任何其他数据库上运行该命令,MongoDB将返回错误。
  • You can only run setClusterParameter on a replica set primary or on a sharded cluster.您只能在副本集主集群或分片集群上运行setClusterParameter
  • You cannot run setClusterParameter on a standalone deployment.您不能在独立部署上运行setClusterParameter
  • setClusterParameter accepts 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 true, you cannot use setClusterParameter to modify cluster parameters.当使用apiStrict设置为trueStable API V1时,不能使用setClusterParameter修改集群参数。