随笔 - 92  文章 - 0  评论 - 13  阅读 - 17万

[Postgres]postgresql.conf : Permission denied处理一法

使用yum安装完postgresql,没有使用默认的DATA地址,自己配置了DATA地址以后,使用root权限启动service

service postgresql start

,报出了"FAILED"

不解,检查Log文件 /var/lib/pgsql/pgstartup.log. 发现如下记录

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

于是检查postgres用户的文件权限,没有明显的问题,可读可写(忘了好像是700),于是上网一查,基本怀疑问题在SELinux上

先检查SELinux状态

# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 21
Policy from config file:        targeted
 

果然是运行状态,并且还是在"enforcing"模式,检查SELinux的Log(大部分情况在/var/log/audit/,有时也会被配置到/var/log/messages)

# grep postgres /var/log/audit/audit.log | grep denied | tail -1
 
type=AVC msg=audit(1234567890.334:432): avc:  denied  { read } for
pid=1234 comm="postmaster" name="pgsql" dev=newpgdisk ino=403123 
scontext=user_u:system_r:postgresql_t:s0
tcontext=system_u:object_r:var_lib_t:s0 tclass=lnk_file

有一条拒绝记录!就这玩意干的。

这里说个最简单干脆的方法,停用SELinux.

编辑/etc/selinux/config:


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted

 

将SELINUX=enforcing 改成 SELINUX=permissive或者SELINUX=disabled,重启系统

再次启动postgresql,问题解决

可参考:http://blog.endpoint.com/2009/09/permission-denied-for-postgresqlconf.html

http://www.crypt.gen.nz/selinux/disable_selinux.html

http://www.centos.org/docs/5/html/5.2/Deployment_Guide/sec-sel-enable-disable.html

posted on   BoneKing  阅读(9487)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示