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

为 Ops Manager 资源配置可查询备份

You can configure queryable backups for Ops Manager resources that you deploy in the Kubernetes Operator.

注意

在 Ops Manager 文档中,可查询备份也称为可查询快照或可查询恢复。

可查询备份允许您对 资源中的特定备份快照 运行查询MongoDB Ops Manager 。查询MongoDB Ops Manager备份可帮助您比较不同快照中的数据,并确定用于恢复数据的最佳快照。

在以下过程中,您将:

  • Create the queryable.pem file that holds the certificates for accessing the backup snapshots that you intend to query.

  • Create the secret containing the queryable.pem file.

  • 配置 Ops Manager 自定义资源以使用密钥进行可查询备份。

  • 保存并应用 Ops Manager 自定义资源配置。

一旦 Kubernetes 操作符为其自定义资源部署更新后的配置,Ops Manager 就可以从spec.backup.queryableBackupSecretRef.name参数中读取密钥。您现在可以访问备份快照并对其运行查询。

在配置可查询备份之前,请完成以下任务:

1

如果您尚未执行,请运行以下命令,执行所创建命名空间的所有 kubectl 命令。

注意

MongoDB Ops Manager如果要在多 Kubernetes 集群 部署中部署MongoDB 资源:

  • 将 context 设置为中心集群的名称,例如:kubectl config set context "$MDB_CENTRAL_CLUSTER_FULL_NAME"。

  • 将--namespace设置为您用于多 Kubernetes 集群 MongoDB 部署的相同范围,例如: kubectl config --namespace "mongodb" 。

kubectl config set-context $(kubectl config current-context) --namespace=<metadata.namespace>
2

创建MongoDB Ops Manager queryable.pem文件,根据部署的TLS要求,使用该文件访问和查询备份。 PEM 文件包含公钥证书及其关联的私钥,在MongoDB Ops Manager中访问和运行备份快照时需要这些证书。

To learn more about the PEM file's requirements, see Authorization and Authentication Requirements in Ops Manager.

3

运行以下命令,使用上一步中创建的Queryable.pem文件创建密钥:

kubectl create secret generic queryable-pem --from-file=./queryable.pem

如果您使用 HashiCorp Vault 作为您的 Secret 存储工具,则可以创建 Vault Secret。

要了解有关 Secret 存储的选项,请参阅配置 Secret 存储。

4

配置spec.backup.queryableBackupSecretRef.name以引用queryable.pem密钥。

1 apiVersion: mongodb.com/v1
2 kind: MongoDBOpsManager
3 metadata:
4 name: ops-manager
5 spec:
6 replicas: 1
7 version: 8.0.0
8 adminCredentials: ops-manager-admin-secret
9 backup:
10 enabled: true
11 queryableBackupSecretRef:
12 name: om-queryable-pem
5
6

对 Ops Manager 资源定义的文件名调用以下kubectl命令:

kubectl apply -f <opsmgr-resource>.yaml

当您将更改应用于 Ops Manager 资源定义时,Kubernetes 会更新 Ops Manager StatefulSet、创建卷并挂载密钥。

7
  1. 获取持久卷声明列表:

    kubectl get pvc
  2. 获取密钥:

    kubectl get secrets
  3. 检查你的 Ops Manager 资源的状态:

    kubectl get om <resource-name> -o yaml -w

    -w标志的意思是“观看”。 设置“watch”标志后,输出会在配置更改时立即刷新,直到状态阶段达到Running状态。

    要了解有关资源部署状态的更多信息,请参阅Kubernetes 操作符故障排除。

配置可查询备份后,您可以对其进行查询以选择用于恢复数据的最佳备份快照。

If you require all containers in your MongoDB deployment to be fully static, disable queryable backups as a best practice. This is so the Backup Daemon Service doesn't attempt to download the MongoDB binaries from Ops Manager. Downloading binaries undermines the immutable nature of static containers and is only possible with non-static containers. To learn more, see Static Containers (Public Preview).

要禁用可查询备份,请执行以下操作:

1

在MongoDBOpsManager自定义资源中,将spec.configuration.mms.featureFlag.backup.queryable和spec.configuration.mms.featureFlag.backup.wt.queryable设置为disabled 。

1apiVersion: mongodb.com/v1
2kind: MongoDBOpsManager
3metadata:
4 name: opsmgr-resource
5spec:
6 configuration:
7 mms.featureFlag.backup.wt.queryable: "disabled"
8 mms.featureFlag.backup.queryable: "disabled"
2
3

对 Ops Manager 资源定义的文件名调用以下kubectl命令:

kubectl apply -f <opsmgr-resource>.yaml
4

在MongoDB Ops Manager用户界面中,单击右上角的 Admin。 在Admin屏幕中,单击General Ops Manager Config Backup 。

5

Navigate to the Queryable Snapshot Configuration section and delete the Proxy Server PEM File.

6