PostgreSQL – Setting shared_buffers Over 320 MB Prevents Restart

configurationmemorypostgresql

I'm running Postgres 8.1 on a CentOS 5 system with 4 GB of RAM. Whenever I set shared_buffers above 320 MB, it won't run.

I've checked SHMMAX and it's at 4294967295 which is the max allowed for a 32-bit/4 GB system. Below are some of the other memory related settings:

max_connections = 225
shared_buffers = 327680
work_mem = 524288
max_fsm_pages = 500000
max_fsm_relations = 10000

Any suggestions on what could improve this?

Best Answer

Just a misunderstanding I guess. The unit for the given number is blocks (or buffers), not 1 kb like you assume.
Quoting the manual for shared_buffers:

Each buffer is 8192 bytes, unless a different value of BLCKSZ was chosen when building the server.

Bold emphasis mine.

SELECT pg_size_pretty(327680 *  8192::numeric);

pg_size_pretty
--------------
2560 MB

Not 320 MB. In modern Postgres the syntax with appended unit is preferred: 320MB, but I don't think that's implemented in the ancient Postgres 8.1, yet. For 320 MB set the GUC to:

shared_buffers = 40960

Have you considered installing a modern version of Postgres? (Like has been hinted in the comments ever so gently). Postgres 8.1 was released 10 years ago.