您可以使用 MongoDB 自定义资源,为 Kubernetes Operator 管理的 MongoDB 数据库配置持续自动化备份。
注意
如果您已在 MongoDB 数据库资源部署期间为 MongoDB 资源配置备份,则无需完成以下过程。
Considerations
在配置 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 资源配置持续备份之前,请完成以下任务:
为 Ops Manager 资源配置备份。在链接的过程中,请参阅配置备份的步骤。MongoDB 数据库持续备份要求您将 Ops Manager 资源规范中的
spec.backup.enabled值设置为true。
步骤
为 MongoDB 数据库部署启用备份。
将 spec.backup.mode 设置添加到 MongoDB 数据库部署的配置文件中,并将其值设置为 enabled,如以下副本集示例所示:
1 2 apiVersion: mongodb.com/v1 3 kind: MongoDB 4 metadata: 5 name: <my-replica-set> 6 spec: 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
可选:设置快照计划。
Add any of the following snapshot schedule settings to the specification file for the deployment. To learn how Ops Manager determines the snapshot schedule if you don't set a snapshot schedule field using the Kubernetes Operator,] see the considerations.
可选:设置备份分配标签。
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.
请参阅本过程前面带有分配标签的规范文件示例。