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’命令手动删除它们.

相关文章

1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...
1 删除0字节文件 find -type f -size 0 -exec rm -rf {} ...
## 步骤 1:安装必要的软件包 首先,需要确保系统已安装 `dh...