Upgrading postgresql databse server software on Debian Lenny (Old Post)

This is a systems administration and database technology oriented one:

Problem: Because we have several servers that was upgrade from Debian Etch and the to Debian Lenny via the “apt-get dist-upgrade” path , I need to upgrade older instance postgresql 8.1 to postgresql 8.3 as smoothly as possible.

The databases are fairly simple but I really don’t want to muck around with dump and restore procedures, if there is a better way to do it. I turns out there is a better way:

Solution:

First: backup your data using the pg_dump utility. This way you will have a fall-back and all of your data in case something does go wrong.

Second: install new postgresql packages: apt-get install postgresql-8.3 postgresql-client-8.3 . Now you have two database clusters in parallel.

Third: what we need to is migrate all the data from the old one to the new one. You will need to do this with sudo or root priviledges. To go ahead do the do the following:

1. Invoke pg_dropcluster –stop 8.3 main. This will stop the new postgresql cluster (but not the server) and make it dormant and ready for migration.

2. Invoke pg_upgradecluster 8.1 main to kick off the upgrade process. This may take some time. My output was something like this:

Creating new cluster (configuration: /etc/postgresql/8.3/main, data: /var/lib/postgresql/8.3/main)…
Moving configuration file /var/lib/postgresql/8.3/main/postgresql.conf to /etc/postgresql/8.3/main…
Moving configuration file /var/lib/postgresql/8.3/main/pg_hba.conf to /etc/postgresql/8.3/main…
Moving configuration file /var/lib/postgresql/8.3/main/pg_ident.conf to /etc/postgresql/8.3/main…
Configuring postgresql.conf to use port 5433…
Disabling connections to the old cluster during upgrade…
Disabling connections to the new cluster during upgrade…
Re-enabling connections to the old cluster…
Re-enabling connections to the new cluster…
Creating globals…
Fixing hardcoded library paths for stored procedures…
Upgrading database postfix…
Analyzing database postfix…
Fixing hardcoded library paths for stored procedures…
Upgrading database postgres…
Analyzing database postgres…
Fixing hardcoded library paths for stored procedures…
Upgrading database template1…
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 1502; 1262 1 DATABASE template1 postgres
pg_restore: [archiver (db)] could not execute query: ERROR:  database “template1” already exists
Command was:
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = ‘SQL_ASCII’;
WARNING: errors ignored on restore: 1
Analyzing database template1…
Copying old configuration files…
Copying old start.conf…
Stopping target cluster…
Stopping old cluster…
Disabling automatic startup of old cluster…
Configuring old cluster to use a different port (5433)…
Starting target cluster on the original port…
Success. Please check that the upgraded cluster works. If it does,
you can remove the old cluster with

pg_dropcluster 8.1 main

3. Verify everytting and then when you’re happy that all data is as it should be, invoke: pg_dropcluster 8.1 main This command will remove old version of the database cluster, and clean up the postgresql instances

4. Now that all is working well you can clean up your server with : apt-get –purge remove postgresql-8.1 postgresql-client-8.1

This process was relatively painless and quick. Definitely a our preferred way to do this sort of work, once you have a good known backup of your data.

what is a “business architecture” ?

There is a perception amongst many people I speak to that Business Architecture is something for the big business, that it is expensive to do, that only medium and big businesses can get value from it.

The reality is that behind the “Business Architecture” label lies a system used to describe, both in pictures and words:

  • what a business does to generate value for its customers
  • an understanding of and what “raw materials” (be that goods or information) are used, how the raw materials are transformed, and how the product or the service is sold.
  • a map of how information flows into, within, and out of the business.
  • a map of business processes used

So when you look at it this way, you really start to wonder how anyone who invests time and money into a business ( be it one of their own or someone else’s ) can say “oh no, this is not for us! that stuff is for the big guys who can afford it”.

How can you “not afford” to understand in detail what it is you are putting your time and money into…

Sometime in the near future I will post some real information about our experience with trying to describe our own business architecture, and about how we applied the knowledge we gained from that excercise to a good use.

New servers and more…

Here, at Vandrad Research Labs, we have taken delivery of a new server. This more than doubles our hosting capacity and allows us to offer a new range of services, such as this lovely blogging engine.

If you are interested, please have a look at the Vandrad Research Labs website for more detail.