Deepin下安装PostgreSQL

Deepin下安装Postgresql

我的Deepin版本为

$ lsb_release -a
No LSB modules are available.
Distributor ID: Deepin
Description:    Deepin 20.9
Release:        20.9
Codename:       apricot

注意这里Codename是apricot,后面会提到。

由于Deepin的apt连接的是Deepin官方源,其中的软件版本十分老旧,直接使用

$ sudo apt install postgresql

下载的版本是 11,而这已经是PostgreSQL的不支持版本。

好在PostgreSQL下载文档告诉我们他们提供了官方Apt仓库,可以通过以下方式设置:

$ sudo apt install -y postgresql-common
$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

报错

$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
This script will enable the PostgreSQL APT repository on apt.postgresql.org on
your system. The distribution codename used will be apricot-pgdg.

Your system is using the distribution codename apricot, but apricot-pgdg
does not seem to be a valid distribution on
http://apt.postgresql.org/pub/repos/apt/dists/

We abort the installation here. If you want to use a distribution different
from your system, you can call this script with an explicit codename, e.g.
"/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh precise".

Specifically, if you are using a non-LTS Ubuntu release, refer to
https://wiki.postgresql.org/wiki/Apt/FAQ#I_am_using_a_non-LTS_release_of_Ubuntu

For more information, refer to https://wiki.postgresql.org/wiki/Apt
or ask on the mailing list for assistance: pgsql-pkg-debian@postgresql.org

看内容可以看出来,apricot不是合法的codename,因为我们毕竟不是在原生Debian上安装。

前往报错中提示的 http://apt.postgresql.org/pub/repos/apt/dists/ 查看

这实际上是Debian发行版本

而在PostgreSQL下载文档,也列出了支持的Debian版本

查询本系统基于的Debian版本:

$ cat /etc/debian_version
10.10

应该使用buster作为Codename,结合报错信息中给的例子,重新执行

$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh buster
This script will enable the PostgreSQL APT repository on apt.postgresql.org on
your system. The distribution codename used will be buster-pgdg.

Press Enter to continue, or Ctrl-C to abort.
Writing /etc/apt/sources.list.d/pgdg.list ...
Importing repository signing key ...
OK
Running apt-get update ...
命中:1 https://pro-driver-packages.uniontech.com eagle InRelease
命中:2 https://dl.google.com/linux/chrome/deb stable InRelease                                               
命中:4 https://community-packages.deepin.com/deepin apricot InRelease                                        
命中:5 https://community-packages.deepin.com/driver driver InRelease                                         
命中:3 https://packages.microsoft.com/repos/code stable InRelease                                            
命中:6 https://community-packages.deepin.com/printer eagle InRelease                                         
获取:7 http://apt.postgresql.org/pub/repos/apt buster-pgdg InRelease [157 kB]                                
获取:8 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 Packages [349 kB]                      
获取:9 http://apt.postgresql.org/pub/repos/apt buster-pgdg/main i386 Packages [344 kB]        
命中:10 https://app-store-files.uniontech.com/240709181548520/appstore deepin InRelease
已下载 850 kB,耗时 5秒 (188 kB/s)
正在读取软件包列表... 完成

You can now start installing packages from apt.postgresql.org.

Have a look at https://wiki.postgresql.org/wiki/Apt for more information;
most notably the FAQ at https://wiki.postgresql.org/wiki/Apt/FAQ

执行成功,查看postgresql最新版本

$ apt show postgresql
Package: postgresql
Version: 16+261.pgdg100+1
Priority: optional
Section: database
Source: postgresql-common (261.pgdg100+1)
Maintainer: Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org>
Installed-Size: 74.8 kB
Depends: postgresql-16
Suggests: postgresql-doc
Download-Size: 69.5 kB
APT-Sources: http://apt.postgresql.org/pub/repos/apt buster-pgdg/main amd64 Packages
Description: object-relational SQL database (supported version)
 This metapackage always depends on the currently supported PostgreSQL
 database server version.
 .
 PostgreSQL is a fully featured object-relational database management
 system.  It supports a large part of the SQL standard and is designed
 to be extensible by users in many aspects.  Some of the features are:
 ACID transactions, foreign keys, views, sequences, subqueries,
 triggers, user-defined types and functions, outer joins, multiversion
 concurrency control.  Graphical user interfaces and bindings for many
 programming languages are available as well.

N: 有 1 条附加记录。请加上 ‘-a’ 参数来查看它们

更新软件包

$ sudo apt upgrade

查看当前版本

$ sudo apt list postgresql
正在列表... 完成
postgresql/buster-pgdg,buster-pgdg,now 16+261.pgdg100+1 all [已安装]
N: 还有 1 个版本。请使用 -a 选项来查看它(他们)。

在PostgreSQL中查看版本

$ psql --version
psql (PostgreSQL) 16.3 (Debian 16.3-1.pgdg100+1)

更新成功

posted on 2024-07-11 17:07  RandolphChen  阅读(13)  评论(0编辑  收藏  举报

导航