【问题标题】:PostgreSQL server won't start after system restore; OSX Mountain Lion [closed]系统还原后PostgreSQL服务器无法启动; OSX山狮[关闭]
【发布时间】:2013-08-18 04:11:49
【问题描述】:

我之前使用 EnterpriseDB 安装程序在我的 Mac 上安装了 PostgreSQL 9.2。因此,我将.bash_profile 修改为export PATH=/opt/local/lib/postgresql92/bin:$PATH,一切正常。

然后我的硬盘损坏了,不得不重新格式化我的电脑并重新安装 OSX。最初我不得不重新安装 Snow Leopard(这是我拥有的恢复光盘的版本),然后重新升级到 Mountain Lion(我在崩溃之前正在运行)。然后,我使用带有迁移助手的 Time Machine 备份来恢复我的用户、应用程序和“其他文件”。

环顾四周,一切似乎又回到了坠机前的位置。然而,现在当我尝试做任何与 PostgreSQL 相关的事情时,我得到了错误:

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"?

上网查了一下,发现这可能是因为我在进行系统还原时我的PostgreSQL服务器没有启动。官方文档说使用以下命令:

$ postgres -D /usr/local/pgsql/data

但我在/usr/local/pgsql 没有文件夹;我能找到的唯一带有data 的目录是/Library/PostgreSQL/9.2/data。所以我通过sudo su postgres切换到postgres并再次尝试postgres -D /Library/PostgreSQL/9.2/data,结果如下:

2013-08-18 11:38:09 SGT FATAL:  could not create shared memory segment: Invalid argument
2013-08-18 11:38:09 SGT DETAIL:  Failed system call was shmget(key=5432001, size=32374784, 03600).
2013-08-18 11:38:09 SGT HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter.  You can either reduce the request size or reconfigure the kernel with larger SHMMAX.  To reduce the request size (currently 32374784 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
    If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the request size or reconfiguring SHMMIN is called for.
    The PostgreSQL documentation contains more information about shared memory configuration.

我从这里去哪里?这整件事有点奇怪。我不记得最初安装 PostgreSQL 时必须启动服务器...

编辑:我还尝试了initdb -D /Library/PostgreSQL/9.2/data,以防数据库集群丢失,但得到了:

initdb: directory "/Library/PostgreSQL/9.2/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/Library/PostgreSQL/9.2/data" or run initdb
with an argument other than "/Library/PostgreSQL/9.2/data".

所以它应该仍然存在,与我系统上的大多数其他东西一起恢复,对吧?

【问题讨论】:

  • 你有一个流浪的postmaster.pid文件在任何地方乱跑吗?
  • @muistooshort,我在/Library/PostgreSQL/9.0/data 有一个,但之前卸载了那个版本的PostgreSQL(data 目录是9.0 中唯一剩下的一个,因为属于postgres 而不是我的普通用户)。 9.2/data 中没有这样的文件。

标签: macos postgresql osx-mountain-lion


【解决方案1】:

您的内核参数需要调整。这是kernel resources 上的相关文档。根据您的系统规格(内存)配置这些,您应该会很好。

作为脚注,我想补充一点,从 Postgresql 9.3 开始,上述调整将 no longer be necessary

【讨论】:

  • 我实际上可以通过简单地运行卸载程序然后重新安装 PostgreSQL 来解决这个问题,但是感谢您的回答。我相信它在未来会被证明是有用的。
猜你喜欢
  • 2013-06-07
  • 2013-04-28
  • 1970-01-01
  • 1970-01-01
  • 2013-09-01
  • 2013-04-02
  • 1970-01-01
  • 2019-10-27
  • 1970-01-01
相关资源
最近更新 更多