Database Reference
In-Depth Information
Don't Give Full OS Administrative Rights to the Postgres System
Account (postgres)
Many people are under the misconception that the
postgres
account needs to have full
administrative rights to the server. In fact, depending on your PostgreSQL version, if
you give the
postgres
account full administrative rights to the server, your database
server might not even start.
The
postgres
account should always be created as a regular system user in the OS with
rights just to the data cluster and additional tablespace folders. Most installers will set
up the correct permissions without you needing to worry. Don't try to do
postgres
any
favors by giving it more rights than it needs. Granting unnecessary rights leaves your
system vulnerable if you fall under an SQL injection attack.
There are cases where you'll need to give the
postgres
account write/delete/read rights
to folders or executables outside of the data cluster. With scheduled jobs that execute
batch files, this need often arises. We advise you to practice restraint and bestow only
the minimum rights necessary to get the job done.
Don't Set shared_buffers Too High
Loading up your server with RAM doesn't mean you can set the
shared_buffers
as
high as your physical RAM. Try it and your server may crash or refuse to start. If you
are running PostgreSQL on 32-bit Windows, setting it higher than 512 MB often results
in instability. With 64-bit Windows, you can push the envelop a bit higher and can even
exceed 1 GB without any issues. On some Linux systems,
shared_buffers
can't be set
higher than the compiled
SHMMAX
variable, which is usually quite low. PostgreSQL 9.3
changed how kernel memory is used, so that many of the issues people ran into with
kernel limitations in prior versions are nonissues in version 9.3. You can find more
details in
Kernel Resources
.
Don't Try to Start PostgreSQL on a Port Already in Use
If you try to start PostgreSQL on a port that's already in use, you'll see errors in your
pg_log
files of the form:
make sure PostgreSQL is not already running
. Here are
the common reasons why this happens:
• You've already started the
postgres
service.
• You are trying to run PostgreSQL on a port already in use by another service.
• Your
postgres
service had a sudden shutdown and you have an orphan
post
gresql.pid
file in the data folder. Just delete the file and try again.
• You have an orphaned PostgreSQL process. When all else fails, kill all running
PostgreSQL processes and then try starting again.