Postgresql 启动失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17204055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postgresql startup failure
提问by mconlin
I'm attempting to build a box via Fabric on Openstack. Part of the install involves installing and running PostgreSQL.
我正在尝试通过 Openstack 上的 Fabric 构建一个盒子。部分安装涉及安装和运行 PostgreSQL。
This command works fine:
此命令工作正常:
$ sudo service postgresql initdb
This command fails:
此命令失败:
$ sudo service postgresql start
Log output of failure shows no issues when I run this command:
当我运行此命令时,失败的日志输出显示没有问题:
$ cat /var/lib/pgsql/pgstartup.log
This command shows the following messages:
此命令显示以下消息:
$ cat /var/lib/pgsql/data/pg_log/postgresql-Wed.log
LOG: could not open configuration file "/var/lib/pgsql/data/pg_hba.conf": Permission denied FATAL: could not load pg_hba.conf
日志:无法打开配置文件“/var/lib/pgsql/data/pg_hba.conf”:权限被拒绝致命:无法加载 pg_hba.conf
My user while executing these commands has the following groups:
我的用户在执行这些命令时有以下组:
vagrant, wheel
My user is in the sudoers
list under /etc/sudoers
with these permissions:
我的用户sudoers
在/etc/sudoers
具有以下权限的列表中:
vagrant ALL=(ALL) NOPASSWD: ALL
perms on pgsql
:
烫发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
and sub dir 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
采纳答案by mconlin
This turned out to be an selinux issue. I disabled it and was well. Full config below.
结果证明这是一个selinux问题。我禁用了它并且很好。完整配置如下。
For those of you that arent up on selinux (like me until today) the config can be found in:
对于那些还没有使用 selinux 的人(像我一样直到今天),可以在以下位置找到配置:
/etc/selinux/config
It can also be turned off temporarily like this:
它也可以像这样暂时关闭:
echo 0 > /selinux/enforce
Full config
完整配置
[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.