4

我正在尝试通过 Openstack 上的 Fabric 构建一个盒子。安装的一部分涉及安装和运行 PostgreSQL。

此命令工作正常:

$ sudo service postgresql initdb 

此命令失败:

$ sudo service postgresql start

当我运行此命令时,失败的日志输出显示没有问题:

$ cat /var/lib/pgsql/pgstartup.log  

此命令显示以下消息:

$ cat /var/lib/pgsql/data/pg_log/postgresql-Wed.log

日志:无法打开配置文件“/var/lib/pgsql/data/pg_hba.conf”:权限被拒绝致命:无法加载 pg_hba.conf

我的用户在执行这些命令时具有以下组:

vagrant, wheel

我的用户在具有以下权限 的sudoers列表中:/etc/sudoers

vagrant  ALL=(ALL) NOPASSWD: ALL

烫发pgsql

[root@integration ~]# ls -ltr /var/lib/pgsql/
total 12
drwx------.  2 postgres postgres 4096 Sep 13  2012 backups
-rw-------.  1 postgres postgres 1152 Jun 19 20:17 pgstartup.log
drwx------. 12 postgres postgres 4096 Jun 19 20:19 data

和子目录data

[root@integration ~]# ls -ltr /var/lib/pgsql/data/
total 76
-rw-------. 1 postgres postgres     4 Jun 19 20:17 PG_VERSION
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_twophase
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_tblspc
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_stat_tmp
drwx------. 4 postgres postgres  4096 Jun 19 20:17 pg_multixact
-rw-------. 1 postgres postgres 16886 Jun 19 20:17 postgresql.conf
-rw-------. 1 postgres postgres  1631 Jun 19 20:17 pg_ident.conf
drwx------. 3 postgres postgres  4096 Jun 19 20:17 pg_xlog
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_subtrans
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_clog
drwx------. 5 postgres postgres  4096 Jun 19 20:17 base
drwx------. 2 postgres postgres  4096 Jun 19 20:17 global
-rw-------. 1 postgres postgres   241 Jun 19 20:17 pg_hba.conf
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_log
-rw-------. 1 postgres postgres    57 Jun 19 20:19 postmaster.opts
4

1 回答 1

1

原来这是一个selinux问题。我禁用它并且很好。完整配置如下。

对于那些还没有使用 selinux 的人(像我一样直到今天),可以在以下位置找到配置:

 /etc/selinux/config

也可以像这样暂时关闭:

echo 0 > /selinux/enforce

完整配置

[root@integration selinux]# cat 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 - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
#   targeted - Only targeted network daemons are protected.
#   strict - Full SELinux protection.
于 2013-06-20T13:42:58.153 回答