您可以扩展或缩减副本集和分片集群部署,以匹配所需的配置。向上扩展会增加部署中节点和/或分片的数量,从而提高部署的冗余性和可用性。部署的扩展是在相应的自定义资源中配置的。
- 扩展副本集
- 要扩展副本集部署,设立
spec.members设置为所需的副本集点数。要学习;了解有关复制的更多信息,请参阅MongoDB手册中的复制。 - 扩展分片集群
要扩展分片集群部署,请根据需要进行以下设置:
设置说明每个分片的节点数。
分片路由器的数量。
配置服务器中的成员数。
Considerations
步骤
要扩展部署,请根据要扩展的部署配置选择所需的标签页:
1
将 spec.members 设置从 3 调整为 4:
apiVersion: mongodb.com/v1 kind: MongoDB metadata: name: <my-replica-set> spec: members: 3 version: "8.0.0" opsManager: configMapRef: # Must match metadata.name in ConfigMap file name: <configMap.metadata.name> credentials: <mycredentials> type: ReplicaSet persistent: true ...
spec: members: 4
1
将以下设置调整为所需的值:
apiVersion: mongodb.com/v1 kind: MongoDB metadata: name: <my-secure-sharded-cluster> spec: shardCount: 3 mongodsPerShardCount: 3 mongosCount: 3 configServerCount: 4 version: "8.0.0" opsManager: configMapRef: name: <configMap.metadata.name> credentials: <mycredentials> type: ShardedCluster persistent: true ...
spec: shardCount: 3 mongodsPerShardCount: 3 mongosCount: 3 configServerCount: 4