Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs 菜单
Docs 主页
/
部署数据库资源

为MongoDB资源配置存储选项

您可以在 MongoDB CustomResourceDefinition 中配置MongoDB资源以绑定到特定存储。The persistence 字段 in the MongoDB CustomResourceDefinition allows you to more precisely manage where Kubernetes 存储 the 日志 and 元数据 generated from MongoDB custom 资源.通过控制日志和元数据存储,可以更精细地控制管理生成的元数据并与之交互的进程。

您可以在MongoDB CustomResourceDefinition 中为每个组件配置持久性设置。这些设置允许您指定给定组件与一个或多个相关 PersistentVolume 资源之间的关系,这些资源存储MongoDB自定义资源的输出。

persistence设置指定与Kubernetes集群中MongoDB自定义资源托管对象关联的persistentVolumes的数量和存储容量。

要为MongoDB 部署配置存储选项,您必须通过MongoDB Kubernetes Operator 部署MongoDB副本集,或者满足以下先决条件:

  • 一个 MongoDB Ops Manager实例Cloud Manager组织。

  • Kubernetes Operator 的MongoDB控制器。

  • Kubernetes Operator ConfigMap。

  • Kubernetes Operator 的凭证,或配置其他密钥存储工具。

要创建单个PersistentVolume ,让给定组件在其中存储所有MongoDB CustomResourceDefinition 输出,请将该组件的persistence 定义为single 。要为组件的 datajournallogs 创建不同的 PersistentVolume,请将组件的 persistence 定义为 multiple

1

填充MongoDB CRD 定义的persistence部分,如以下示例所示:

1---
2apiVersion: mongodb.com/v1
3kind: MongoDB
4metadata:
5 name: my-sharded-cluster
6spec:
7 shardCount: 2
8 mongodsPerShardCount: 3
9 mongosCount: 2
10 configServerCount: 3
11 version: "8.0.0"
12 service: my-service
13 type: ShardedCluster
14
15 persistent: true
16
17 configSrvPodSpec:
18 persistence:
19 single: true
20
21 shardPodSpec:
22 persistence:
23 multiple:
24 # if the child of "multiple" is omitted then the default size will be used.
25 # 16GB for "data", 1GB for "journal", 3GB for "logs"
26 data:
27 storage: "20Gi"
28 storageClass: standard # You must define a storageClass, as the Operator creates a PVC, which will only create an associated PV with a backing storageClass.
29 logs:
30 storage: "4Gi"
31 storageClass: standard
32...
2
kubectl apply -f mongodb-crd.yaml

后退

配置拓扑

在此页面上