Thread: shared_buffers and shmall,shmmax

shared_buffers and shmall,shmmax

From
"Jie Liang"
Date:
Tom,
I am trying to tunrn my db server (p4 3.2GHzCPU, 2GB RAM on FreeBSD 5.5,
postgresql 8.1.4), I am trying to increase the share_buffer to 512M 1/4
of RAM, so I set it to shared_buffers=65536 (512M), then failed to
start, then I reduce to 60000,40000,30000, it failed to start database
until 20000.

Following is my kernel:
kern.ipc.maxsockbuf: 262144
kern.ipc.sockbuf_waste_factor: 8
kern.ipc.somaxconn: 128
kern.ipc.semaem: 16384
kern.ipc.semvmx: 32767
kern.ipc.semusz: 344
kern.ipc.semume: 40
kern.ipc.semopm: 100
kern.ipc.semmsl: 240
kern.ipc.semmnu: 120
kern.ipc.semmns: 240
kern.ipc.semmni: 40
kern.ipc.semmap: 30
kern.ipc.shm_allow_removed: 0
kern.ipc.shm_use_phys: 0
kern.ipc.shmall: 65536
kern.ipc.shmseg: 128
kern.ipc.shmmni: 192
kern.ipc.shmmin: 1
kern.ipc.shmmax: 536870912
kern.ipc.numopensockets: 117
kern.ipc.maxsockets: 25600


shmmax is 512M
shmall is 65536 page

following is my pgsql.log:

Jan 25 09:52:09 iguard postgres[49577]: [7-1] FATAL:  terminating
connection due to administrator command
Jan 25 09:52:09 iguard postgres[46784]: [15-1] FATAL:  terminating
connection due to administrator command
Jan 25 09:52:09 iguard postgres[49439]: [12-1] FATAL:  terminating
connection due to administrator command
Jan 25 09:54:00 iguard postgres[49909]: [1-3] HINT:  This error usually
means that PostgreSQL's request for a shared memory segment exceeded
your kernel's SHMMAX parameter.
Jan 25 09:54:00 iguard postgres[49909]: [1-4]  You can either reduce the
request size or reconfigure the kernel with larger SHMMAX.  To reduce
the request size (currently
Jan 25 09:54:00 iguard postgres[49909]: [1-5]  607731712 bytes), reduce
PostgreSQL's shared_buffers parameter (currently 65535) and/or its
max_connections parameter
Jan 25 09:54:00 iguard postgres[49909]: [1-6]  (currently 120).
Jan 25 09:54:00 iguard postgres[49909]: [1-7]   If the request size is
already small, it's possible that it is less than your kernel's SHMMIN
parameter, in which case raising
Jan 25 09:54:00 iguard postgres[49909]: [1-8]  the request size or
reconfiguring SHMMIN is called for.
Jan 25 09:54:00 iguard postgres[49909]: [1-9]   The PostgreSQL
documentation contains more information about shared memory
configuration.
Jan 25 09:54:31 iguard postgres[49919]: [1-1] FATAL:  could not create
shared memory segment: Invalid argument
Jan 25 09:54:31 iguard postgres[49919]: [1-2] DETAIL:  Failed system
call was shmget(key=5432001, size=561455104, 03600).
Jan 25 09:54:31 iguard postgres[49919]: [1-3] HINT:  This error usually
means that PostgreSQL's request for a shared memory segment exceeded
your kernel's SHMMAX parameter.
Jan 25 09:54:31 iguard postgres[49919]: [1-4]  You can either reduce the
request size or reconfigure the kernel with larger SHMMAX.  To reduce
the request size (currently
Jan 25 09:54:31 iguard postgres[49919]: [1-5]  561455104 bytes), reduce
PostgreSQL's shared_buffers parameter (currently 60000) and/or its
max_connections parameter
Jan 25 09:54:31 iguard postgres[49919]: [1-6]  (currently 120).
Jan 25 09:54:31 iguard postgres[49919]: [1-7]   If the request size is
already small, it's possible that it is less than your kernel's SHMMIN
parameter, in which case raising
Jan 25 09:54:31 iguard postgres[49919]: [1-8]  the request size or
reconfiguring SHMMIN is called for.
Jan 25 09:54:31 iguard postgres[49919]: [1-9]   The PostgreSQL
documentation contains more information about shared memory
configuration.
Jan 25 09:55:00 iguard postgres[49929]: [1-1] FATAL:  could not create
shared memory segment: Cannot allocate memory
Jan 25 09:55:00 iguard postgres[49929]: [1-2] DETAIL:  Failed system
call was shmget(key=5432001, size=394256384, 03600).
Jan 25 09:55:00 iguard postgres[49929]: [1-3] HINT:  This error usually
means that PostgreSQL's request for a shared memory segment exceeded
available memory or swap space.
Jan 25 09:55:00 iguard postgres[49929]: [1-4]  To reduce the request
size (currently 394256384 bytes), reduce PostgreSQL's shared_buffers
parameter (currently 40000) and/or
Jan 25 09:55:00 iguard postgres[49929]: [1-5]  its max_connections
parameter (currently 120).
Jan 25 09:55:00 iguard postgres[49929]: [1-6]   The PostgreSQL
documentation contains more information about shared memory
configuration.
Jan 25 09:55:34 iguard postgres[49953]: [1-1] FATAL:  could not create
shared memory segment: Cannot allocate memory
Jan 25 09:55:34 iguard postgres[49953]: [1-2] DETAIL:  Failed system
call was shmget(key=5432001, size=310394880, 03600).
Jan 25 09:55:34 iguard postgres[49953]: [1-3] HINT:  This error usually
means that PostgreSQL's request for a shared memory segment exceeded
available memory or swap space.
Jan 25 09:55:34 iguard postgres[49953]: [1-4]  To reduce the request
size (currently 310394880 bytes), reduce PostgreSQL's shared_buffers
parameter (currently 30000) and/or
Jan 25 09:55:34 iguard postgres[49953]: [1-5]  its max_connections
parameter (currently 120).
Jan 25 09:55:34 iguard postgres[49953]: [1-6]   The PostgreSQL
documentation contains more information about shared memory
configuration.
Jan 25 09:56:17 iguard postgres[49970]: [1-1] LOG:  database system was
shut down at 2007-01-25 09:52:09 PST
Jan 25 09:56:17 iguard postgres[49970]: [2-1] LOG:  checkpoint record is
at 14B/649807D0
Jan 25 09:56:17 iguard postgres[49970]: [3-1] LOG:  redo record is at
14B/649807D0; undo record is at 0/0; shutdown TRUE
Jan 25 09:56:17 iguard postgres[49970]: [4-1] LOG:  next transaction ID:
4566517; next OID: 361483975
Jan 25 09:56:17 iguard postgres[49970]: [5-1] LOG:  next MultiXactId: 1;
next MultiXactOffset: 0
Jan 25 09:56:17 iguard postgres[49970]: [6-1] LOG:  database system is
ready
Jan 25 09:56:17 iguard postgres[49970]: [7-1] LOG:  transaction ID wrap
limit is 1077475224, limited by database "urldbdev"
Jan 25 09:57:00 iguard postgres[49988]: [1-1] LOG:  statement: SELECT
count(*) FROM public.unchecked WHERE allocatedto IS NULL OR allocatedto
= 'EX'
Jan 25 09:57:12 iguard postgres[49969]: [1-1] LOG:  received fast
shutdown request
Jan 25 09:57:12 iguard postgres[49971]: [1-1] LOG:  shutting down
Jan 25 09:57:12 iguard postgres[49971]: [2-1] LOG:  database system is
shut down
Jan 25 09:57:13 iguard postgres[49997]: [1-1] FATAL:  could not create
shared memory segment: Cannot allocate memory
Jan 25 09:57:13 iguard postgres[49997]: [1-2] DETAIL:  Failed system
call was shmget(key=5432001, size=310394880, 03600).
Jan 25 09:57:13 iguard postgres[49997]: [1-3] HINT:  This error usually
means that PostgreSQL's request for a shared memory segment exceeded
available memory or swap space.
Jan 25 09:57:13 iguard postgres[49997]: [1-4]  To reduce the request
size (currently 310394880 bytes), reduce PostgreSQL's shared_buffers
parameter (currently 30000) and/or
Jan 25 09:57:13 iguard postgres[49997]: [1-5]  its max_connections
parameter (currently 120).
Jan 25 09:57:13 iguard postgres[49997]: [1-6]   The PostgreSQL
documentation contains more information about shared memory
configuration.
Jan 25 09:58:20 iguard postgres[50012]: [1-1] LOG:  database system was
shut down at 2007-01-25 09:57:12 PST
Jan 25 09:58:20 iguard postgres[50012]: [2-1] LOG:  checkpoint record is
at 14B/64980820
Jan 25 09:58:20 iguard postgres[50012]: [3-1] LOG:  redo record is at
14B/64980820; undo record is at 0/0; shutdown TRUE
Jan 25 09:58:20 iguard postgres[50012]: [4-1] LOG:  next transaction ID:
4566519; next OID: 361483975
Jan 25 09:58:20 iguard postgres[50012]: [5-1] LOG:  next MultiXactId: 1;
next MultiXactOffset: 0
Jan 25 09:58:20 iguard postgres[50012]: [6-1] LOG:  database system is
ready


Question:
How come that shared_buffers=40000 (or 30000), which request size
394256384 (or 310394880) bytes is much lower then shmmax(536870912
bytes), and max_connection is set to 125 still failed to start
postmaster?


Thanks,

Best regards,

Jie Liang



Re: shared_buffers and shmall,shmmax

From
"Jie Liang"
Date:
Tom,
Sorry, it's 4kb, that explain it.

Thank you,

Regards,

Jie Liang

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thursday, January 25, 2007 12:15 PM
To: Jie Liang
Cc: pgsql-sql@postgresql.org
Subject: Re: shared_buffers and shmall,shmmax

> shmall is 65536 page

And how big is a page?
        regards, tom lane