centos7 - 当我在 CentOS 中更改其默认数据目录时,Postgres 11 无法启动

标签 centos7 postgresql-11

我按照以下步骤更改了 postgres 数据目录:

systemctl stop postgresql-11.service

cp -r /var/lib/pgsql/11/data /home/eshel/pgsql-11/

chown -R postgres:postgres /home/eshel/pgsql-11/

chmod 700 /home/eshel/pgsql-11/

vi /usr/lib/systemd/system/postgresql-11.service
    Environment=PGDATA=/home/eshel/pgsql-11/data/

systemctl daemon-reload

systemctl start postgresql-11.service

到目前为止,postgres-11是正常的。 在我更改了新的 data_directory 的 postgres.conf 之后。

1. vim pgsql-11/data/postgresql.conf
    data_directory = '/home/eshel/pgsql-11/data'

我无法启动 postgres-11。我不知道该如何处理。 错误如下:

[root@localhost 11]# systemctl start postgresql-11.service
* Job for postgresql-11.service failed because the control process exited with error code. See "systemctl status postgresql-11.service" and "journalctl -xe" for details.
[root@localhost 11]# systemctl status postgresql-11.service
● postgresql-11.service - PostgreSQL 11 database server
   * Loaded: loaded (/usr/lib/systemd/system/postgresql-11.service; enabled; vendor preset: disabled)
   * Active: failed (Result: exit-code) since Fri 2019-10-11 23:05:00 CST; 27s ago
     * Docs: https://www.postgresql.org/docs/11/static/
  * Process: 12758 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
 * Main PID: 11582 (code=exited, status=0/SUCCESS)

* Oct 11 23:05:00 localhost.localdomain systemd[1]: Starting PostgreSQL 11 database server...
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service: control process exited, code=exited status=1
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Failed to start PostgreSQL 11 database server.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Unit postgresql-11.service entered failed state.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service failed.

[root@localhost 11]#journalctl -xe

* Oct 11 23:01:21 localhost.localdomain dbus[6461]: [system] Activating service name='org.freedesktop.problems' (using servicehe
* Oct 11 23:01:21 localhost.localdomain dbus[6461]: [system] Successfully activated service 'org.freedesktop.problems'
* Oct 11 23:04:51 localhost.localdomain nautilus-deskto[9318]: g_simple_action_set_enabled: assertion 'G_IS_SIMPLE_ACTION (simpl
* Oct 11 23:05:00 localhost.localdomain polkitd[6478]: Registered Authentication Agent for unix-process:12752:1022414 (system bu
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Starting PostgreSQL 11 database server...
* -- Subject: Unit postgresql-11.service has begun start-up
* -- Defined-By: systemd
* -- Unit postgresql-11.service has begun starting up.
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: "/home/eshel/pgsql-11/data/" is missing or empty.
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: Use "/usr/pgsql-11/bin/postgresql-11-setup initdb" to
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: See /usr/share/doc/postgresql11-11.4/README.rpm-dist 
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service: control process exited, code=exited status=1
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Failed to start PostgreSQL 11 database server.
* -- Subject: Unit postgresql-11.service has failed
* -- Defined-By: systemd

* -- Unit postgresql-11.service has failed.

* -- The result is failed.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Unit postgresql-11.service entered failed state.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service failed.

the error image

最佳答案

进程:10839 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)/p> postgres 无法读取 PGDATA 目录。在其他人的帮助下,我们通过以下方式解决了这个问题:

Before modification:
drwx------. 19 eshel eshel 4096 Oct 12 21:00 eshel
After modification:
[root@localhost eshel]# chmod 755 ../eshel/
[root@localhost eshel]# ll ../
drwxr-xr-x. 19 eshel eshel 4096 Oct 12 21:00 eshel

然后我启动postgres11,就OK了!

systemctl start postgresql-11

关于centos7 - 当我在 CentOS 中更改其默认数据目录时,Postgres 11 无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58344426/

相关文章:

r - 无法在 centOS 7.0 64 位上安装 git2r 或 devtools R 包

linux - Jenkins 无法在 centOS7 上启动

python - 安装 hunspell 包

url 的 postgresql 唯一非连续 id

apache - 从 CentOS 完全卸载/删除 tomcat 9

docker - 如何在 CentOS 7 docker 上安装 gcc/g++ 9 (centos :7)

windows - 大量空间,但 - [53100] 错误 : could not write block …: No space left on device

database - PostgreSQL:PgAdmin 上具有 3 个主键的表的外键

sql - 用另一个列的总和更新列

python - 并行运行测试时出错