I know it's been more than a week since I published 9.0 RPMs, and I'm a bit late to write this article -- sorry, I just could find time.
Years ago, I have started a project to support parallel PostgreSQL version installation feature with RPMs, like Ubuntu/Debian folks have been doing for many years, but I could not complete it because of this and that. However, this time I bite the bullet, and given that we already bumped the major version to 9.0, this was a good chance to enable this feature and break existing scripts!
The main goal is not just to be able to install different PostgreSQL versions on the same machine -- we also needed to support different 3rd party software to be compiled and installed using the new scheme. Honestly, that is the hardest part. We have 60+ different packages, and even in noarch packages, I had to replace dependency from postgresql to
postgresql90...
What? Where did
90 suffix come from?
In the early phase of 9.0(or say, 8.5) development, there were some problems with testing:
** I did not use yum to test, I only used rpm command.
** I did not have 9.1, so that I could really test parallel installation.
I was lucky enough, and 9.1 Alpha1 was released just 1 week before 9.0.0 was released. After working on 9.1 RPMs and pushing them to
yum repository, I could perform a real test which failed immediately. The oversight was that the package names were the same, and yum thought that 9.1 was an upgrade to 9.0....
... so I had to find another way. Tom pushed 8.4 packages as of RHEL 5.5, and to avoid confusion, he added 84 suffix to package names (postgresql84, postgresql84-server, etc). I borrowed that idea, and changed package names... Sorry guys, I had to do it.
One of the biggest change in spec file is:
%define pgbaseinstdir /usr/pgsql-%{majorversion}
and I used this in most part of the spec file.
Another change is using alternatives method. See
here for details.
Now, let's give an example about how to install PostgreSQL 9.0 my Fedora 13 box. It is more or less the same with the other Fedora/RHEL/CentOS releases. Please refer to
yum howto link for more details, especially for the YUM repository configuration RPMs.
First, let's install repo RPM:
# rpm -ivh http://yum.pgrpms.org/reporpms/9.0/pgdg-fedora-9.0-2.noarch.rpm
Retrieving http://yum.pgrpms.org/reporpms/9.0/pgdg-fedora-9.0-2.noarch.rpm
warning: /var/tmp/rpm-tmp.aczMlm: Header V3 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ########################################### [100%]
1:pgdg-fedora ########################################### [100%]
#
Nice. Now, we can install PostgreSQL 9.0:
# yum install postgresql90-server postgresql90-contrib
< output trimmed >
Installed:
postgresql90-contrib.i686 0:9.0.0-1PGDG.f13.1 postgresql90-server.i686 0:9.0.0-1PGDG.f13.1
Dependency Installed:
postgresql90.i686 0:9.0.0-1PGDG.f13.1 postgresql90-libs.i686 0:9.0.0-1PGDG.f13.1 uuid.i686 0:1.6.1-11.fc13
Complete!
As of 9.0, init script name also changed. It now contains major PostgreSQL version number: /etc/init.d/postgresql-9.0 .
# service postgresql-9.0 initdb
Initializing database: [ OK ]
# service postgresql-9.0 start
Starting postgresql-9.0 service: [ OK ]
#
Great. Service started. That was easy, right? Well, there are some more issues actually. The major change in file layout is that PostgreSQL stuff, except data directory, is now installed under /usr/pgsql-9.0, not /usr:
# ls /usr/pgsql-9.0/
bin include lib share
and the data directory changed, too. In previous versions, we used /var/lib/pgsql as the base directory, and /var/lib/pgsql/data as data directory. Base directory remained the same. However, data directory had to change for parallel installation. It is now /var/lib/pgsql/9.0/data . initdb procedure in init script performs cluster initialization in this directory automagically.
One of the most FAQ is:
Where are my binaries gone? Why didn't you add /usr/pgsql-9.0/bin to $PATH
For various reasons, we did not add it to $PATH, which would be a silly thing given that we want to support multiple versions. Instead, we used alternatives method to install most common binaries. These are:
clusterdb
createdb
createlang
createuser
dropdb
droplang
dropuser
pg_dump
pg_dumpall
pg_restore
psql
reindexdb
vacuumdb
Please note that all of these are backwards compatible binaries. They will be replaced with 9.1 ones when installed, but they won't break your applications.
So, what about ecpg, initdb, oid2name, pg_config, pg_resetxlog, postgres and others? They are under /usr/pgsql-9.0/bin directory. That may break your existing scripts -- but that is what I had to do for a .0 release.
Please don't symlink them under /usr/bin, and instead fix your scripts.
I want to thank Greg Smith for his great support and great ideas in both early stages and the last stages. For example, using alternatives method is his idea.