PostgreSQL版本不兼容



情况如下:

我已经用命令 安装了postgresql-9.3
    sudo apt-get install postgresql-9.3:
然后使用pg_ctl启动服务器
    pg_ctl -D /var/lib/postgresql/9.3/main -Z coordinator start

导致以下错误:

    18:23:50 CEST FATAL:  database files are incompatible with server 2014-07-14 18:23:50 CEST DETAIL:  The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.2.4.

我不知道9.2.4版本在哪里,我检查了所有关于Postgres的文件夹,它们都在9.3文件夹下,甚至尝试了pg_clusters。有人能给一些提示来解决这个问题吗?

dpkg -l | grep postgres给出了结果:

ii  postgres-xc               1.1-2ubuntu2  amd64        write-scalable, synchronous multi-master, transparent PostgreSQL cluster
ii  postgres-xc-client        1.1-2ubuntu2  amd64        front-end programs for Postgres-XC
rc  postgresql-9.3            9.3.4-1       amd64        object-relational SQL database, version 9.3 server
rc  postgresql-client-common  154           all          manager for multiple PostgreSQL client versions
rc  postgresql-common         154           all          PostgreSQL database-cluster manager

我试过一次删除"所有",并重新安装它们现在我得到了dpkg -l | grep ' postgres:

的输出
    ii  postgresql-9.3        9.3.4-1       amd64        object-relational SQL database, version 9.3 server
    ii  postgresql-client-9.3 9.3.4-1       amd64        front-end programs for PostgreSQL 9.3
    ii  postgresql-client-common  154       all          manager for multiple PostgreSQL client versions
    ii  postgresql-common         154       all          PostgreSQL database-cluster manager

现在一切看起来都很好,当我尝试用pg_ctl启动服务器时,命令行告诉我:

    The program 'pg_ctl' is currently not installed. You can install it by typing:

install postgresql

是否有其他方式启动服务器?我应该按照建议安装postgresg -xc吗?

Thank you

您的机器上安装了旧的Postgres 9.2(除非您没有混淆两台机器)。假设Debian缺乏信息。Ubuntu应该是类似的。

dpkg -l | grep postgres

(除非你安装的程序没有包管理器,那么你也应该能够解开这个混乱。)

如果你不再需要Postgres 9.2了(确保这一点!)卸载它。那么一切都应该正常了。

sudo apt-get remove postgresql-9.2

或偶数:

sudo apt-get purge postgresql-9.2

如果你想保持两个(或更多)版本并行,我建议你另外安装postgresql-commonpostgresql-client-common,这有助于使这成为可能。