6

我按照以下说明安装了 postgresql:http: //xadmin.info/ ?p=284

# pg_ctl -D /var/lib/pgsql/data -l pglog.log start
server starting
postgres@linux-p0pl:~> psql
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on
 Unix domain socket "/tmp/.s.PGSQL.5432"?

我不明白为什么在服务器启动时出现此错误...有人可以帮忙吗?

我的 pglog.log 文件显示以下输出:

2013-02-06 19:43:39 GMT   FATAL:  lock file "postmaster.pid" already exists
2013-02-06 19:43:39 GMT   HINT:  Is another postmaster (PID 23971) running in data directory "/var/lib/pgsql/data"?
2013-02-06 19:44:02 GMT   FATAL:  lock file "postmaster.pid" already exists
2013-02-06 19:44:02 GMT   HINT:  Is another postmaster (PID 23971) running in data directory "/var/lib/pgsql/data"?
2013-04-24 12:43:29 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:43:29 GMT   DETAIL:  Permissions should be u=rwx (0700).
2013-04-24 12:44:07 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:44:07 GMT   DETAIL:  Permissions should be u=rwx (0700).
2013-04-24 12:57:02 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:57:02 GMT   DETAIL:  Permissions should be u=rwx (0700).
2013-04-24 12:57:40 GMT   FATAL:  data directory "/var/lib/pgsql/data" has group or world access
2013-04-24 12:57:40 GMT   DETAIL:  Permissions should be u=rwx (0700).

ps -ef | grep postgres

root     21659 21591  0 19:14 pts/0    00:00:00 grep --color=auto postgres
4

3 回答 3

19

权限和所有权/var/lib/pgsql/data应为:

# ll -d /var/lib/pgsql/data
drwx------. 15 postgres postgres 4096 Apr 24 10:27 /var/lib/pgsql/data

如果他们不是以 root 身份执行的:

# chmod -R 700 /var/lib/pgsql/data
# chown -R postgres /var/lib/pgsql/data
于 2013-04-24T16:29:10.987 回答
1

签入pglog.log文件以确保服务器确实没有错误地实际启动。鉴于错误,它似乎没有正常启动。

于 2013-04-24T13:06:16.133 回答
1

您可能没有将服务器配置为将 unix 域套接字放入“/tmp”。它可能类似于“/var/run/pgsql”,但请查看您的postgresql.conf文件以了解具体内容。

然后您可以在命令行上将此目录指定为“主机”:

psql -h /path/we/want ...

如果这不是问题,请检查端口号。

不确定您的 psql 客户端和 postgresql 服务器为什么/如何具有不同的默认路径,但是我从未听说过您从中获得说明的站点,所以我不知道它们有多大用处。

于 2013-04-24T13:09:25.613 回答