[英]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: 我对如何处理此问题几乎没有想法(从最可能到最少列出):
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. 请记住,这可能需要一段时间。
You can use a tool to assist you with that. 您可以使用工具来协助您。 For example pghoard .
例如pghoard 。
You can make a tared backup of you DB and try to copy as a object via Google Cloud Storage. 您可以对数据库进行皮重备份,然后尝试通过Google Cloud Storage作为对象复制。
You can try to create PVCs manually, attach pods to those PVCs and than copy your dataset onto those pods. 您可以尝试手动创建PVC,将容器附加到这些PVC,然后将数据集复制到这些容器上。
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.