3

I'm running a dedicated PostgreSQL on a 16GB Linode (Ubuntu 12.04 32bit). I've tried using pgtune, but I'll run into shared memory errors. I.e.

The PostgreSQL server failed to start. Please check the log output:
2014-02-10 08:32:39 EST FATAL:  could not create shared memory segment: Invalid argument
2014-02-10 08:32:39 EST DETAIL:  Failed system call was shmget(key=5432001, size=4107419648, 03600).
2014-02-10 08:32:39 EST 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 4107419648 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
    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

So I went ahead and started tweaking the SHMAX, but I'm really not sure what I should be setting this to. I was hoping pgtune would let me know or that I could find some documentation @ linode about this. I assume this value is in bytes? I've read it should be anything from 1/4 to 1/2 of the total memory (so 4 or 8 GB), but also that it shouldn't exceed 4GB when you're on 32bit.

Any advice? What would you recommending setting SHMAX to and why? Should I give up on pgtune, or pass a max memory param to it?

Thanks!

VPS Memory Details:

             total       used       free     shared    buffers     cached
Mem:      16617352     334320   16283032          0      18132     208400
-/+ buffers/cache:     107788   16509564
Swap:       524284          0     524284

-- Update --

Migrating to 64bit did basically make everything work. The SHMAX was being accepted (it's in bytes by the way). Figuring out what to set it to I just went with half of my available RAM on the box ("free -b" on Ubuntu to see memory in bytes).

I basically went with pgtune recommendations for the rest with a couple minor tweaks.

apt-get install pgtune
Dave Rapin
  • 133
  • 5

1 Answers1

9

You installed a 32-bit operating system on a machine with 16GB of RAM. This isn't going to work. Even if a 32-bit OS can technically use more than 4GB of RAM, no single process on the operating system can exceed that boundary. Start over and install a 64-bit operating system, and this problem will go away (along with all the other problems you're going to have).

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • Understood and thanks for the feedback. However as of right now barely any of the memory is being used, not even close to 4GB (334MB if you look at the numbers I posted). In fact the server's barely doing any work at all, so I think my first problem is a configuration one. So I suspect I will end up with this exact same problem even after spending the effort to migrate to 64bit. – Dave Rapin Feb 11 '14 at 13:20
  • Like you said, moving it to a 64bit system did magically solve all of the problems. Basically the SHMAX wasn't taking hold on 32bit, even though it was set below 4GB, but on 64bit now I've set it to 8GB and have gone with mostly pgtune recommended settings and it's working great. Lesson learned, stay away from using 32bit for a PostgreSQL box. – Dave Rapin Feb 12 '14 at 03:19
  • @DaveRapin It's 2012 -- Stay away from using 32bit operating systems for *anything* :) – voretaq7 Feb 13 '14 at 04:23