PostgreSQL安装错误 - 无法分配内存 [英] PostgreSQL installation error -- Cannot allocate memory

查看:1472
本文介绍了PostgreSQL安装错误 - 无法分配内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从sqlite3切换到PostgreSQL以便在Rails中进行开发,这样我就不会有任何heroku问题。我正在关注heroku和链接Railscast的建议,但在安装postgresql后,我遇到了以下错误。


创建在/ usr / local / var / postgres / base / 1中的template1数据库...
$ b

致命错误:无法创建共享内存段:无法分配内存



详细信息:失败的系统调用是shmget(key = 1,size = 2072576,03600)。
$ b 提示:此错误通常表示PostgreSQL对共享内存段的请求超出了可用内存或交换空间,或者
超出了内核的SHMALL参数。您可以减少
请求的大小,或者用更大的SHMALL重新配置内核。为了减少
的请求大小(目前为2072576字节),可以减少PostgreSQL的共享
内存使用量,可能是通过减少shared_buffers或max_connections。 $ b

我已经对文档进行了一些探讨,但是我对此并不熟悉,并且对内存和数据库的工作方式知之甚少,并且我认为这里有人可能能够指引我朝着正确的方向发展比我自己能找到的要好得多。任何想法如何解决这个问题?我的电脑是新的,相当花哨的,如果内存不足,我会感到惊讶,所以我不知道是否减少共享内存使用是正确的想法(如果我理解到底是怎么回事) 。

编辑:应该早点提出。这是导致错误的命令(构建数据库):

  initdb / usr / local / var / postgres -E utf8 


解决方案

从数据库路径中,我猜你正在使用因为大多数流行的Linux发行版都有一个数据库目录驻留在/ var / lib中。



在谷歌搜索后,我发现这个:
解决postgresql initdb致命共享内存错误Leopard


希望有帮助。

为了您的方便,我从上面的链接中复制了这些说明。 / b>

运行以下命令:

  sudo sysctl -w kern.sysv。 shmall = 65536 
sudo sysctl -w kern.sysv.shmmax = 16777216

或编辑/ etc / sysctl.conf用于永久更改

  kern.sysv.shmal l = 65536 
kern.sysv.shmmax = 16777216


I'm trying to switch over from sqlite3 to PostgreSQL for development in Rails so that I don't have any heroku problems. I was following the advice given on heroku and a linked-to Railscast, but I ran into the following error after brew installing postgresql.

creating template1 database in /usr/local/var/postgres/base/1 ...

FATAL: could not create shared memory segment: Cannot allocate memory

DETAIL: Failed system call was shmget(key=1, size=2072576, 03600).

HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space, or exceeded your kernel's SHMALL parameter. You can either reduce the request size or reconfigure the kernel with larger SHMALL. To reduce the request size (currently 2072576 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.

I've poked around the doc a bit, but I'm new to this and know very little about memory and how databases work, and I figured that someone here might be able to point me in the right direction a lot better than I could find it myself. Any idea how to fix this? My computer is new and relatively fancy, and I'd be surprised if it ran out of memory for this, so I don't know if reducing "shared memory usage" is the right idea (if I understand what's going on at all).

Edit: Should have put this up earlier. This is the command (building the database) that led to the error:

initdb /usr/local/var/postgres -E utf8

解决方案

From the database path, I guess you are using Mac OS X.

Since most popular Linux distros has a database directory reside in /var/lib.

After some search on Google, I found this: Fixing the postgresql initdb fatal shared memory error on Leopard

Hope it help.

I copied those instructions from the link above for your convenience.

Run these command:

sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216

Or edit /etc/sysctl.conf for permanent changes

kern.sysv.shmall=65536
kern.sysv.shmmax=16777216 

这篇关于PostgreSQL安装错误 - 无法分配内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆