Обсуждение: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory

Поиск
Список
Период
Сортировка

[Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory

От
Yvon Thoraval
Дата:

I've just installed PostgreSQL, using brew, on Mac OS Mountain Lion.
The server doesn't start and the log file shows :

$ cat /usr/local/var/postgres/server.log
FATAL:  could not create shared memory segment: Cannot allocate memory
DETAIL:  Failed system call was shmget(key=5432002, size=3809280, 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 3809280 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
The PostgreSQL documentation contains more information about shared memory configuration.


I have been using psql before, on Lion, without this kind of prob.

What is the workaround ?

--
Yvon


Re: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory

От
John R Pierce
Дата:
On 10/07/12 6:30 AM, Yvon Thoraval wrote:
>
> What is the workaround ?

exactly what the error says to do, increase SHMMAX and SHMMAL in your
kernel configuration.   on differnet unix-like systems you do this
differently (/etc/system on vintage Solaris, /etc/sysctl.conf on most
Linux distros, etc).


--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast



Re: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory

От
Scott Marlowe
Дата:
On Sun, Oct 7, 2012 at 7:30 AM, Yvon Thoraval <yvon.thoraval@gmail.com> wrote:
>
> I've just installed PostgreSQL, using brew, on Mac OS Mountain Lion.
> The server doesn't start and the log file shows :
>
> $ cat /usr/local/var/postgres/server.log
> FATAL:  could not create shared memory segment: Cannot allocate memory
> DETAIL:  Failed system call was shmget(key=5432002, size=3809280, 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 3809280 bytes), reduce PostgreSQL's shared memory usage, perhaps
> by reducing shared_buffers or max_connections.
> The PostgreSQL documentation contains more information about shared memory
> configuration.

http://www.postgresql.org/docs/9.2/static/kernel-resources.html


Re: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory

От
Yvon Thoraval
Дата:




OK, fine thanks to both.

I've found a page dealing with that prob :

The points are to :

Easy to fix; run:

sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216
(The first one's the critical one for me, but second seems appropriate too.)

This changes the limits in the currently-running kernel. To make these values stick across reboots, add them to /etc/sysctl.conf, like this:

kern.sysv.shmall=65536
kern.sysv.shmmax=16777216
(Create this file if it doesn't already exist – it doesn't on fresh Leopard installs.)
--
Yvon


Re: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory

От
Scott Marlowe
Дата:
On Sun, Oct 7, 2012 at 1:59 PM, Yvon Thoraval <yvon.thoraval@gmail.com> wrote:
>
>
> 2012/10/7 Scott Marlowe <scott.marlowe@gmail.com>
>>
>> http://www.postgresql.org/docs/9.2/static/kernel-resources.html
>
> OK, fine thanks to both.
>
> I've found a page dealing with that prob :
> Fixing the postgresql initdb fatal shared memory error on Leopard

I'd have posted more, but

1: I know just enough about MacOS to be dangerous and
2: MacOS is known for changing how shared memory works from one minor
patch to another so..
3: Any page on making work will be dependent on the exact MacOS
version you are running.


Re: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory

От
Yvon Thoraval
Дата:


2012/10/7 Scott Marlowe <scott.marlowe@gmail.com>
'd have posted more, but

1: I know just enough about MacOS to be dangerous and
2: MacOS is known for changing how shared memory works from one minor
patch to another so..
3: Any page on making work will be dependent on the exact MacOS
version you are running.

In fact i had already installed PostgreSQL on mac os x Lion, recently i upgraded to mac os x mountain lion.
And also switching to a brew install of Postgres.
I don't why but it is more difficult, on Mountain Lion, than on Lion.
And also far more difficult than on (X)Ubuntu 12.04.

On Lion and Ubuntu i had only to change postgresql.conf and pg_hba.conf.

But here with ML (Mountain Lion) the server is running but not accepting connection :
$ psgrep postgres     
yt             47140   0,0  0,0  2444240    520   ??  Ss    1:20     0:00.00 postgres: wal writer process     
yt             47139   0,0  0,0  2444240    564   ??  Ss    1:20     0:00.05 postgres: writer process     
yt             47138   0,0  0,0  2444240    588   ??  Ss    1:20     0:00.00 postgres: checkpointer process     
yt             47136   0,0  0,1  2444240   3696 s002  S+    1:20     0:00.02 postgres -D /usr/local/var/postgres
yt             47142   0,0  0,0  2440520    400   ??  Ss    1:20     0:00.00 postgres: stats collector process     
yt             47141   0,0  0,0  2444372   1528   ??  Ss    1:20     0:00.00 postgres: autovacuum launcher process     

(my psgrep is an alias of 'ps aux | grep -v grep | grep')

$  psql -p 5433
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5433"?

the socket is here :

/var/pgsql_socket $ ls -al
drwxr-xr-x   5 yt    wheel  170  8 oct 01:27 .
drwxr-xr-x  26 root  wheel  884  7 oct 14:00 ..
-rw-r--r--   1 yt    wheel  313  8 oct 01:08 .profile
srwxrwxrwx   1 yt    wheel    0  8 oct 01:27 .s.PGSQL.5433
-rw-------   1 yt    wheel   64  8 oct 01:27 .s.PGSQL.5433.lock


no socket at all in /tmp...

It's to late : 2 hours in the early morning here in Paris...


--
Yvon


Re: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory

От
Ralf Schuchardt
Дата:

Am 08.10.2012 um 02:08 schrieb Yvon Thoraval <yvon.thoraval@gmail.com>:

2012/10/7 Scott Marlowe <scott.marlowe@gmail.com>
'd have posted more, but

1: I know just enough about MacOS to be dangerous and
2: MacOS is known for changing how shared memory works from one minor
patch to another so..
3: Any page on making work will be dependent on the exact MacOS
version you are running.

Using sysctl to set the shm* values has consistently worked for us in the last years ...

In fact i had already installed PostgreSQL on mac os x Lion, recently i upgraded to mac os x mountain lion.
And also switching to a brew install of Postgres.
I don't why but it is more difficult, on Mountain Lion, than on Lion.
And also far more difficult than on (X)Ubuntu 12.04.

On Lion and Ubuntu i had only to change postgresql.conf and pg_hba.conf.

But here with ML (Mountain Lion) the server is running but not accepting connection :
$ psgrep postgres     
yt             47140   0,0  0,0  2444240    520   ??  Ss    1:20     0:00.00 postgres: wal writer process     
yt             47139   0,0  0,0  2444240    564   ??  Ss    1:20     0:00.05 postgres: writer process     
yt             47138   0,0  0,0  2444240    588   ??  Ss    1:20     0:00.00 postgres: checkpointer process     
yt             47136   0,0  0,1  2444240   3696 s002  S+    1:20     0:00.02 postgres -D /usr/local/var/postgres
yt             47142   0,0  0,0  2440520    400   ??  Ss    1:20     0:00.00 postgres: stats collector process     
yt             47141   0,0  0,0  2444372   1528   ??  Ss    1:20     0:00.00 postgres: autovacuum launcher process     

(my psgrep is an alias of 'ps aux | grep -v grep | grep')

$  psql -p 5433
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5433"?

the socket is here :

/var/pgsql_socket $ ls -al
drwxr-xr-x   5 yt    wheel  170  8 oct 01:27 .
drwxr-xr-x  26 root  wheel  884  7 oct 14:00 ..
-rw-r--r--   1 yt    wheel  313  8 oct 01:08 .profile
srwxrwxrwx   1 yt    wheel    0  8 oct 01:27 .s.PGSQL.5433
-rw-------   1 yt    wheel   64  8 oct 01:27 .s.PGSQL.5433.lock


no socket at all in /tmp...

Mountain Lion comes with it's own version of PostgreSQL. The included psql command probably searches for unix sockets in a different place than your self compiled version. Is your path correctly set?

Ralf

Вложения

Re: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory

От
Yvon Thoraval
Дата:


2012/10/8 Ralf Schuchardt <rasc@gmx.de>


Using sysctl to set the shm* values has consistently worked for us in the last years ...

probably i missed that point because my last install of postgres was on ubuntu...
 

Mountain Lion comes with it's own version of PostgreSQL. The included psql command probably searches for unix sockets in a different place than your self compiled version. Is your path correctly set?

right, the client only.
my path is correctly set, resarting the computer helps.
i'm now able to connect using tcp/ip :
$ psql -h localhost -p 5433 -U yt -d yt_tests
psql (9.2.1)
Type "help" for help.

yt_tests=# CREATE EXTENSION unaccent;
CREATE EXTENSION
yt_tests=# select unaccent('Hôtel');
 unaccent 
----------
 Hotel
(1 row) 

may be something was wrong with postmaster.pid and the socket ?
unclear to me but it "seems" to work right now.

--
Yvon