简体   繁体   English

如何将Postgres DB从一个Kubernetes集群迁移到另一个集群

[英]How to move Postgres DB from one Kubernetes cluster to another

I have a big (300Gb) Postgres DB running on GKE cluster (Stateful Set, SSD Volume). 我在GKE群集(状态集,SSD卷)上运行着一个大型(300Gb)Postgres数据库。 I need to move this DB to another GKE cluster. 我需要将此数据库移至另一个GKE群集。

What is the easiest way to accomplish it? 最简单的方法是什么?

I tried to do it with piping pg_dump / pg_restore , but it takes forever and for some reason, not all constraints/triggers were recreated. 我试图用管道pg_dump / pg_restore做到这一点,但是它要花很多时间,并且由于某种原因,并不是所有约束/触发都被重新创建了。

Is there any proper way to gracefully "shutdown" Postgres server running in Kubernetes and copy the /pgdata folder directly (from one volume to another)? 有什么适当的方法来正常地“关闭”在Kubernetes中运行的Postgres服务器并直接将/pgdata文件夹复制(从一个卷复制到另一个卷)?

Other ideas? 还有其他想法吗? tnx n

I got few ideas (listed from the most probable to the least) about how you could approach this: 我对如何处理此问题几乎没有想法(从最可能到最少列出):

  1. Remember to use proper format when using pg_dump . 在使用pg_dump时,请记住使用正确的格式。 Default plain format may not work properly with pg_restore . 默认的纯格式可能无法与pg_restore一起正常工作。 Try to specify different format with pg_dump or use psql -f xxx.tar instead of pg_restore . 尝试使用pg_dump指定其他格式,或使用psql -f xxx.tar而不是pg_restore Remember that it might take a while. 请记住,这可能需要一段时间。

  2. You can use a tool to assist you with that. 您可以使用工具来协助您。 For example pghoard . 例如pghoard

  3. You can make a tared backup of you DB and try to copy as a object via Google Cloud Storage. 您可以对数据库进行皮重备份,然后尝试通过Google Cloud Storage作为对象复制。

  4. You can try to create PVCs manually, attach pods to those PVCs and than copy your dataset onto those pods. 您可以尝试手动创建PVC,将容器附加到这些PVC,然后将数据集复制到这些容器上。

  5. Finally, you may try to create an Init container and use it later for your new cluster. 最后,您可以尝试创建一个Init容器,以后将其用于新集群。

I suggest starting from point 1 as I think it is the most possible solution. 我建议从第1点开始,因为我认为这是最可能的解决方案。 If that would not be enough, try later points from the list. 如果那还不够,请尝试从列表中稍后的要点。

Please let me know if that helped. 请让我知道是否有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Postgres:将数据从一个数据库的公共模式移动到另一个数据库的新模式的最佳方法 - Postgres: Best way to move data from public schema of one DB to new schema of another DB 从 AWS 中的 Kubernetes 集群访问 Postgres RDS - Accessing Postgres RDS from Kubernetes cluster in AWS 从集群外的应用程序访问 kube.netes 中的 postgres - access postgres in kubernetes from an application outside the cluster 在Postgres中将数据从一个表移动到另一表的最快方法 - Fastest way to move data from one table to another in Postgres 如何在 Postgres 中将数据从一个表移动到另一个表(在使用 PK 时) - How to move data from one table to another in Postgres (while working with PK's) 如何在 postgres 中将数据从一列移动到另一列的行? - how to move data from one column to another column's row in postgres? "Kubernetes:无法从 Kubernetes 集群外部连接到 postgres" - Kubernetes: Trouble connecting to postgres from outside Kubernetes cluster 使用 Go 从一个 postgres 数据库复制到另一个 - Using Go to copy from one postgres db to another 如何在没有pg_dump的情况下将我所有的表从Postgres数据库复制到另一个表? - How to copy all my tables from a Postgres db to another one without pg_dump? 如何在保留原始模式的 Postgres 中将某些表从一个模式复制到另一个模式? - How to copy certain tables from one schema to another within same DB in Postgres keeping the original schema?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM