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:
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:
Nice. Now, we can install PostgreSQL 9.0:
As of 9.0, init script name also changed. It now contains major PostgreSQL version number: /etc/init.d/postgresql-9.0 .
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:
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:
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.

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.

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.
Magnus Hagander
For example, pg_dump/pg_restore isn't that backwards compatible is it? If I run both say 8.1 and 9.0, I can use the 9.0 pg_dump to dump 8.1 only if I want to restore it on 9.0 - if I want to restore it on 8.1, that will break. And I don't think we guarantee something similar won't happen with 9.0->9.x.
Devrim GÜNDÜZ
arıkan
Teşekkürler.
Devrim GÜNDÜZ
Darren Duncan
Devrim GÜNDÜZ
Still, I wanted to follow what Red Hat(Tom) did at RHEL 5.5 PostgreSQL 8.4 packages...
Ryan Wallace
Devrim GÜNDÜZ
Brian Dunford-Shore
On FC13 with postgresql-server-8.4.5 (FC13 version) installed, when trying to install postgresql90-server, I get:
Transaction Check Error:
file /var/lib/pgsql/.bash_profile from install of postgresql90-server-9.0.1-1PGDG.f13.x86_64 conflicts with file from package postgresql-server-8.4.5-1.fc13.x86_64
I have worked around it by copying off the conflicting file, downloading the rpms, adding --force to the rpm installation command line, and then copying the conflicting file back.
Devrim GÜNDÜZ
Joseph Genova
I'm having the same problem. I renamed /var/lib/pgsql/.bash_profile, but still get the conflict error. why ? and if I renamed .bash_profile, why would I still need to add --force flag to the install ?
thanks
joe
Devrim GÜNDÜZ
spider
This new RPM craziness seems to have completely broken vendor integration. Is there a way to build the postgres SRPMS so it will install at /usr just like the old days? I have tried hacking the SPEC file, and one fix leads to another break.
Devrim GÜNDÜZ
All you may need is to symlink pg_config under /usr/bin. I don't expect nothing more, but I'd like to see the error first.
spider
%define pgbaseinstdir /usr
so I had to change these with include/pgsql/server :
mv %{buildroot}%{pgbaseinstdir}/include/pgsql/server/pg_config.h %{buildroot}%{pgbaseinstdir}/include/pgsql/server/pg_config_`uname -i`.h
install -m 644 %{SOURCE5} %{buildroot}%{pgbaseinstdir}/include/pgsql/server/
Which leads to shload of File not found errors (and i notice it is not using /usr/lib64/ for standard x86_64 support). Here is a small sampling of errors:
RPM build errors:
File not found: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/lib/libpqwalreceiver.so
File not found: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/share/postgres.bki
File not found by glob: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/share/*.sample
File not found by glob: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/share/timezonesets/*
File not found by glob: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/share/tsearch_data/*.affix
File not found: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/lib/dict_int.so
File not found: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/lib/dict_snowball.so
File not found by glob: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/lib/*_and_*.so
File not found: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/share/conversion_create.sql
File not found: /var/tmp/postgresql90-9.0.2-1PGDG-root-build/usr/share/information_schema.sql
Devrim GÜNDÜZ
Keith Gabryelski
gives me this error (i am rpm/yum challenged, do you have explicit instructions on how to get around this issue -- centos installation -- I have postgres 8.4.6 installed and running):
# yum install postgresql90-server postgresql90-contrib
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
addons: ec2-us-east-mirror1.rightscale.com
base: ec2-us-east-mirror1.rightscale.com
centosplus: ec2-us-east-mirror1.rightscale.com
epel: ec2-us-east-mirror1.rightscale.com
extras: ec2-us-east-mirror1.rightscale.com
rightscale-epel: ec2-us-east-mirror1.rightscale.com
* updates: ec2-us-east-mirror1.rightscale.com
rightscale-epel | 951 B 00:00
Excluding Packages from none
Finished
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql90-contrib.x86_64 0:9.0.2-2PGDG.rhel5 set to be updated
--> Processing Dependency: postgresql90 = 9.0.2 for package: postgresql90-contrib
---> Package postgresql90-server.x86_64 0:9.0.2-2PGDG.rhel5 set to be updated
--> Running transaction check
---> Package postgresql90.x86_64 0:9.0.2-2PGDG.rhel5 set to be updated
--> Processing Dependency: postgresql90-libs = 9.0.2-2PGDG.rhel5 for package: postgresql90
--> Running transaction check
---> Package postgresql90-libs.x86_64 0:9.0.2-2PGDG.rhel5 set to be updated
--> Processing Conflict: postgresql-server conflicts postgresql < 7.4
--> Finished Dependency Resolution
postgresql-server-8.4.6-1PGDG.rhel5.x86_64 from installed has depsolving problems
--> postgresql-server conflicts with postgresql90
Error: postgresql-server conflicts with postgresql90
You could try using --skip-broken to work around the problem
You could try running: package-cleanup --problems
package-cleanup --dupes
rpm -Va --nofiles --nodigest
Devrim GÜNDÜZ
Walter W.
Anything can be checked?
Excluding Packages from CentOS-5 - Base
Finished
Excluding Packages from CentOS-5 - Updates
Finished
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql90.i386 0:9.0.4-1PGDG.rhel5 set to be updated
--> Processing Dependency: postgresql90-libs = 9.0.4-1PGDG.rhel5 for package: postgresql90
--> Running transaction check
---> Package postgresql90-libs.i386 0:9.0.4-1PGDG.rhel5 set to be updated
--> Processing Conflict: postgresql-server conflicts postgresql < 7.4
--> Finished Dependency Resolution
postgresql-server-8.4.4-2PGDG.el5.i386 from installed has depsolving problems
--> postgresql-server conflicts with postgresql90
Error: postgresql-server conflicts with postgresql90
Devrim GÜNDÜZ
Clemens Schwaighofer
So I cannot install postgresql 9.0 in EL5 while 8.4 is installed?
I could do that on a EL4 with an even older postgresql 8.3 installed.
And I also do not understand the error ...
Devrim GÜNDÜZ
This feature is available only for PostgreSQL 9.0+ for ALL distros. The only exception is RHEL 6, and you can install 8.4+ to RHEL6 in parallel.
*Using RPMs*, you cannot install this on EL-4 and PostgreSQL 8.3 -- but you can do it using source installation.
Is that ok now.?
Regards,
Devrim
Clemens Schwaighofer
I have a Redhat EL4 box with hand installed postgresql 8.3 RPMS:
postgresql-server-8.3.5-1PGDG.rhel4
and I could install the 9.0 postgresql from the yum repository:
postgresql90-server-9.0.2-1PGDG.rhel4
On a RedHat EL5 box I have postgresql 8.4 RPMS installed by hand:
postgresql-server-8.4.1-1PGDG.rhel5
but when I try to install the postgresql 9.0 via yum (with the same yum install file provided on the postgresql yum rpm list page) I get the same error as the parent poster.
I does not allow me to install postgresql 9.0 because it has some "conflict" with a postgresql < 7.4 ...
Devrim GÜNDÜZ
Clemens Schwaighofer
Devrim GÜNDÜZ
Josephine
is pgdg-centos91-9.1-4.noarch.rpm the only rpm I need to install to get this going or do I need other rpms?
Some blogs have different rpms listed for older versions. I can't seem to find doc for someone just starting out.
Secondly, I need to also install PHP and apache and make it work with postfresql.
Will appreciate any info
Thanks
Devrim GÜNDÜZ