系统还原后,PostgreSQL 服务器不会启动;OSX 山狮



我之前在Mac上使用EnterpriseDB安装程序安装了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没有文件夹;我能找到的唯一具有CCD_ 5的目录是CCD_。所以我通过做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时必须启动服务器。。。

EDIT:我也尝试了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".

所以它应该还在那里,和我系统上的大多数其他东西一起恢复,对吧?

您的内核参数需要调整。以下是有关内核资源的相关文档。根据您的系统规范(内存)配置这些,您应该会做得很好。

作为一个脚注,我想补充一点,从Postgresql9.3开始,上面的调整将不再必要。

最新更新