Timescale Cloud:性能、可伸缩性、企业级
自托管产品
MST
您可以将数据从自托管 Timescale 迁移到 Managed Service for TimescaleDB,并自动完成大部分常见的操作任务。
Managed Service for TimescaleDB 会创建一个名为 defaultdb
的数据库和一个名为 tsdbadmin
的默认用户账户。您可以使用 Web 控制台,通过“用户”和“数据库”选项卡创建其他用户和数据库。
您可以在 Managed Service for TimescaleDB 中切换不同的套餐大小。但是,在导出过程中,请选择一个存储大小与当前分配套餐相同或略大的套餐。这可以限制迁移过程中的停机时间,并确保您拥有足够强大的 Timescale 套餐。
警告
根据您的数据库大小和网络速度,迁移可能需要很长时间。在此期间,导出过程中发生的任何新写入都不会包含在内。为防止数据丢失,请在开始导出过程之前关闭对旧数据库服务器的所有写入操作。尝试作为冷运行迁移,即不关闭原服务器上的写入,并同时运行导出。这可以为您估算导出过程所需的时间。这也有助于您在不影响客户停机的情况下练习实际操作。
请确保您已
- 安装了 PostgreSQL
pg_dump
和
pg_restore
工具。
- 安装了用于连接 PostgreSQL 的客户端。这些说明使用
psql
,但任何客户端都可以。 - 在 Managed Service for TimescaleDB 中创建了一个新的空数据库。有关更多信息,请参阅安装 Managed Service for TimescaleDB。为您的数据库预留足够空间以存储所有数据。
- 检查您在 Managed Service for TimescaleDB 和源数据库上运行的是相同的主版本 PostgreSQL。有关升级 PostgreSQL 的信息,请参阅自托管 TimescaleDB 的升级说明和 Managed Service for TimescaleDB
。
- 检查您在 Managed Service for TimescaleDB 和源数据库上运行的是相同的主版本 TimescaleDB。有关更多信息,请参阅Timescale 升级部分。
注意
为了加快迁移速度,请将数据压缩到列存中。您可以压缩当前未插入、更新或删除数据的任何数据块。迁移完成后,您可以根据正常运行需要将数据块解压缩回行存。有关行存和列存压缩的更多信息,请参阅 hypercore。
使用源数据库连接详情,将源数据库中的所有数据导出到
dump.bak
文件中。如果提示输入密码,请使用您的源数据库凭据;为避免权限错误,请包含--no-owner
标志pg_dump -U <SOURCE_DB_USERNAME> -W \-h <SOURCE_DB_HOST> -p <SOURCE_DB_PORT> --no-owner -Fc -v \-f dump.bak <SOURCE_DB_NAME>在命令行提示符下,使用 Managed Service for TimescaleDB 连接详情,将
dump.bak
文件中的导出数据恢复到您的 Managed Service for TimescaleDB 数据库中。要从多个数据库进行迁移,请重复一个接一个地导出或加载数据库的过程。--jobs
选项指定用于并发导出和恢复数据库的 CPU 数量。pg_restore -d 'postgres://CLICK_TO:REVEAL_PASSWORD@demo.demoproject.timescaledb.io:19335/defaultdb?sslmode=require' --jobs 4 dump.bak连接到新数据库,并在整个数据集上运行
ANALYZE
以更新表统计信息
psql 'postgres://CLICK_TO:REVEAL_PASSWORD@demo.demoproject.timescaledb.io:19335/defaultdb?sslmode=require'defaultdb=> ANALYZE;
如果在迁移过程中看到这些错误,您可以安全地忽略它们。迁移仍会成功完成。
使用
pg_dump
时的错误pg_dump: warning: there are circular foreign-key constraints on this table:pg_dump: hypertablepg_dump: You might not be able to restore the dump without using --disable-triggers or temporarily dropping the constraints.pg_dump: Consider using a full dump instead of a --data-only dump to avoid this problem.pg_dump: NOTICE: hypertable data are in the chunks, no data will be copiedDETAIL: Data for hypertables are stored in the chunks of a hypertable so COPY TO of a hypertable will not copy any data.HINT: Use "COPY (SELECT * FROM <hypertable>) TO ..." to copy all data in hypertable, or copy each chunk individually.使用
pg_restore
时的错误pg_restore: while PROCESSING TOC:pg_restore: from TOC entry 4142; 0 0 COMMENT EXTENSION timescaledbpg_restore: error: could not execute query: ERROR: must be owner of extension timescaledbCommand was: COMMENT ON EXTENSION timescaledb IS 'Enables scalable inserts and complex queries for time-series data';
关键词
此页面有问题?报告问题 或 在 GitHub 中编辑此页面
。