跨 EC2 实例移动 Postgres 表空间和表

发布于 2024-09-15 20:11:51 字数 569 浏览 5 评论 0原文

我有在 Amazon EC2 实例上运行的 postgres 数据库。我创建的表空间很少 一些每月表,这样每个表都位于单独的表空间上。为了获得最大性能,我在单独的 amazon ebs 卷上创建了每个表空间。

我想将其中一些表移动到不同的实例和数据库。我将用一个例子来解释它。 可以说。

  1. 我有 EC2 实例 A,如上文所述,采用了 postgres 设置。

  2. 我有另一个 Amazon 实例 B 正在运行,并且我也在其上安装了 postgres。

  3. 我想为 B 上 A 中的某些表创建相同的表结构。我想从实例 A 中分离卷并将其附加到实例 B。

  4. 此外,我想在实例 B 上创建表空间,该表空间将指向新附加的卷。

  5. 当我启动这个新创建的 postgres 时,我希望看到表中填充了这些卷(数据库)中的数据。

  6. 最后我将从 A 中删除这些表

我知道我的写作生疏,但找不到更好的方法来提出问题。

沿着这些思路的事情是可能的吗?有没有任何指示可以实现这样的目标?

I have postgres database running on Amazon EC2 instance. I have few tablespaces created for
some monthly tables, such that each table is on individual tablespace. To get the maximum performance, I have created each tablespace on individual amazon ebs volume.

I want to move some of this tables to different instance and database. I will explain it with one example.
Lets say.

  1. I have EC2 instance A with postgres setup as explained above.

  2. I have another Amazon instance B running and I installed postgres on it as well.

  3. I want to create the same table structure for some of the tables present in A on B. I want to detach the volumes from instance A and attach it to instance B.

  4. Also, I want to create tablespaces on instance B, which will point to the newly attached volumes.

  5. And when I start up this newly created postgres, I expect to see the tables populated with data from those volumes(database).

  6. finally I will delete those tables from A

I know I am being rusty in writing, but couldn't find a better way to ask the question.

Is something along these lines is possible? Are there any pointers for achieving something like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

⊕婉儿 2024-09-22 20:11:51

不,

表空间目录中的数据只是数据。您还需要 pg_catalog 架构中的表中的元数据,以及来自 pg_clog 和 pg_xlog 的信息来访问它。

如果您想使用卷来移动内容,则必须立即移动整个安装(所有表空间,包括 pg_default)。否则,你需要使用pg_dump/pg_restore来传输数据。

No.

The data in the tablespace directory is only the data. You also need the metadata that's in the tables in the pg_catalog schema, as well as the information from pg_clog and pg_xlog to access it.

If you want to move things across using volumes, you must move the entire installation at once (all the tablespaces, including pg_default). Otherwise, you need to use pg_dump/pg_restore to transfer the data over.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文