系统还原后PostgreSQL服务器无法启动; OSX Mountain Lion

时间:2013-08-18 04:11:50

标签: macos postgresql osx-mountain-lion

我以前使用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的{​​{1}}唯一的目录是/Library/PostgreSQL/9.2/data。所以我通过postgres切换到sudo su 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".

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

1 个答案:

答案 0 :(得分:0)

您的内核参数需要调整。以下是kernel resources的相关文档。根据您的系统规格(内存)配置它们,你应该很好。

作为一个脚注,我想从Postgresql 9.3开始添加,上面的调整将no longer be necessary