OK, so I'm relatively new to linux. Some months ago, I managed to set up a website using Amazon's build of CentOS, PHP and Postgres 9.1. I'd done an initdb on /pgdata which was mounted on an Amazon volume I'd created for that purpose. The site's been humming ever since, and I felt like this wasn't so hard after all! 🙂
But right now, my site is down. Here's what happened…
Yesterday I logged in to begin some website changes. First thing I saw is that there were some updates available (naturally), so I ran "yum update". It did a bunch of things and reported success. Cool!
All was going well on my website changes until I executed a change to a Postgres function. I got an error:
ERROR: could not load library "/usr/lib64/pgsql/plpgsql.so": "/usr/lib64/pgsql/plpgsql.so": undefined symbol: SPI_plan_get_cached_plan
(I'm using plpgsql in my functions)
Google led me to various places which seemed to say I just needed to restart Postgresql. I tried that various ways. Postgres would stop, but not start again.
At some point along the way, I got another (bit more helpful) error message:
"The data directory was initialized by PostgreSQL version 9.1, which is not compatible with this version 9.2.3."
What the? Had my yum update installed a new, incompatible version of Postgres? Is this how we roll in the Linux world? Major upgrades without warnings about what that entails or asking my permission? Foowee, I'll be more careful next time. Incidentally, what should I have done if I had my time again?
Anyway, that led me to these links, and of course the postgres docs. I'm stuck now on running pg_upgrade. Here's my command so far:
pg_upgrade -d /pgdata_temp -D /pgdata -b /usr/lib64/pgsql/postgresql-9.1/bin/ -B /??/ -v
How do I find out where the new Postgres bin directory is (for the /B argument)? It doesn't seem to be anywhere. And yet, when I ran
su – postgres
initdb -D /pgdata -E UTF8
cat /pgdata/PG_VERSION
…earlier, I got "9.2".
Any help would be very much appreciated. Maybe I just roll back to 9.1? Is that my best strategy? Then how do I avoid upgrades when I run yum update next time? Or else, I'm happy to upgrade, but how do I do that and upgrade my existing database to 9.2.3?
Thanks!
EDIT: I decided my next best option was to abandon 9.1 and my database (I had a copy of the data in CSV format), and rebuild a 9.2 database from scratch with the scripts I kept in the initial 9.1 build.
sudo su –
cd /pgdata
rm -fr * .* (delete everything in /pgdata from 9.1 database – I kept a backup first)
su – postgres
initdb -D /pgdata -E UTF
Edit postgresql.conf and pg_hba.conf and start the server.
I still have no idea
- where yum put the 9.2 version binaries – and yet the 9.1 binary
directory still exists - how to get
service postgresql upgrade
working
But after days of Googling and server downtime, I don't care anymore.
Best Answer
The unintended upgrade is Amazon's packaging fault. The other Linux distributions normally don't break PostgreSQL when upgrading.
To get out of this mess, see this entry in their FAQ: