如何安装旧版本的 postgresql 和 postgis? [英] How do I install older version of postgresql and postgis?

查看:96
本文介绍了如何安装旧版本的 postgresql 和 postgis?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Linux 新手,我发现安装旧版本的 postgresql(以及 postgis)真的很困难.我已经卸载了我能找到的所有连接到 aptidude 中的 postgresql 的东西.由于只有最新版本可以通过 apt-get install 获得,我已经阅读了几个如何安装 9.1 的教程.示例:https://wiki.postgresql.org/wiki/Apt(最后是 9.1,不是 9.3)在我完成本教程后,pgAdmin III 仍然显示 9.3 作为版本.转储 9.3 并安装 9.1 和 postgis 1.5 的正确方法是什么?

I am new to Linux and I found it really difficult to install older version of postgresql (along with postgis). I have uninstalled everything I could find connected to postgresql in aptidude. As only the newest version is available through apt-get install, I have went through several tutorials how to get 9.1 installed. Example: https://wiki.postgresql.org/wiki/Apt (with 9.1 at the end, not 9.3) After I was done with this tutorial, pgAdmin III is still showing 9.3 as version. What's the correct way to dump 9.3 and install 9.1 as well as postgis 1.5?

我使用的是 Mint 17

I am using Mint 17

推荐答案

好的.首先,可以同时运行多个版本的 postgresql.一台机器上可以有多个集群,每个集群可以运行不同的版本.debian pacakges 设计得非常好,可以轻松实现这一点.

Okay. First off it is perfectly fine to run multiple versions of postgresql alongside one another. You can have more than one cluster on a box, and each cluster can run different versions. The debian pacakges are very well designed to make this easy to do.

然而,既然你已经表明你是 linux/postgresql 的新手,那么最好从你的系统中彻底清除 9.3,以避免令人沮丧的打嗝,这会花费你很长时间才能弄清楚.

However since you've indicated you're a newby to linux/postgresql it's probably best to get 9.3 completely cleaned from your system to avoid frustrating hiccups which will take you a long time to figure out.

要做到这一点,您需要:

To do this you need to:

  1. 从 dpkg 中清除所有 postgresql 9.3 包
  2. 手动删除 9.3 集群的任何 9.3 数据和配置
  3. 确保您已创建 9.1 集群

第 1 步 - 清除 DPKG

DPKG 管理您系统上的软件包.APT 充当安装包的机制.许多 DPKG 功能可通过 apt 获得,但有些事情在 dpkg 上更容易.在您的评论中,您已经表明 DPKG 仍在显示 9.3 的残余.当您卸载软件包时,它的某些部分可能会挂起(例如配置文件).您可以在一个命令中删除多个包.要完全摆脱这些,您可以告诉 dpkg 清除它们 dpkg --purge .您可以在一个命令中删除多个包,最好这样做.

DPKG manages the packages on your system. APT acts as a mechanism for getting packages to install. A lot of DPKG functionality is available through apt, but some things are just easier on dpkg. In your comments you've shown that DPKG is still showing remnants of 9.3. When you uninstall a package some parts of it may hang around (such as configuration files). You can remove multiple packages in one command. To get rid of these completely you can tell dpkg to purge them dpkg --purge <package name>. You can remove multiple packages in one command and it's best to do so.

dpkg --list 将列出您系统上的所有内容.dpkg --list |grep postgresql 在此列表中搜索 postgresql.

dpkg --list will list everything on your system. dpkg --list | grep postgresql searches this list for postgresql.

第 2 步 – 从旧的 9.3 集群中手动删除数据和配置.

当您第一次安装 postgresql 时,它会为您创建一个集群;无话可问.这让很多新用户感到困惑,因为他们既不知道它发生了,也不知道如何替换它.现在 9.3 已卸载,您可以继续并简单地删除配置和数据:

When you first install postgresql it creates a cluster for you; no questions asked. This trips up a lot of new users because they neither knew that it happened nor how to replace it. Now that 9.3 is uninstalled you can go ahead and simply delete the configuration and data:

如果您想在已安装的 9.3 数据库中保留任何内容,请不要运行以下命令

sudo rm -rf/etc/postgresql/9.3 删除配置.

sudo rm -rf/var/lib/postgresql/9.3 删除数据.

第 3 步 – 创建新集群

您在评论中指出已安装 postgresql 9.1.在运行此命令之前,值得阅读手册.man pg_createcluster.

You've indicated in comments that postgresql 9.1 is installed. Before you run this command it's worth reading the manual. man pg_createcluster.

sudo pg_createcluster 9.1 <想一个名字>

现在你应该可以启动 postgresql sudo service postgresql start

Now you should be able to start up postgresql sudo service postgresql start

编辑

如果 pg_config 仍然列出不正确的版本,那么...这可能是因为 9.3 的残余仍然留在您的系统上.这可能不是问题.为了允许多个版本并排运行,pg_config 是一个包装脚本,用于搜索/usr/lib/postgresql/*/bin/pg_config 的最新(最高版本).所以你看到的是运行 /usr/lib/postgresql/9.3/bin/pg_config 的结果.如果 9.3 从您的系统中完全清除,那么/usr/lib/postgresql/9.3 应该已经消失了.

If pg_config is still listing the incorrect version then... this can be a result of remnants of 9.3 still left on your system. This may not be a problem. To allow multiple versions to run along side one another pg_config is a wrapper script which searches for the latest (highest version) of /usr/lib/postgresql/*/bin/pg_config. So what you're seeing is the result of running /usr/lib/postgresql/9.3/bin/pg_config. If 9.3 is completely cleaned from your system then /usr/lib/postgresql/9.3 should have gone.

如果你想查看 9.1 的配置,请尝试运行:/usr/lib/postgresql/9.1/bin/pg_config.

If you want to see the configuration of 9.1 then try running: /usr/lib/postgresql/9.1/bin/pg_config.

启动服务器的包装脚本将使用/etc/postgresql 的文件结构并使用适当的版本.所以/etc/postgresql/9.1/main 将启动版本为 9.1.

The wrapper scripts which starts the server will use the file structure of /etc/postgresql and use the apropriate version. So /etc/postgresql/9.1/main will startup version as 9.1.

这篇关于如何安装旧版本的 postgresql 和 postgis?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆