共享存储上的 PostgreSQL 和数据库集群所有权

共享存储上的 PostgreSQL 和数据库集群所有权

为了进行研究,我使用始终在线的虚拟机来对我的数据进行主要分析。为此,我需要(或者,我想,想要)创建并将数据存储在 PostgreSQL 数据库中。虚拟机运行的是 CentOS 7,我的登录名(我们称之为“ username”)具有 root 访问权限。问题:

数据必须存储在位置 的已安装共享存储中/shared/username/data。我(“ username”)是目录及其所有子目录的所有者/shared/username/,并且(出于安全原因?)似乎无法通过chown或进行更改sudo chown。这意味着我无法以用户身份启动数据库postgres,因为它需要 的​​所有权/shared/username/data。见下文。

登录为postgres

bash-4.2$ /usr/pgsql-9.4/bin/initdb -D /shared/username/data
could not change directory to "/shared/username": Permission denied
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

initdb: could not access directory "/shared/username/data": Permission denied

我是 PostgreSQL 的新手,但已经使用各种版本的 Linux 一段时间了。不过文件权限有时会让我感到困惑。

这个问题有解决办法吗?也许可以以某种方式阻止 initdb 撤销访问权限username?任何帮助我都感激不尽,我很乐意提供任何其他信息。

相关内容