-1

A) 挂载了具有所需所有权和权限的 Virtualbox 目录:

ls -l /var:

drwx------.  1 postgres postgres 4096 Aug 20 12:43 pgshared

(和 /var/pgshared/data 目录已经创建了完全相同的权限)

B) 将 PGDATA 环境变量从默认更改为该数据目录

C) initdb 失败并出现以下错误:

fixing permissions on existing directory /var/pgshared/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Europe/Brussels
creating configuration files ... ok
running bootstrap script ... 2021-08-20 12:16:08.088 CEST [2807] LOG:  could not link file "pg_wal/xlogtemp.2807" to "pg_wal/000000010000000000000001": Operation not permitted
2021-08-20 12:16:08.090 CEST [2807] FATAL:  could not open file "pg_wal/000000010000000000000001": No such file or directory
child process exited with exit code 1

initdb: removing contents of data directory "/var/pgshared/data"

附加评论:

使用 -D 选项具有相同的结果(无论 PGDATA 环境变量如何)

4

2 回答 2

1

该错误表示文件系统不支持硬链接(link(2)系统调用失败)。

即使你设法放置一个数据目录,PostgreSQL 也不会工作。要确认,请运行以下几次:

SELECT pg_switch_xlog();

您将不得不使用实现所有必需系统调用的不同文件系统。

于 2021-08-20T12:32:56.653 回答
0

这是我使用的一种解决方法,我能够成功地继续创建数据库并连接到它们,但我不知道(还)我是否会面临更多问题。此外,根本原因和真正的解决方案仍然未知:

1- 由于可以在本地驱动器上进行初始化,因此我卸载了共享驱动器(umount /var/pgshared)并初始化了数据库。它成功了,并且创建了包含所有预期内容的数据文件夹。

2- 我将数据文件夹移动到一个临时位置,并使用相同的挂载命令重新挂载了共享文件夹。

3-我将数据文件夹移回安装的驱动器。

4-我用 psql 命令做了简单的测试。

于 2021-08-20T11:24:07.493 回答