Thursday, February 22, 2007
PostgreSQL RPM vs Debian Packages
I've been spoiled by Debian.
Today I had to install PostgreSQL into a server at work. It was a Red Hat EL 4 server, with the x86_64 kernel. Luckily -- I thought -- I found RPM packages made by the Command Prompt folks.
Downloading the RPMs was a bit of a pain. The PostgreSQL download service first redirects you to a page where you select a mirror, and when you do the link to the file you want is URL encoded, so it ends up looking like http://wwwmaster.postgresql.org/redir?ftp%3A%2F%2Fftp5.us.postgresql.org%2Fpub%2FPostgreSQL%2Fbinary%2Fv8.2.3%2Flinux%2Frpms%2Fredhat%2Frhel-es-4-x86_64%2Fpostgresql-8.2.3-1PGDG.x86_64.rpm
That looks really amateurish. C'mon folks, you can do much better than that for almost no extra effort (and I'll do the work). How many servers do you work on have a browser up and running? Or even a graphical interface? When I need to get things up on a server, I usually just use wget.
But with the urlencoded link to the file, I can't just paste that into the command. I had to open up a python interpreter, import urllib and urllib.unquote() the URL, then paste that into the command line. That's a lot of unnecessary work because of some (apparently) lazy programming on the PostgreSQL site.
So, I finally grab all the RPMs. I install them. Used to Debian, I expect now to have a functioning PostgreSQL server that I have to tune a little bit to get away from the conservative defaults.
Man, was I wrong.
The RPMs install PostgreSQL, but it doesn't work at all. It doesn't even perform the necessary initdb. The configuration files are not even in place. I had to rpm -ql | grep conf the postgresql package to find out where the config files were. They were in /usr/share/pgsql and they were just fully commented out samples.
So I grab the sample files, and copy them to /etc/sysconfig/pgsql, (which I also found by grepping the package listing) and remove the .sample suffix from each of them. I expected the package to have created /etc/postgresql or something similar, but sysconfig is Red Hat's thing (apparently at least, since Debian doesn't have it), so I let it slide, somewhat grudgingly.
I modify the config files to my liking. I try to start PostgreSQL. Ooops, the packages didn't run initdb, so I have to do that myself. Ok, it seems to have started. I try to get my application to connect and it fails with an ident error. I look at my pg_hba.conf file (it controls how clients connect to the server, hba stands for Host Based Access, I believe.)
I look at my pg_hba.conf and it looks fine, what gives? Well, apparently the config files have to be in /var/lib/pgsql, the directory where the PostgreSQL databases are stored. Now that doesn't make any sense. Configuration files are meant to be put in /etc, not /var, much less the PostgreSQL data directory.
I then modify the /etc/init.d/postgresql script and add -c config_file=/etc/sysconfig/pgsql/postgresql.conf to the line that starts the daemon. I then modify postgresql.conf to have the explicit path to the pg_hba.conf file.
Restart PostgreSQL. It finally works. What a work out! Here's what would have happened in Debian:
aptitude install postgresql-8.1. Apt grabs all the dependencies, install them, and I have a working PostgreSQL installation that I can connect to (locally). That's it.
The config files I may modify if I want to, are somewhere expected: /etc. And they are working files with the right names (i.e. without .sample suffixes that I have to remove)
Yes, I know I could have used yum or something like it to simplify the packages part. But it would still have left everything else to do, and that was the most time-consuming part. With Debian, everything is simpler. It just helps me get the job done faster and simpler. Because package owners have to adhere to a set of standards, packages behave very consistently, which further reduces guess work and helps me be more productive.
So instead of saying "Debian spoiled me", maybe I should have just said "Debian got me used to being productive". And it's hard going back to not being so productive.