删除不存在的 postgres 集群

删除不存在的 postgres 集群

我在 ubuntu 10.04 上安装了 postgres 8.4。我在无法再安装的磁盘上创建了一个集群。现在我想删除 postgres,但当我这样做时,apt-get remove postgresql-8.4我得到了:

dpkg: error processing postgresql-8.4 (--remove):
 Package is in a very bad inconsistent state - you should
 reinstall it before attempting a removal.
Errors were encountered while processing:
 postgresql-8.4

当我这样做时,apt-get upgrade它会说:

Selecting previously deselected package postgresql-8.4.
Preparing to replace postgresql-8.4 8.4.9-0ubuntu0.10.04 (using .../postgresql-8.4_8.4.14-0ubuntu10.04_amd64.deb) ...
 * Stopping PostgreSQL 8.4 database server
 * Error: /mnt/db/postgresql/8.4/main is not accessible or does not exist
   ...fail!
invoke-rc.d: initscript postgresql-8.4, action "stop" failed.
dpkg: warning: old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
 * Stopping PostgreSQL 8.4 database server
 * Error: /mnt/db/postgresql/8.4/main is not accessible or does not exist
   ...fail!
invoke-rc.d: initscript postgresql-8.4, action "stop" failed.
dpkg: error processing /var/cache/apt/archives/postgresql-8.4_8.4.14-0ubuntu10.04_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
 * Starting PostgreSQL 8.4 database server
 * Error: /mnt/db/postgresql/8.4/main is not accessible or does not exist
   ...fail!
invoke-rc.d: initscript postgresql-8.4, action "start" failed.

看起来 apt 正在阻塞不存在的集群。我该如何删除该集群并卸载 postgres?

答案1

知道了:

pg_dropcluster --stop 8.4 main
>>> warning: corrupted cluster: data directory does not exist

忽略此警告。如果你第二次这样做,它会说集群已经消失。

要使 dpkg 再次处于良好状态:

apt-get install postgres-8.4

并摆脱它:

apt-get remove --purge postgres-8.4
apt-get autoremove

相关内容