简体   繁体   English

如何快速转储 Postgres 数据库

[英]How do I dump a Postgres database QUICKLY

I have a massive Postgres 9.1 database (~450 GB) that I need to copy to a new machine, where I want to upgrade to Postgres 12.我有一个庞大的 Postgres 9.1 数据库(约 450 GB),我需要将其复制到一台新机器上,我想在其中升级到 Postgres 12。

Using pg_dump stalls out after a few hours, writing only 60 GB.使用pg_dump几个小时后停止,只写入 60 GB。 How can I speed up the process dramatically?我怎样才能显着加快这个过程?

Nothing is going to do what pg_dump does faster than pg_dump itself.没有什么能比pg_dump本身更快地完成pg_dump的工作。 Shut down access to the database while dumping if at all possible.尽可能在转储时关闭对数据库的访问。 Check the system for other sources of load (particularly I/O load) and remove them if possible.检查系统是否存在其他负载源(尤其是 I/O 负载),如果可能,将其移除。 Check if the drive is failing.检查驱动器是否出现故障。 Don't write the dump to the same disk that the database is being read from (if another disk isn't available on the source machine, consider something like pg_dump whatever | ssh anothermachine 'cat > db.sql' ).不要将转储写入正在读取数据库的同一磁盘(如果源计算机上没有另一个磁盘可用,请考虑类似pg_dump whatever | ssh anothermachine 'cat > db.sql' )。 Or, just have patience.或者,只要有耐心。

If you are dumping the database over ssh, add the -Z flag, followed by the zip level, to compress the output of pg_dump .如果要通过 ssh 转储数据库,请添加-Z标志,后跟 zip 级别,以压缩pg_dump的 output。 eg, pg_dump -Z 9例如, pg_dump -Z 9

See the documentation: https://www.postgresql.org/docs/9.3/app-pgdump.html请参阅文档: https://www.postgresql.org/docs/9.3/app-pgdump.html

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

相关问题 在MySQL中,如何转储说明以再次创建该数据库? - In MySQL, how do I dump instructions to create that database again? 如何从远程 postgres 数据库转储到 docker 容器内的目录? - How to dump from remote postgres database to a directory inside a docker container? 如何快速获取dbus上的所有VLC实例? - How do I get all instances of VLC on dbus quickly? 如何将大型OSM Postgresql数据库从VMWare Linux迁移到OSX上的Postgres.app? - How Do I Migrate A Large OSM Postgresql Database from VMWare Linux to Postgres.app on OSX? Postgres pg_dump每次都以不同的顺序转储数据库 - Postgres pg_dump dumps database in a different order every time Postgres pg_dump 转储文件大小大于 pg_database_size - Postgres pg_dump dump file size bigger than pg_database_size 如何使用 Python 执行 Shell 命令以恢复数据库 postgres? - How can I Executing Shell Commands with Python for restore database postgres? 我可以使用mysql(而不是mysqldump)转储数据库吗? - Can I dump database with mysql (not mysqldump)? 如何创建 cron 作业来运行 postgres SQL 函数? - How do I create a cron job to run an postgres SQL function? 崩溃时如何将程序的核心转储保存到文件中? - How do I have my program's core dump saved to a file upon a crash?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM