27aa74
README.rpm-dist
27aa74
-----------------------------------------------------------------------------
27aa74
Version 9.2, for the PostgreSQL 9.2 RPM set.
27aa74
Devrim Gündüz <devrim@gunduz.org>
27aa74
-----------------------------------------------------------------------------
27aa74
27aa74
Contents:
27aa74
 1.)	Introduction and QuickStart
27aa74
 2.)	Upgrading an installation
27aa74
 3.)	PostgreSQL RPM packages and rationale
27aa74
 4.)	Starting multiple postmasters
27aa74
 5.)	Regression Testing
27aa74
 6.)	Starting postmaster automatically on startup
27aa74
 7.)	Grand Unified Configuration(GUC) File
27aa74
 8.)	Logging set up
27aa74
 9.)	Rebuilding from the source RPM
27aa74
10.)	Contrib files
27aa74
11.)	Further Information Resource
27aa74
27aa74
INTRODUCTION
27aa74
-----------------------------------------------------------------------------
27aa74
This document exists to explain the layout of the RPMs for PostgreSQL, to 
27aa74
describe various RPM specifics, and to document special features found
27aa74
in the RPMset.
27aa74
27aa74
This document is written to be applicable to version 9.2 of PostgreSQL,
27aa74
which is the current version of the RPMs as of this writing. More to the 
27aa74
point, versions prior to 9.2 are not documented here.
27aa74
27aa74
This document is intended for use only with the RPMs supplied in Red Hat
27aa74
Enterprise Linux, CentOS and Fedora.  Note that there are also "PGDG"
27aa74
RPMs available directly from the upstream PostgreSQL project.  Those are
27aa74
slightly different.
27aa74
27aa74
QUICKSTART (note that this requires postgresql-server installed)
27aa74
-----------------------------------------------------------------------------
27aa74
For a fresh installation, you will need to initialize the cluster first. Run:
27aa74
27aa74
	postgresql-setup initdb
27aa74
27aa74
as root, and it will prepare a new database cluster for you. Then you will 
27aa74
need to start PostgreSQL. Again as root, run:
27aa74
27aa74
	systemctl start postgresql.service
27aa74
27aa74
This command will start a postmaster that willl listen on localhost and Unix 
27aa74
socket 5432 only.  Edit /var/lib/pgsql/data/postgresql.conf and pg_hba.conf 
27aa74
if you want to allow remote access -- see the section on Grand Unified 
27aa74
Configuration.
27aa74
27aa74
You will probably also want to do
27aa74
27aa74
	systemctl enable postgresql.service
27aa74
27aa74
so that the postmaster is automatically started during future reboots.
27aa74
27aa74
The file /var/lib/pgsql/.bash_profile is packaged to help with the 
27aa74
setting of environment variables. You may edit this file, and it won't be
27aa74
overwritten during an upgrade.  However, enhancements and bugfixes may 
27aa74
be added to this file, so be sure to check .bash_profile.rpmnew after 
27aa74
upgrading.
27aa74
27aa74
The user 'postgres' is created during installation of the server subpackage.
27aa74
This user by default is UID and GID 26. The user has the default shell set to
27aa74
bash, and the home directory set to /var/lib/pgsql.  This user also has no
27aa74
default password, so the only way to become this user is to su to it from root.
27aa74
If you want to be able to su to it from a non-root account or log in directly
27aa74
as 'postgres' you will need to set a password using passwd.
27aa74
27aa74
UPGRADING AN INSTALLATION
27aa74
-----------------------------------------------------------------------------
27aa74
For a minor-version upgrade (such as 9.2.1 to 9.2.2), just install the
27aa74
new RPMs; there's usually nothing more to it than that.  Upgrading
27aa74
across a major release of PostgreSQL (for example, from 9.1.x to 9.2.x)
27aa74
requires more effort.
27aa74
27aa74
If you are upgrading across more than one major release of PostgreSQL
27aa74
(for example, from 8.3.x to 9.0.x), you will need to follow the "traditional"
27aa74
dump and reload process to bring your data into the new version.  That is:
27aa74
*before* upgrading, run pg_dumpall to extract all your data into a SQL file.
27aa74
Shut down the old postmaster, upgrade to the new version RPMs, initdb,
27aa74
and run the dump file through psql to restore your data.
27aa74
27aa74
In some major releases, the RPMs also support in-place upgrade from the
27aa74
immediately previous major release.  Currently, you can upgrade in-place
27aa74
from 9.1.x to 9.2.x.  This is much faster than a dump and reload.
27aa74
To do an in-place upgrade:
27aa74
* shut down the old postmaster ("systemctl stop postgresql.service")
27aa74
* optionally make a backup of /var/lib/pgsql/data/ (recommended!)
27aa74
* install the new version's RPMs (install all the ones you had before,
27aa74
  plus postgresql-upgrade)
27aa74
* as root, run "postgresql-setup upgrade"
27aa74
* update the configuration files /var/lib/pgsql/data/*.conf with any
27aa74
  customizations you had before (your old configuration files are in
27aa74
  /var/lib/pgsql/data-old/)
27aa74
* as root, run "systemctl start postgresql.service"
27aa74
* the postgresql-upgrade RPM can be removed after the update is complete,
27aa74
  as can /var/lib/pgsql/data-old/
27aa74
27aa74
NOTE: The in-place upgrade process is new and relatively poorly tested,
27aa74
so if your data is critical it's a really good idea to make a tarball
27aa74
backup of /var/lib/pgsql/data/ before running the upgrade.  This will
27aa74
let you get back to where you were in case of disaster.
27aa74
27aa74
POSTGRESQL RPM PACKAGES AND RATIONALE.
27aa74
-----------------------------------------------------------------------------
27aa74
PostgreSQL is split up into multiple packages so that users can 'pick and
27aa74
choose' what pieces are needed, and what dependencies are required.
27aa74
27aa74
The RPMset is packaged in the following subpackages:
27aa74
27aa74
postgresql:		Key client programs and documentation
27aa74
postgresql-libs:	Client shared libraries
27aa74
postgresql-server:	Server executables and data files
27aa74
postgresql-devel:	Development libraries and include files
27aa74
postgresql-test:	The regression tests and associated files
27aa74
postgresql-upgrade:	Support files for upgrading from previous major version
27aa74
postgresql-docs:	Extra documentation, such as the tutorial files
27aa74
postgresql-contrib:	Add-on loadable modules and programs
27aa74
postgresql-plperl:	PL/Perl procedural language
27aa74
postgresql-plpython:	PL/Python procedural language (for Python 2)
27aa74
postgresql-plpython3:	PL/Python procedural language (for Python 3)
27aa74
postgresql-pltcl:	PL/Tcl procedural language
27aa74
27aa74
You have to install postgresql and postgresql-libs to do anything.
27aa74
postgresql-server is needed unless you only plan to use the clients to work
27aa74
with a remote PostgreSQL server. The others are optional.
27aa74
27aa74
Note that there are no postgresql-perl, postgresql-jdbc, postgresql-odbc,
27aa74
postgresql-python, postgresql-tcl, or postgresql-tk subpackages any longer.
27aa74
Those programs have been split off into separate source distributions.
27aa74
They are still available, but in some cases not under those RPM names.
27aa74
27aa74
RPM FILE LOCATIONS.
27aa74
-----------------------------------------------------------------------------
27aa74
To be in compliance with the Linux FHS, the PostgreSQL RPMs install files in
27aa74
a manner not consistent with most of the PostgreSQL documentation.  According
27aa74
to the standard PostgreSQL documentation, PostgreSQL is installed under the
27aa74
directory /usr/local/pgsql, with executables, source, and data existing in
27aa74
various subdirectories.
27aa74
27aa74
Different distributions have different ideas of some of these file locations.
27aa74
In particular, the documentation directory can be /usr/doc, /usr/doc/packages,
27aa74
/usr/share/doc, /usr/share/doc/packages, or some other similar path.
27aa74
27aa74
However, the Red Hat / CentOS / Fedora RPM's install the files like 
27aa74
this:
27aa74
27aa74
Executables:		/usr/bin
27aa74
Libraries:		/usr/lib (or /usr/lib64 on 64-bit machines)
27aa74
Documentation:		/usr/share/doc/postgresql-docs-x.y.z/html
27aa74
Contrib documentation:	/usr/share/doc/postgresql-contrib-x.y.z
27aa74
Source:			not installed
27aa74
Data:			/var/lib/pgsql/data
27aa74
Backup area:		/var/lib/pgsql/backups
27aa74
Templates:		/usr/share/pgsql
27aa74
Procedural Languages:	/usr/lib/pgsql or /usr/lib64/pgsql
27aa74
Development Headers:	/usr/include/pgsql
27aa74
Other shared data:	/usr/share/pgsql
27aa74
Regression tests:	/usr/lib/pgsql/test/regress  (in the -test package)
27aa74
			or /usr/lib64/pgsql/test/regress
27aa74
27aa74
While it may seem gratuitous to place these files in different locations, the
27aa74
FHS requires it -- distributions should not ever touch /usr/local.  It may
27aa74
also seem like more work to keep track of where everything is -- but, that's
27aa74
the beauty of RPM -- you don't have to keep track of the files, RPM does it
27aa74
for you.
27aa74
27aa74
These RPMs are designed to be LSB-compliant -- if you find this not to be the
27aa74
case, please let us know by way of the pgsqlrpms-hackers@pgfoundry.org
27aa74
mailing list.
27aa74
27aa74
MULTIPLE POSTMASTERS
27aa74
-------------------------------------------------------------------------------
27aa74
The postgresql-server RPM contains a systemd "unit" file, postgresql.service,
27aa74
that is used to start the PostgreSQL postmaster.  If you need to run multiple
27aa74
postmasters on one machine, you can create additional unit files derived
27aa74
from this one.
27aa74
27aa74
As an example, let us create a secondary postmaster called, creatively enough,
27aa74
'secondary'.  Here are the steps:
27aa74
1.)	Create a file named /etc/systemd/system/secondary.service.
27aa74
	(Note that user-created unit files must go into /etc not /lib!)
27aa74
	Put these lines in it:
27aa74
		.include /lib/systemd/system/postgresql.service
27aa74
		[Service]
27aa74
		Environment=PGPORT=nnnn
27aa74
		Environment=PGDATA=/path/to/data/directory
27aa74
	Replace "nnnn" and "/path/to/data/directory" with appropriate
27aa74
	settings that don't conflict with any other postmaster.
27aa74
2.)	As root, do "/bin/systemctl daemon-reload" to ensure systemd has
27aa74
	noticed your updates to the service file.
27aa74
3.)	Create the target PGDATA directory, making sure that its parent
27aa74
	directories have appropriate ownership and permissions.
27aa74
4.)	Initdb the target PGDATA with 'postgresql-setup initdb secondary'.
27aa74
5.)	Edit postgresql.conf in the target PGDATA to change settings as needed.
27aa74
6.)	Start the new postmaster with 'systemctl start secondary.service'.
27aa74
	You will probably also want to do 'systemctl enable secondary.service'
27aa74
	so that the new postmaster is automatically started in future reboots.
27aa74
27aa74
When doing a major-version upgrade of a secondary postmaster, add the
27aa74
service name to the postgresql-setup command, for example 'postgresql-setup
27aa74
upgrade secondary'.  This will let postgresql-setup find the correct data
27aa74
directory from the service file.
27aa74
27aa74
If you are running SELinux in enforcing mode (which is highly recommended,
27aa74
particularly for network-exposed services like PostgreSQL) you will need to
27aa74
adjust SELinux policy to allow the postmaster to use non-default PGPORT or
27aa74
PGDATA settings.  To allow use of a non-default port, say 5433, do this
27aa74
as root:
27aa74
	semanage port -a -t postgresql_port_t -p tcp 5433
27aa74
To allow use of a non-default data directory, say /special/pgdata, do:
27aa74
	semanage fcontext -a -t postgresql_db_t "/special/pgdata(/.*)?"
27aa74
If you already created the directory, follow that with:
27aa74
	restorecon -R /special/pgdata
27aa74
These settings are persistent across reboots.  For more information
27aa74
see "man semanage".
27aa74
27aa74
REGRESSION TESTING
27aa74
-------------------------------------------------------------------------------
27aa74
If you install the postgresql-test RPM then you can run the PostgreSQL
27aa74
regression tests.  These tests stress your database installation and produce
27aa74
results that give you assurances that the installation is complete, and that
27aa74
your database machine is up to the task.
27aa74
27aa74
To run the regression tests under the RPM installation, make sure that the
27aa74
postmaster has been started (if not, su to root and do "systemctl start
27aa74
postgresql.service"), su to postgres, cd to /usr/lib/pgsql/test/regress
27aa74
(or /usr/lib64/pgsql/test/regress on a 64-bit machine),
27aa74
and execute "make check".
27aa74
This command will start the regression tests and will both show the
27aa74
results to the screen and store the results in the file regress.out.
27aa74
27aa74
If any tests fail, see the file regression.diffs in that directory for details,
27aa74
and read the "Regression Tests" section of the PostgreSQL documentation to
27aa74
find out whether the differences are actually significant.  If you need help
27aa74
interpreting the results, contact the pgsql-general list at 
27aa74
postgresql.org.
27aa74
27aa74
After testing, run "make clean" to remove the files generated by the test
27aa74
script.  Then you can remove the postgresql-test RPM, if you wish.
27aa74
27aa74
STARTING POSTMASTER AUTOMATICALLY AT SYSTEM STARTUP
27aa74
-------------------------------------------------------------------------------
27aa74
Fedora / Red Hat / CentOS use the systemd package to manage server startup.
27aa74
A systemd unit file for PostgreSQL is provided in the server package, as
27aa74
/lib/systemd/system/postgresql.service.  To start the postmaster manually,
27aa74
as root run
27aa74
	systemctl start postgresql.service
27aa74
To shut the postmaster down,
27aa74
	systemctl stop postgresql.service
27aa74
These two commands only change the postmaster's current status.  If you
27aa74
want the postmaster to be started automatically during future system startups,
27aa74
run
27aa74
	systemctl enable postgresql.service
27aa74
To undo that again,
27aa74
	systemctl disable postgresql.service
27aa74
See "man systemctl" for other possible subcommands.
27aa74
27aa74
GRAND UNIFIED CONFIGURATION (GUC) FILE
27aa74
-------------------------------------------------------------------------------
27aa74
The PostgreSQL server has many tunable parameters -- the file 
27aa74
/var/lib/pgsql/data/postgresql.conf is the master configuration file for the
27aa74
whole system.  
27aa74
27aa74
The RPM ships with a mostly-default file -- you will need to tune the
27aa74
parameters for your installation.  In particular, you might want to allow
27aa74
nonlocal TCP/IP socket connections -- in order to allow these, you will need
27aa74
to edit the postgresql.conf file.  The line in question contains the string 
27aa74
'listen_addresses' -- you need to both uncomment the line and set the value
27aa74
to '*' to get the postmaster to accept nonlocal connections.  You'll also need
27aa74
to adjust pg_hba.conf appropriately.
27aa74
27aa74
LOGGING SET UP
27aa74
-------------------------------------------------------------------------------
27aa74
By default, the postmaster's stderr log is directed into files placed in a
27aa74
pg_log subdirectory of the data directory (ie, /var/lib/pgsql/data/pg_log).
27aa74
The out-of-the-box configuration rotates among seven files, one for each
27aa74
day of the week.  You can adjust this by changing postgresql.conf settings.
27aa74
27aa74
REBUILDING FROM SOURCE RPM
27aa74
-------------------------------------------------------------------------------
27aa74
If your distribution is not supported by the binary RPMs from PostgreSQL.org, 
27aa74
you will need to rebuild from the source RPM.
27aa74
27aa74
If you have not previously rebuilt any RPMs, set up the required environment:
27aa74
make a work directory, say ~/rpmwork, then cd into it and do
27aa74
	mkdir BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
27aa74
Then make a file ~/.rpmmacros containing
27aa74
	%_topdir <full path to work directory here>
27aa74
27aa74
Download the postgresql .src.rpm for the release you want and place it in
27aa74
the SRPMS subdirectory, then cd there and execute
27aa74
	rpmbuild --rebuild postgresql-nnn.src.rpm
27aa74
The results will appear under the RPMS subdirectory.
27aa74
27aa74
You will have to have a full development environment to rebuild the RPM set.
27aa74
If rpmbuild complains of lack of certain packages, install them and try
27aa74
again.  In some cases, you can disable features to avoid needing some
27aa74
development packages, as detailed next.
27aa74
27aa74
This release of the RPMset includes the ability to conditionally build 
27aa74
sets of packages.  The parameters, their defaults, and the meanings are:
27aa74
27aa74
beta		0	#build with cassert and do not strip the binaries
27aa74
runselftest	1	#do "make check" during the build
27aa74
test		1	#build the postgresql-test package
27aa74
upgrade		1	#build the postgresql-upgrade package
27aa74
plpython	1	#build the PL/Python procedural language package
27aa74
plpython3	1	#build the PL/Python3 procedural language package
27aa74
pltcl		1	#build the PL/Tcl procedural language package
27aa74
plperl		1	#build the PL/Perl procedural language package
27aa74
ssl		1	#build with OpenSSL support
27aa74
kerberos	1	#build with Kerberos 5 support
27aa74
ldap		1	#build with LDAP support
27aa74
nls		1	#build with national language support
27aa74
pam		1	#build with PAM support
27aa74
sdt		1	#build with SystemTap support
27aa74
xml		1	#build with XML support
27aa74
pgfts		1	#build with --enable-thread-safety
27aa74
selinux		1	#build contrib/selinux
27aa74
uuid		1	#build contrib/uuid-ossp
27aa74
27aa74
To use these defines, invoke a rebuild like this:
27aa74
rpmbuild --rebuild --define 'plpython 0' --define 'pltcl 0' \
27aa74
	--define 'test 0' --define 'runselftest 0' --define 'kerberos 0' \
27aa74
	postgresql-9.2.0-1.src.rpm
27aa74
This line would disable the plpython, pltcl, and test subpackages, disable
27aa74
the regression test run during build, and disable kerberos support.
27aa74
27aa74
You might need to disable runselftest if there is an installed version of
27aa74
PostgreSQL that is a different major version from what you are trying to
27aa74
build.  The self test tends to pick up the installed libpq.so shared library
27aa74
in place of the one being built :-(, so if that isn't compatible the test will
27aa74
fail.  Also, you can't use runselftest when doing the build as root.
27aa74
27aa74
More of these conditionals will be added in the future.
27aa74
27aa74
CONTRIB FILES
27aa74
-------------------------------------------------------------------------------
27aa74
The contents of the contrib tree are packaged into the -contrib subpackage
27aa74
and are processed with make and make install.  There is documentation in
27aa74
/usr/share/doc/postgresql-contrib-VERSION for these modules.  Most of the
27aa74
modules are in /usr/lib/pgsql (or /usr/lib64/pgsql) for loadable
27aa74
modules, and binaries are in /usr/bin.  In the future these files may be
27aa74
split out, depending upon function and dependencies.
27aa74
27aa74
MORE INFORMATION
27aa74
-------------------------------------------------------------------------------
27aa74
You can get more information at http://www.postgresql.org and 
27aa74
http://yum.pgsqlrpms.org
27aa74
27aa74
Please help make this packaging better -- let us know if you find problems, or
27aa74
better ways of doing things. You can reach us by e-mail at
27aa74
pgsqlrpms-hackers@pgfoundry.org
27aa74
-------------------------------------------------------------------------------