PostgreSQL on RedHat Linux

From PostgreSQL wiki
Jump to navigationJump to search

If you have the packages already installed on your server, RedHat installation can be as easy as:

service postgresql start

In older versions you'll automatically get a call to service postgresql initdb the first time you do this that will create the database cluster; in recent versions you'll need to do that yourself before the above.

You can turn on and off whether PostgreSQL starts at boot like this:

chkconfig postgresql on/off

The default network configuration that RedHat initdb specifies uses the 'ident' mechanism for controlling access to the database, which is often not what people want. See Client Authentication for more information.

RedHat defaults to creating the database in /var/lib/pgsql/data. If you want to change that, or otherwise want to adjust the parameters uses when PostgreSQL is started, you can do that by editing /etc/sysconfig/pgsql/postgresql and putting changes into there. This is a standard shell script file included into the environment; here is a sample with the default parameters, you can pick just the lines from here you want to change and put new values there:

PGDATA=/var/lib/pgsql/data
PGPORT=5432
PGLOG=/var/lib/pgsql/pgstartup.log
PGOPTS=

PGOPTS can be used to set random other options; it is added to the end of the command line used to run the postmaster daemon. But note that any configuration parameters set this way cannot be changed on-the-fly while the postmaster is running. It's usually better to set custom values in postgresql.conf.

Also, if you want to change PGDATA from the default, be aware that the default SELinux configuration in recent Red Hat releases will prevent the postmaster daemon from writing anywhere except /var/lib/pgsql/data. You'll need to change the SELinux setup or at least relabel directory security contexts to put it someplace else. See PostgreSQL and SELinux for links to more information.

Recent Fedora versions

Starting in Fedora 16, the configuration of the server has been changed relative to the above. See the release notes for details.