对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

配置 MongoDB 数据库备份

您可以使用 MongoDB 自定义资源,为 Kubernetes Operator 管理的 MongoDB 数据库配置持续自动化备份。

注意

如果您已在 MongoDB 数据库资源部署期间为 MongoDB 资源配置备份,则无需完成以下过程。

在配置 MongoDB 资源的备份之前,请参阅以下注意事项:

  • 如果您使用 Kubernetes Operator 设置分配标签,您在 Kubernetes 配置文件中为分配标签设置的值将覆盖 Ops Manager 用户界面中定义的值。您未使用 Kubernetes Operator 设置的分配标签继续使用 Ops Manager 用户界面中设置的值。

  • If you set a snapshot schedule field using the Kubernetes Operator, the value that you set in the Kubernetes configuration file for that field overrides the value defined in the Ops Manager UI. Snapshot schedule fields that you don't set using the Kubernetes Operator continue to use the value set in the Ops Manager UI.

    例子

    • 您在 Kubernetes 运算符中设置了 backup.snapshotSchedule.snapshotIntervalHours=6。

    • 您在用户界面中设置以下值:

      • Snapshot Inverval: 10

      • 快照保留天数:5

    Ops Manager uses the following values for your deployment:

    • Snapshot Inverval: 6

    • 快照保留天数:5

  • If you enable backups for your MongoDB database deployment using the Kubernetes Operator, but you don't set a snapshot schedule using the Kubernetes Operator, Ops Manager uses the snapshot schedule you set in the Ops Manager UI.

  • 如果您为 MongoDB 部署启用了备份,但根本没有设置快照计划,则 Ops Manager 会使用默认快照计划。

在为 MongoDB 资源配置持续备份之前,请完成以下任务:

1

将 spec.backup.mode 设置添加到 MongoDB 数据库部署的配置文件中,并将其值设置为 enabled,如以下副本集示例所示:

1---
2apiVersion: mongodb.com/v1
3kind: MongoDB
4metadata:
5 name: <my-replica-set>
6spec:
7 members: 3
8 version: "8.0.0"
9 type: ReplicaSet
10 opsManager:
11 configMapRef:
12 name: <my-project>
13 credentials: <my-credentials>
14 backup:
15 # Sets labels for the Backup Daemon.
16 assignmentLabels: ["test1", "test2"]
17 mode: enabled

要了解有关创建或编辑配置文件的更多信息,请参阅部署副本集或部署分片群集。

3

Add one or more spec.backup.assignmentLabels to the specification file for the deployment. Use assignment labels to identify that specific backup stores are associated with particular projects. Setting labels in Kubernetes Operator overrides labels that you set in Ops Manager. To learn more, see considerations.

请参阅本过程前面带有分配标签的规范文件示例。

4

运行以下命令检查备份状态:

kubectl get mdb <resource-name> -n <metadata.namespace> -o yaml

status.backup.statusname 字段指示备份的状态。成功配置备份后,状态将显示 STARTED。

给本页内容打分