First of all, I want to remind you that PGDG layout is very different than Fedora package layout. Fedora packages traditionally supported only one version installation, where the PGDG packages has been more or less supporting multiple version installation as of 9.0 (thoug 8.4 is also available for RHEL 6 users, so that they don't miss the train): The installation files are under
/usr/pgsql-X.Y,
where X.Y are the major version numbers, like 9.1, 9.2). We symlinked some binaries under /usr/bin using the alternatives method -- so on upgrades, you will pick up the latest version.
This difference also applies to the data directory location, though not as different as above: We are using
/var/lib/pgsql/X.Y, and we have
/var/lib/pgsql/X.Y/data for the data files by default.
Let's start with installing it. Install repo RPM first:
http://yum.postgresql.org/repopackages.php
For example, if you want to install 9.2 on Fedora 17, here is the command that you will use:
rpm -ivh http://yum.postgresql.org/9.2/fedora/fedora-17-x86_64/pgdg-fedora92-9.2-5.noarch.rpm
Now, you can install PostgreSQL:
yum -y install postgresql92-server postgresql92-contrib
In the SysV versions, users used to run initdb along with the service command: service postgresql-9.2 initdb
However, I followed Tom's changes here, and added a new script. To initialize the cluster, you need to run:
/usr/pgsql-X.Y/bin/postgresqlXY-setup initdb
like:
/usr/pgsql-9.2/bin/postgresql92-setup initdb
This command will initdb the cluster. Please note that this script includes an "upgrade" option, but it is broken as of now on my scripts, and in the very todo list.
Systemd brings the concept of unit files, which replaces init scripts. PostgreSQL unit file is
/usr/lib/systemd/system/postresql-X.Y.service
so changes should be done there.
Now, we can start PostgreSQL:
systemctl start postgresql-X.Y.service
If you want to change the port that PostgreSQL is running, you need two steps:
- postgresql.conf
- Copy unit file under /etc/systemd/system and edit it there.
This is a comment from /usr/lib/systemd/system/postresql.service in Fedora18 official postgresql-server package:
# For example, if you want to change the server's port number to 5433,
# create a file named "/etc/systemd/system/postgresql.service" containing:
# .include /lib/systemd/system/postgresql.service
# [Service]
# Environment=PGPORT=5433
# This will override the setting appearing below.
And remember to run systemctl daemon-reload when you add new service files.
If you want to reload/stop/restart the database, please use
systemcl reload/stop/restart postgresql-X.Y.service
Please let me know if you have any questions/comments.