我在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项目的数量).
关于如何解决这个问题的任何想法?