外部数据库(Postgres)
我们的数据库服务 Postgres 默认随 OpenReplay 一起安装,并在你的实例上的专用容器中运行,以降低部署成本。如果你需要更强的可扩展性或更简便的运维,你仍然可以使用外部 Postgres(即 AWS RDS 或 GCP Cloud SQL)。
导出现有的架构和数据
Section titled 导出现有的架构和数据注意: 如果你是全新开始且尚未安装 OpenReplay,那么只需继续进行安装设置,并忽略以下步骤。
现在必须将本地架构和已记录的数据导出到外部 Postgres:
- 首先,备份本地数据库:
kubectl exec -n db postgresql-0 -- bash -c 'PGPASSWORD=<postgresPassword from vars.yaml> pg_dumpall -U postgres ' > ~/path/to/dump.sql
- 在你的 OpenReplay 实例上安装 Postgres 客户端,并确保它能够访问外部数据库:
sudo apt install postgresql-client
- 将备份还原到新的 externalPostgres:
PGPASSWORD=PG_PASSWORD psql -U PG_USERNAME -h {RDS_URL} -d postgres < /path/to/dump.sql
- 最后,更新
openreplay -e中的所有postgres变量,并将它们指向外部数据库:
postgresqlPassword: "changeMePassword"
postgresqlHost: "postgresql.db.svc.cluster.local"
postgresqlPort: "5432"
postgresqlUser: "postgres"
postgresqlDatabase: "postgres"
- 使用
:wq保存并退出,使更改生效