微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用sudo命令修改postgresql.conf后启动PostgreSQL服务器失败

我想更改 postgresql.conf文件中的“shared_buffers”参数.

问题是我使用了sudo命令,它将所有权赋予root.

-rw-rw-rw-   1 root root  13661 Mar 14 15:36 postgresql.conf

然后我使用以下命令将所有权归还给postmaster:

sudo chown postgres:postgres /var/lib/pgsql/data/postgresql.conf

所以我尝试了这个命令:

postgres -D /var/lib/pgsql/data

我仍然感到非常惊讶,仍然收到以下错误消息

postgres cannot access the server configuration file "/var/lib/pgsql/data/postgresql.conf": Permission denied

下面的id是postgresql中目录中“ls”命令的结果:

sudo ls -l /var/lib/pgsql/data/
total 208
drwx------  19 postgres postgres   4096 Mar 13 17:23 base
drwx------   2 postgres postgres   4096 Mar 14 14:30 global
drwx------   2 postgres postgres   4096 Mar  5 14:26 pg_clog
-rw-------   1 postgres postgres   3365 Mar  1  2006 pg_hba.conf
-rw-------   1 postgres postgres   3182 Mar  1  2006 pg_hba.conf.old
-rw-------   1 postgres postgres   1460 Feb 24  2006 pg_ident.conf
drwx------   2 postgres postgres 139264 Mar 14 00:00 pg_log
drwx------   4 postgres postgres   4096 Feb 24  2006 pg_multixact
drwx------   2 postgres postgres   4096 Mar 14 10:42 pg_subtrans
drwx------   2 postgres postgres   4096 Feb 24  2006 pg_tblspc
drwx------   2 postgres postgres   4096 Feb 24  2006 pg_twophase
-rw-------   1 postgres postgres      4 Feb 24  2006 PG_VERSION
drwx------   3 postgres postgres   4096 Mar 14 14:30 pg_xlog
-rw-rw-rw-   1 postgres postgres  13661 Mar 14 15:36 postgresql.conf
-rw-------   1 postgres postgres     49 Jan  2 17:15 postmaster.opts

如果有人知道可能是解决这个问题的方法.

提前致谢.

弗雷德

解决方法

检查SELinux如何运行:

# sestatus

如果它处于强制模式,请检查日志:

# less /var/log/audit/audit.log

如果你发现SELinux阻塞,那么暂时禁用SELinux只是为了确认它是罪魁祸首:

# setenforce 0

现在尝试启动服务器.如果它工作,然后重新启用SELinux:

# setenforce 1

搜索如何恢复该文件的SELinux设置.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐