FAQ

[PostgreSQL-Admin] Shared memory error using initdb on Solaris 8

Kevin Schroeder
May 21, 2004 at 3:13 pm
Hello,
I'm trying to install PostgreSQL 7.4.2 on a brand new SunFire 120 with
2GB of RAM but when I run initdb -D /usr/local/pgsql/data I get the
following error:

creating directory /usr/local/pgsql/data... ok
creating directory /usr/local/pgsql/data/base... ok
creating directory /usr/local/pgsql/data/global... ok
creating directory /usr/local/pgsql/data/pg_xlog... ok
creating directory /usr/local/pgsql/data/pg_clog... ok
selecting default max_connections... 10
selecting default shared_buffers... 50
creating configuration files... ok
creating template1 database in /usr/local/pgsql/data/base/1... FATAL: could
not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(key=1, size=1081344, 03600).
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 1081344 bytes), reduce PostgreSQL's
shared_buffers parameter (currently 50) and/or its max_connections parameter
(currently 10).
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.

initdb: failed
initdb: removing data directory "/usr/local/pgsql/data"

When I run ulimit -a I get

time(seconds) unlimited
file(blocks) unlimited
data(kbytes) unlimited
stack(kbytes) 8192
coredump(blocks) 0
nofiles(descriptors) 256
vmemory(kbytes) unlimited

There does not seem to be an option in initdb to reduce the shared buffers
size. Plus, with 2GB of RAM I don't know that I'd want to go below the
"lowest common denominator" that Postgres defaults to.

Kevin
reply

Search Discussions

5 responses

  • Jim Seymour at May 21, 2004 at 3:57 pm

    Hello,
    I'm trying to install PostgreSQL 7.4.2 on a brand new SunFire 120 with
    2GB of RAM but when I run initdb -D /usr/local/pgsql/data I get the
    following error: [snip]
    creating template1 database in /usr/local/pgsql/data/base/1... FATAL: could
    not create shared memory segment: Invalid argument
    DETAIL: Failed system call was shmget(key=1, size=1081344, 03600).
    HINT: This error usually means that PostgreSQL's request for a shared
    memory segment exceeded your kernel's SHMMAX parameter. [snip]
    When I run ulimit -a I get
    [snip]

    You're looking at the wrong thing. You need to do:

    sysdef |egrep -i 'shm|sem'
    There does not seem to be an option in initdb to reduce the shared buffers
    size.
    It tries to reduce things as far as it "sanely" can to fit within
    what's available. You can hand-tweak initdb to over-ride its
    limits, but you'd end-up with a sub-optimal installation.
    Plus, with 2GB of RAM I don't know that I'd want to go below the
    "lowest common denominator" that Postgres defaults to.
    Nope. You need to adjust certain values by placing settings in
    /etc/system and rebooting. I use:

    /etc/system
    set shmsys:shminfo_shmmax=0x2000000 (33554432 decimal)
    set shmsys:shminfo_shmmin=1
    set shmsys:shminfo_shmmni=256
    set shmsys:shminfo_shmseg=256

    set semsys:seminfo_semmap=256
    set semsys:seminfo_semmni=512
    set semsys:seminfo_semmns=512
    set semsys:seminfo_semmsl=32

    I arrived at the above values from Google'ing.

    Jim
  • Kevin Schroeder at May 21, 2004 at 4:59 pm
    There we go. For reference, what page did you get that info and what did
    you search for to get it?

    Kevin

    ----- Original Message -----
    From: "Jim Seymour" <jseymour@LinxNet.com>
    To: <pgsql-admin@postgresql.org>
    Sent: Friday, May 21, 2004 10:57 AM
    Subject: Re: [ADMIN] Shared memory error using initdb on Solaris 8

    Hello,
    I'm trying to install PostgreSQL 7.4.2 on a brand new SunFire 120
    with
    2GB of RAM but when I run initdb -D /usr/local/pgsql/data I get the
    following error: [snip]
    creating template1 database in /usr/local/pgsql/data/base/1... FATAL:
    could
    not create shared memory segment: Invalid argument
    DETAIL: Failed system call was shmget(key=1, size=1081344, 03600).
    HINT: This error usually means that PostgreSQL's request for a shared
    memory segment exceeded your kernel's SHMMAX parameter. [snip]
    When I run ulimit -a I get
    [snip]

    You're looking at the wrong thing. You need to do:

    sysdef |egrep -i 'shm|sem'
    There does not seem to be an option in initdb to reduce the shared
    buffers
    size.
    It tries to reduce things as far as it "sanely" can to fit within
    what's available. You can hand-tweak initdb to over-ride its
    limits, but you'd end-up with a sub-optimal installation.
    Plus, with 2GB of RAM I don't know that I'd want to go below the
    "lowest common denominator" that Postgres defaults to.
    Nope. You need to adjust certain values by placing settings in
    /etc/system and rebooting. I use:

    /etc/system
    set shmsys:shminfo_shmmax=0x2000000 (33554432 decimal)
    set shmsys:shminfo_shmmin=1
    set shmsys:shminfo_shmmni=256
    set shmsys:shminfo_shmseg=256

    set semsys:seminfo_semmap=256
    set semsys:seminfo_semmni=512
    set semsys:seminfo_semmns=512
    set semsys:seminfo_semmsl=32

    I arrived at the above values from Google'ing.

    Jim

    ---------------------------(end of broadcast)---------------------------
    TIP 5: Have you checked our extensive FAQ?

    http://www.postgresql.org/docs/faqs/FAQ.html
  • Jim Seymour at May 21, 2004 at 6:16 pm

    There we go. For reference, what page did you get that info and what did
    you search for to get it?
    Like I said: I derived it all from Google'ing on various search
    terms, IIRC. Probably things like "postgresql+Solaris+shmmax" and
    the like. I didn't save any URL references.

    Jim
  • Kevin Schroeder at May 21, 2004 at 6:35 pm
    Searching Google brought up this page.

    http://www.postgresql.org/docs/current/interactive/kernel-resources.html



    ----- Original Message -----
    From: "Jim Seymour" <jseymour@LinxNet.com>
    To: <pgsql-admin@postgresql.org>
    Sent: Friday, May 21, 2004 1:14 PM
    Subject: Re: [ADMIN] Shared memory error using initdb on Solaris 8

    There we go. For reference, what page did you get that info and what
    did
    you search for to get it?
    Like I said: I derived it all from Google'ing on various search
    terms, IIRC. Probably things like "postgresql+Solaris+shmmax" and
    the like. I didn't save any URL references.

    Jim

    ---------------------------(end of broadcast)---------------------------
    TIP 8: explain analyze is your friend
  • Steve Lane at May 22, 2004 at 3:33 pm
    Apologies in advance for the somewhat off-topic post. This is quite a
    sophisticated group so it strikes me as the right group of people to ask.

    I'm trying to find someone experienced in scaling open-source,
    database-backed web applications. Particularly, I have an application based
    on Linux-Apache-PHP-Postgres, that my customer would like to scale to
    support 500 simultaneous users (by which they do mean 500 simultaneous
    submits, since the app gets used that way).

    I'd like to find someone who has done this, minimally with Apache and other
    middleware + db, ideally with PHP and more ideally with PHP-postgres. I need
    it to be someone who has actually done it, as opposed to someone with a
    theoretical knowledge of how it should be done.

    If you are such a person, or you know of one, can you please email me
    offline at slane@moyegroup.com?

    -- sgl

Related Discussions

Discussion Navigation
viewthread | post