Blame SOURCES/README.rpm-dist

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