我最近从 Maverick 升级到了 Natty,一切都很顺利,只是在 dist-upgrade 期间 PostgreSQL 出了点问题。此后,我尝试通过“sudo apt-get purge postgresql”重新安装、删除甚至清除它,但无论我做什么,它仍然会出现相同的错误。见下文。升级前它运行良好。任何帮助都将不胜感激。谢谢!
Setting up postgresql-common (114) ...
* Starting PostgreSQL 8.4 database server * The PostgreSQL server failed to start. Please check the log output:
2011-05-19 11:49:41 EDT LOG: could not bind IPv4 socket: Address already in use
2011-05-19 11:49:41 EDT HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2011-05-19 11:49:41 EDT WARNING: could not create listen socket for "127.0.0.1"
2011-05-19 11:49:41 EDT FATAL: could not create shared memory segment: Invalid argument
2011-05-19 11:49:41 EDT DETAIL: Failed system call was shmget(key=5432001, size=37879808, 03600).
2011-05-19 11:49:41 EDT 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 37879808 bytes), reduce PostgreSQL's shared_buffers parameter (currently 4096) and/or its max_connections parameter (currently 103).
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.
[fail]
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing postgresql-common (--configure):
subprocess installed post-installation script returned error exit status 1
答案1
您需要增加 Linux 内核允许一次分配的共享内存块的最大大小(称为 SHMMAX 参数)
您需要编辑/etc/sysctl.conf
并添加以下行:
kernel.shmmax = 41943040
(其中41943040
是内存大小(以字节为单位),即 40 兆字节。在生产系统上,您可能希望将此值设置得更高 - Postgres 文档建议从可用内存的 1/4 开始)
然后运行
sudo sysctl -p
并再次重新启动postgres。
或者,您可以编辑/etc/postgresql/<version>/main/postgresql.conf
并减少shared_buffers
参数的值。
这是一个错误,更多信息请点击此处
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/264336
(还有一个/etc/sysctl.d/30-postgresql-shm.conf
应该用于此目的的文件但它似乎没有包含在主配置中因此编辑它没有效果)
答案2
旧的 Postgres 很可能仍在运行。
就像自由思想者指出的那样,验证该端口上运行的内容是一个好主意。
一旦你知道它是 Postrgres 那么你可能想要杀死它:
# Find PID
ps axf | grep post
kill PID
然后你就可以启动新版本了:
/etc/init.d/postgresql start
我很困惑为什么包管理器无法停止旧版本。