Thread: Two Versions of PostgreSQL Installed - How to uninstall one particular version

Two Versions of PostgreSQL Installed - How to uninstall one particular version

From
"Wang, Mary Y"
Date:
Hi,

I got this error:
"-bash-2.05b$ /usr/local/pgsql/bin/pg_ctl start
server starting
-bash-2.05b$ FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 7.3, which is not compatible with this version
8.3.8."

I think I must have two versions of Postgres installed.  How do I uninstall the 7.3 version?  Do I need to do a manual
uninstallby removing Postgres related files from /usr/bin and etc?  Or is there an automatic way?  The problem is that
I'munclear what files need to be removed.  I think might also need to delete a file in the /etc/init.d directory. 

I'm running on RHEL 3.9.

Thanks
Mary




Re: Two Versions of PostgreSQL Installed - How to uninstall one particular version

From
"A. Kretschmer"
Date:
In response to Wang, Mary Y :
> Hi,
>
> I got this error:
> "-bash-2.05b$ /usr/local/pgsql/bin/pg_ctl start
> server starting
> -bash-2.05b$ FATAL:  database files are incompatible with server
> DETAIL:  The data directory was initialized by PostgreSQL version 7.3, which is not compatible with this version
8.3.8."
>
> I think I must have two versions of Postgres installed.  How do I
> uninstall the 7.3 version?  Do I need to do a manual uninstall by
> removing Postgres related files from /usr/bin and etc?  Or is there an
> automatic way?  The problem is that I'm unclear what files need to be
> removed.  I think might also need to delete a file in the /etc/init.d
> directory.

I think, you have a problem ;-)

You have a data directory initialized by PostgreSQL version 7.3. Because
of this, you need a running 7.3-Server to acces to this data. But you
have installed 8.3.8.

You should now install a 7.3 - Server tu access to the data. Make a
Backup of the data-directory before!

If the 7.3 - Server is running, you can make a Backup. You should make
this Backup with the 8.3-Server (yes, you can have multiple versions
installed on the same computer and the same time)


Regards, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

Re: Two Versions of PostgreSQL Installed - How to uninstall one particular version

From
"Wang, Mary Y"
Date:
Thanks Andreas for the info.  I'm working on a development server right now, and currently I don't have any data loaded
yet. As matter of fact, I was trying to load the database data from a dump file that generated by "pg_dump".   
Here is the thing:
I've a /usr/bin/initdb -> this is probably from version 7.3 and other postgres related executable files.
I've a /usr/local/pgsql/bin/initdb -> this is probably from version 8.3.8.  I think all the postgres related executable
filesare located in this directory.  I like this organization much better in 8.3.8. 
My question is what files should I delete from /usr/bin directory?  Is there an automatic way to uninstall a particular
version? I want to delete the 7.3 version and don't want to have multiple versions of postgres running on the same
server.  
If there is not an automatic way, then I can probably remove files like initdb, dropdb, createdb, psql and etc from the
/usr/bindirectory. 
Or may be just specify the path when I run the initdb command "/usr/local/pgsql/bin/initdb" (other wise it would use
/usr/bin/initdb)

Any thoughts?
Mary



-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of A. Kretschmer
Sent: Thursday, February 25, 2010 11:04 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Two Versions of PostgreSQL Installed - How to uninstall one particular version

In response to Wang, Mary Y :
> Hi,
>
> I got this error:
> "-bash-2.05b$ /usr/local/pgsql/bin/pg_ctl start server starting
> -bash-2.05b$ FATAL:  database files are incompatible with server
> DETAIL:  The data directory was initialized by PostgreSQL version 7.3, which is not compatible with this version
8.3.8."
>
> I think I must have two versions of Postgres installed.  How do I
> uninstall the 7.3 version?  Do I need to do a manual uninstall by
> removing Postgres related files from /usr/bin and etc?  Or is there an
> automatic way?  The problem is that I'm unclear what files need to be
> removed.  I think might also need to delete a file in the /etc/init.d
> directory.

I think, you have a problem ;-)

You have a data directory initialized by PostgreSQL version 7.3. Because of this, you need a running 7.3-Server to
accesto this data. But you have installed 8.3.8. 

You should now install a 7.3 - Server tu access to the data. Make a Backup of the data-directory before!

If the 7.3 - Server is running, you can make a Backup. You should make this Backup with the 8.3-Server (yes, you can
havemultiple versions installed on the same computer and the same time) 


Regards, Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: Two Versions of PostgreSQL Installed - How to uninstall one particular version

From
"A. Kretschmer"
Date:
In response to Wang, Mary Y :
> Thanks Andreas for the info.  I'm working on a development server right now, and currently I don't have any data
loadedyet.  As matter of fact, I was trying to load the database data from a dump file that generated by "pg_dump".   
> Here is the thing:
> I've a /usr/bin/initdb -> this is probably from version 7.3 and other postgres related executable files.
> I've a /usr/local/pgsql/bin/initdb -> this is probably from version 8.3.8.  I think all the postgres related
executablefiles are located in this directory.  I like this organization much better in 8.3.8. 
> My question is what files should I delete from /usr/bin directory?  Is there an automatic way to uninstall a
particularversion?  I want to delete the 7.3 version and don't want to have multiple versions of postgres running on
thesame server.   
> If there is not an automatic way, then I can probably remove files like initdb, dropdb, createdb, psql and etc from
the/usr/bin directory. 
> Or may be just specify the path when I run the initdb command "/usr/local/pgsql/bin/initdb" (other wise it would use
/usr/bin/initdb)
>
> Any thoughts?

I'm not familiar with RH, maybe someone else can better help you. But i
think, you should use the packaging system, RPM, for software-(de)installation.


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99

Re: Two Versions of PostgreSQL Installed - How to uninstall one particular version

From
"Albe Laurenz"
Date:
Mary Y Wang wrote:
> I got this error:
> "-bash-2.05b$ /usr/local/pgsql/bin/pg_ctl start
> server starting
> -bash-2.05b$ FATAL:  database files are incompatible with server
> DETAIL:  The data directory was initialized by PostgreSQL
> version 7.3, which is not compatible with this version 8.3.8."
>
> I think I must have two versions of Postgres installed.  How
> do I uninstall the 7.3 version?  Do I need to do a manual
> uninstall by removing Postgres related files from /usr/bin
> and etc?  Or is there an automatic way?  The problem is that
> I'm unclear what files need to be removed.  I think might
> also need to delete a file in the /etc/init.d directory.
>
> I'm running on RHEL 3.9.

PostgreSQL 7.3 is the version that comes with RedHat 3.

To find out what PostgreSQL stuff you have installed (provided
you installed it as RPM and did not compile it from source),
you can run

rpm -qa | grep postgres

Your question seems to suggest that you don't know a lot about RPMs,
maybe you should ask for system administrator for help about
uninstalling those packages you don't need.

Your problem, however, is completely unrelated to this.

Somebody has already created a PostgreSQL data directory on the machine
by running 7.3's initdb command.

Now you are trying to start a server on this directory with
PostgreSQL 8.3. This will fail with the message above.

If you care about the data in the 7.3 data directory, you will
have to migrate it: start a 7.3 server, export with 8.3's
pg_dumpall, run 8.3's initdb, import the dump.

If you don't care about the data, all you have to do is
remove the data directory and create a new one by running
8.3's initdb.

Yours,
Laurenz Albe

Re: Two Versions of PostgreSQL Installed - How to uninstall one particular version

From
John R Pierce
Date:
Albe Laurenz wrote:
> If you care about the data in the 7.3 data directory, you will
> have to migrate it: start a 7.3 server, export with 8.3's
> pg_dumpall, run 8.3's initdb, import the dump.
>

and thats not that easy with Redhat/Centos/Fedora/etc RPM installs, as
installing 8.x from RPM sources wiped out the 7.3 binaries

assuming you installed the PGDG rpms over the RH stock 7.3 RPMs, and you
don't particluarlly care for any 7.3 databases,   you could try this...

    # service stop postgresql               -- (make sure everything is
stopped)
    # mv /var/lib/pgsql/data /var/lib/pgsql/data-73
    # service postgresql initdb
    # service postgresql start

this will put aside the 7.3 postgres data for later consideration, and
create a new database cluster with the version you installed.




Albe Laurenz wrote:
> To find out what PostgreSQL stuff you have installed (provided
> you installed it as RPM and did not compile it from source),
> you can run
>
> rpm -qa | grep postgres
>
Some other useful tricks to know here; most commands take "--version":

$ initdb --version
initdb (PostgreSQL) 8.3.3

Which can help out figuring out which version is which when you have two
on the server.

If you've managed to connect to a server, you can often find out where
it came from like this:

$ psql -c "select version()"

version
-----------------------------------------------------------------------------------------------------------
 PostgreSQL 8.3.3 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC)
4.1.2 20071124 (Red Hat 4.1.2-42)

And if you have the pg_config utility installed in either location,
running it will tell you all sorts of info about how your install was done.

--
Greg Smith  2ndQuadrant US  Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com   www.2ndQuadrant.us