我已经多次使用这种技术在服务器之间传输数据库:
\n\npg_dump --no-owner -Fd mydb -j 4 -f tmp/mydb\nscp -r tmp/mydb otherserver:tmp/\nRun Code Online (Sandbox Code Playgroud)\n\n然后在另一台服务器中:
\n\ndropdb --if-exists mydb && \ncreatedb -T template0 mydb && \npg_restore -j 4 -d mydb tmp/mydb && \nrm -rf tmp/mydb\nRun Code Online (Sandbox Code Playgroud)\n\n它运行完美。\n使用 Postgres 9.3.16 和 CentOS 7。
\n\n但现在,在新服务器中,pg_restore 抱怨:
\n\npg_restore: [archiver] parallel restore is not supported with this archive file format\nRun Code Online (Sandbox Code Playgroud)\n\n我可以删除该-j 4参数,但理论上它应该是有效的。\n根据pg_restore 文档:
\n-j 作业数\n --jobs=作业数
\n\n运行 pg_restore \xe2\x80\x94 中最耗时的部分,这些部分使用多个并发作业加载\n 数据、创建索引或创建约束 \xe2\x80\x94。此选项可以显着减少将大型数据库恢复到多处理器计算机上运行的服务器的时间。
\n\n每个作业都是一个进程或一个线程,具体取决于操作系统,并使用与服务器的单独连接。 …