使用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

[Postgres]postgresql.conf : Permission denied处理一法的更多相关文章

  1. Postgresql ERROR: permission denied for relation app_info

    启用终端,: 进入mydb数据库:\c mydb 然后给当前数据库的角色赋予权限:GRANT ALL PRIVILEGES ON TABLE 表名  TO 角色名;

  2. docker postgresql FATAL: could not access private key file "/etc/ssl/private/ssl-cert-snakeoil.key": Permission denied

    在docker中启动postgresql时出现错误 FATAL:  could not access private key file "/etc/ssl/private/ssl-cert- ...

  3. Apache Permission denied (httpd.conf配置和目录权限无问题)解决办法

    今天在CentOS5.9中配置zabbix时出现错误:Apache 403 error, (13)Permission denied: access to / denied 检查了一圈httpd.co ...

  4. postgresql connection failure:SQLSTATE[08006] [7] could not connect to server: Permission denied Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?

    PHP 程序无法连接到 CentOS 上的PostgreSQL,但是在 CentOS 服务器上却能正常运行 psql, 操作如下:多次重启 PG 数据库后发现 CGI 脚本无法连接数据库,但是可以使用 ...

  5. Understanding postgresql.conf : log*

    After loooong pause, adding next (well, second) post to the “series“. This time, I'd like to describ ...

  6. vsftpd安装配置 530 Permission denied.错误

    yum install vsftpd service vsftpd start 530 Permission denied.错误 /etc/vsftpd/user_list    该文件里的用户账户在 ...

  7. [转]HDFS客户端的权限错误:Permission denied

    搭建了一个Hadoop的环境,Hadoop集群环境部署在几个Linux服务器上,现在想使用windows上的Java客户端来操作集群中的HDFS文件,但是在客户端运行时出现了如下的认证错误. 错误的详 ...

  8. org.apache.hadoop.security.AccessControlException: Permission denied:

    org.apache.hadoop.security.AccessControlException: Permission denied: user=xxj, access=WRITE, inode= ...

  9. 解决mac os x下 tomcat启动报 java.net.BindException: Permission denied <null>:80 错误

    我在mac os x上启动tomcat的时候,报 java.net.BindException: Permission denied <null>:80,java.net.BindExce ...

随机推荐

  1. Java 将字符串转换为字符数组 toCharArray()

    Java 手册 toCharArray public char[] toCharArray() 将此字符串转换为一个新的字符数组. 返回: 一个新分配的字符数组,它的长度是此字符串的长度,它的内容被初 ...

  2. 利用VMware在虚拟机上安装Zookeeper集群

    http://blog.csdn.net/u010246789/article/details/52101026 利用VMware在虚拟机上安装Zookeeper集群 pasting

  3. springcloud(八) Hystrix监控

    一.Feign项目Hystrix自带的监控 在feign项目pom.xml 添加: <!-- 1,使用 Hystrix的模块 hystrix-metrics-event-stream,就可将这些 ...

  4. WPF MVVM

    MVVM全称:Model-View-ViewModel 优点:MVVM的引入使程序实现了松耦合设计,UI层与业务逻辑可以并行设计 1.Model:对现实世界的抽象 比如:需要做一个学校的管理系统,学校 ...

  5. python实现socket上传下载文件-进度条显示

    在python的socket编程中,可以实现上传下载文件,并且在下载的时候,显示进度条,具体的流程如下图所示: 1. 服务器端代码如下: [root@python 519]# cat server.p ...

  6. jsp 学习 第1步 - 引入 jstl

    通过 eclipse 新建 动态web项目  默认是没有引入 jstl, 则无法JSP页面引入相关标记. <%@ taglib prefix="c" uri="ht ...

  7. leetcode807

    class Solution { public: int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) { ...

  8. Cascade属性的取值

    Cascade属性的取值有:1.none:忽略其他关联的对象,默认值.2.save-update:当session通过save(),update(),saveOrUpdate()方法来保存或更新对象时 ...

  9. CommonDialog控件

    '要先单击“工程-部件”,显示“部件”对话框,将“Microsoft Common Dialog control 6.0(SP6)”选中,在工具栏就多出了一个CommonDialog控件图标,将其添加 ...

  10. Memcpy, blockcopy的进一步理解

    using System; using System.Runtime.InteropServices; using System.IO; namespace tx { struct ST { publ ...