我在 Win 2012 服务器上安装了 postgreSQL 9.4.1。
我希望在这台服务器和另一台相同规格的服务器之间设置复制。因此,我按照热备份第 25.2.3 节中有关为备用服务器准备主数据库服务器的指南进行操作,这涉及使用pg_basebackup。
主服务器上的 PostgreSQL 实例包含我们的一个应用程序的数据库。该数据库有 3 个模式,每个模式都有自己的专用表空间。在 Windows 上,表空间位置是通过使用 MKLINK 命令创建的(因为我相信 LOCATION 参数必须指向 Windows 上的符号链接)所以 - 例如,:
mklink /j C:\tbs1 D:\app\tablespace\tbs1
mklink /j C:\tbs2 D:\app\tablespace\tbs2
Run Code Online (Sandbox Code Playgroud)
因此,以上述为例,使用以下命令在 postgreSQL 中创建了一个表空间:
CREATE TABLESPACE app_ops OWNER the_user LOCATION 'C:\tbs1';
Run Code Online (Sandbox Code Playgroud)
这一切都很好。但是,当我希望使用 pg_basebackup 工具时,我收到以下错误/警告 - 没有任何内容写入备份位置:
pg_basebackup -h localhost -U postgres -D C:\master_backup
pg_basebackup: directory "C:\tbs1" exists but is not empty
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我会收到这条特定的消息。
我看到的许多答案中的要点都是关于确保 PG_DATA 中不存在表空间。但是,在我的情况下,它们不是 - PG_DATA 在 Windows 服务的可执行路径中设置为-DC:\Program Files\PostgreSQL\9.4\data,如下所示:
"C:\Program Files\PostgreSQL\9.4\bin\pg_ctl.exe" runservice -N "postgresql-x64-9.4" -D "C:\Program Files\PostgreSQL\9.4\data" -w
Run Code Online (Sandbox Code Playgroud)
我查看了表空间映射参数“old=new”,但这并没有改变结果。
我很感激有类似的问题和指导,但是我似乎无法找到任何可能有帮助的其他内容。我查看了 dba/stackoverflow 和 www.postgresql.org 我会列出更多我看到有用信息的地方 - 但可惜我的声誉不允许我添加更多
如果有任何想法或想法,将不胜感激。
问候。
在我看来,它与mklinkWindows 问题无关。
根据pg_basebackup docs,主数据目录将放置在目标目录中,但所有其他表空间将放置在与服务器上相同的绝对路径中。
-F format
--format=format
Selects the format for the output. format can be one of the following:
p
plain
Write the output as plain files, with the same layout as the current data directory and tablespaces. When the cluster has no
additional tablespaces, the whole database will be placed in the
target directory. If the cluster contains additional tablespaces, the
main data directory will be placed in the target directory, but all
other tablespaces will be placed in the same absolute path as they
have on the server.
This is the default format.
Run Code Online (Sandbox Code Playgroud)
解决方法:不要在同一台服务器上运行,或者更改备份格式。