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参数中读取密钥。您现在可以访问备份快照并对其运行查询。
先决条件
在配置可查询备份之前,请完成以下任务:
为 Ops Manager 资源配置备份设置。在链接的过程中,请参阅配置备份的步骤。
步骤
将kubectl 配置为默认命名空间。
如果您尚未执行,请运行以下命令,执行所创建命名空间的所有 kubectl 命令。
注意
MongoDB Ops Manager如果要在多 Kubernetes 集群 部署中部署MongoDB 资源:
kubectl config set-context $(kubectl config current-context) --namespace=<metadata.namespace>
创建用于备份的 PEM 文件。
创建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.
创建包含 PEM 文件的密钥。
运行以下命令,使用上一步中创建的Queryable.pem文件创建密钥:
kubectl create secret generic queryable-pem --from-file=./queryable.pem
如果您使用 HashiCorp Vault 作为您的 Secret 存储工具,则可以创建 Vault Secret。
要了解有关 Secret 存储的选项,请参阅配置 Secret 存储。
配置 Ops Manager 自定义资源以使用密钥。
配置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
追踪已挂载卷和密钥的状态。
获取持久卷声明列表:
kubectl get pvc 获取密钥:
kubectl get secrets 检查你的 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).
要禁用可查询备份,请执行以下操作:
更新MongoDB Ops Manager自定义资源。
在MongoDBOpsManager自定义资源中,将spec.configuration.mms.featureFlag.backup.queryable和spec.configuration.mms.featureFlag.backup.wt.queryable设置为disabled 。
1 apiVersion: mongodb.com/v1 2 kind: MongoDBOpsManager 3 metadata: 4 name: opsmgr-resource 5 spec: 6 configuration: 7 mms.featureFlag.backup.wt.queryable: "disabled" 8 mms.featureFlag.backup.queryable: "disabled"
删除 PEM 文件
Navigate to the Queryable Snapshot Configuration section and delete the Proxy Server PEM File.