微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linux – PostgreSQL无法启动,因为它“无法分配内存”

我在Ubuntu 10.04上运行Postgresql 8.4.5.我运行一个EC2实例,其中有几个站点Nginx上运行.大多数这些站点都在Django上运行并连接到这个Postgres实例.

出于某种原因,今晚8点45分,Postgres下台了.我登录到机器,我看到此错误消息:

* Starting Postgresql 8.4 database server
 * The Postgresql server Failed to start. Please check the log output:
2011-04-17 04:46:49 UTC FATAL:  Could not create shared memory segment: Cannot allocate memory
2011-04-17 04:46:49 UTC DETAIL:  Failed system call was shmget(key=5432001,size=16211968,03600).
2011-04-17 04:46:49 UTC HINT:  This error usually means that Postgresql's request for a shared memory segment exceeded available memory or swap space. To reduce the request size (currently 16211968 bytes),reduce Postgresql's shared_buffers parameter (currently 1792) and/or its max_connections parameter (currently 53).
        The Postgresql documentation contains more information about shared memory configuration.
   ...fail!

我做的第一件事是更改Linux共享内存分配.

sysctl -w kernel.shmmax=367108864>
sysctl -p /etc/sysctl.conf

那没有做到.然后我编辑了/etc/postgresql/8.4/main/postgresql.conf并降低了max_connections值.这有效…大约10分钟.

现在我得到了同样的错误,无论max_connections有多低.我需要将它设置为至少9(因为这是需要访问此Postgres服务器的Django项目的数量).

关于如何解决这个问题的任何想法?

解决方法

您可以使用’ipcs’命令列出所有SHM段.如果一个程序崩溃而没有删除它们,它们可能正在消耗内存;您可以使用’ipcrm’命令手动删除它们.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐