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