发送反馈
在 Cloud Storage 中安排备份
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您当前正在查看 Apigee Hybrid 文档的 1.12 版本。 This version is end of life. You should upgrade to a
newer version. 如需了解详情,请参阅支持的版本 。
Version 1.12 keyboard_arrow_down
警告: 1.12.4 之前的 Apigee Hybrid 版本存在已知问题 ,会影响使用 HYBRID
或 GCP
云服务提供商的备份。请参阅 Cassandra 问题排查指南 ,查看您的设置是否受到影响以及解决问题所需的步骤。
本页面介绍了如何在 Cloud Storage 中为 Cassandra 安排备份。
通过此方法,备份会存储在指定的 Cloud Storage 存储桶中。
注意 :在现有集群上应用备份配置后,Cassandra pod 将从最后一个到第一个依次重启(滚动重启)。
如需计划 Cassandra 备份,请执行以下步骤:
运行以下 create-service-account
命令以创建具有标准 roles/storage.objectAdmin
角色的 Google Cloud 服务账号 (SA)。此 SA 角色允许您将备份数据写入 Cloud Storage。在 $APIGEE_HELM_CHARTS_HOME /apigee-operator/etc/
目录中执行该命令。
./tools/create-service-account --env non-prod --dir ./
此命令会创建一个名为 apigee-non-prod
的服务账号,以用于非生产环境,并将下载的密钥文件放在 ./
目录中。
注意: 如果您希望为生产环境创建所有单独的服务账号,请使用以下命令:
./tools/create-service-account --env prod --dir ./
然后,将每个服务账号移至其对应的图表目录。下表列出了每个服务账号和对应的 Apigee Hybrid Helm 图表:
服务账号
Apigee Helm 图表
apigee-cassandra
apigee-datastore
apigee-logger
apigee-telemetry
apigee-mart
apigee-org
apigee-metrics
apigee-telemetry
apigee-runtime
apigee-env
apigee-synchronizer
apigee-env
apigee-udca
apigee-org
apigee-watcher
apigee-org
如需详细了解 Google Cloud 服务账号,请参阅创建和管理服务账号 。
create-service-account
命令会保存包含服务账号私钥的 JSON 文件。该文件会保存在执行命令的目录中。执行以下步骤将需要此文件的路径。
创建 Cloud Storage 存储桶 。
为存储桶指定合理的数据保留政策 。Apigee 建议采用 15 天的数据保留政策。
打开您的 overrides.yaml
文件。
添加以下 cassandra.backup
属性以启用备份。请勿移除任何已配置的属性。
参数
cassandra:
...
backup:
enabled: true
serviceAccountPath: SA_JSON_FILE_PATH
dbStorageBucket: CLOUD_STORAGE_BUCKET_PATH
schedule: BACKUP_SCHEDULE_CODE
cloudProvider: "GCP" # required verbatim "GCP" (all caps)
...
示例
...
cassandra :
storage :
type : gcepd
capacity : 50 Gi
gcepd :
replicationType : regional - pd
auth :
default :
password : "abc123"
admin :
password : "abc234"
ddl :
password : "abc345"
dml :
password : "abc456"
nodeSelector :
key : cloud . google . com / gke - nodepool
value : apigee - data
backup :
enabled : true
serviceAccountPath : "/Users/myhome/.ssh/my-cassandra-backup-sa.json"
dbStorageBucket : "gs://myname-cassandra-backup"
schedule : "45 23 * * 6"
cloudProvider : "GCP"
...
其中:
属性
说明
backup:enabled
备份默认处于停用状态。您必须将此属性设为 true
。
backup:serviceAccountPath
SA_JSON_FILE_PATH
文件系统上指向在运行 create-service-account
命令时下载的服务账号 JSON 文件的路径。
该路径必须相对于 apigee-datastore 图表目录。例如 serviceAccountPath: myproject-apigee-cassandra.json
。
backup:dbStorageBucket
CLOUD_STORAGE_BUCKET_PATH
Cloud Storage 存储桶路径,格式如下:gs://BUCKET_NAME
。
gs://
是必需的。
backup:cloudProvider
GCP
对于到 Cloud Storage 的备份,请将此属性设置为 GCP
。
backup:schedule
BACKUP_SCHEDULE_CODE
备份的开始时间,使用标准 crontab 语法 指定。默认值:0 2 * * *
注意 :请避免将备份安排在将备份配置应用于集群后很短时间内开始。应用备份配置时,Kubernetes 会重新创建 Cassandra 节点。如果备份在节点重启之前启动,则第一个备份将失败,后续备份将成功。
将配置更改应用到新集群。例如:
helm upgrade datastore apigee-datastore/ \
--namespace APIGEE_NAMESPACE \
--atomic \
-f OVERRIDES_FILE .yaml
注意: 如果您看到错误消息提示 Error: UPGRADE FAILED: "datastore" has no deployed releases
,请将 upgrade
替换为 install
,然后重试该命令。
其中,OVERRIDES_FILE 是您刚刚修改的替换文件的路径。
验证备份作业。例如:
kubectl get cronjob -n APIGEE_NAMESPACE
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
apigee - cassandra - backup 33 * * * * False 0 <none > 94 s
启动手动备份
备份作业会根据 overrides.yaml
文件的 cassandra.backup.schedule 中设置的 Cron 时间表自动触发。不过,如果需要,您也可以使用以下命令手动启动备份作业:
kubectl create job -n APIGEE_NAMESPACE --from=cronjob/apigee-cassandra-backup MANUAL_BACKUP_JOB_NAME
其中 MANUAL_BACKUP_JOB_NAME 是要创建的手动备份作业名称。
发送反馈
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可 获得了许可,并且代码示例已根据 Apache 2.0 许可 获得了许可。有关详情,请参阅 Google 开发者网站政策 。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-10。
需要向我们提供更多信息?
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-10。"],[[["This guide explains how to schedule Cassandra backups to Cloud Storage for Apigee Hybrid."],["A Google Cloud service account with the `roles/storage.objectAdmin` role is required to write backup data to a designated Cloud Storage bucket."],["The `overrides.yaml` file must be updated to enable backups, specifying the service account path, Cloud Storage bucket, backup schedule, and `GCP` as the cloud provider."],["Applying the backup configuration will trigger a rolling restart of Cassandra pods, and it's important to avoid scheduling the initial backup immediately afterward to prevent failure."],["Backups can be initiated manually using a `kubectl` command, or they will automatically run according to the defined cron schedule in the `overrides.yaml` file."]]],[]]