首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PostgreSQL15的安装似乎失败了

PostgreSQL15的安装似乎失败了
EN

Server Fault用户
提问于 2022-09-18 11:09:47
回答 1查看 3.2K关注 0票数 0

提前道歉,如果这是一个愚蠢的问题-我是一个开发人员,而不是一个系统管理员。

由于在我的ubuntu (Oracle )上运行apt-get更新/升级,我似乎无法在线获得postgresql数据库。我相信这可能是因为postgresql-15已经从beta-3升级到了beta-4。

这对我来说是一个真正的麻烦,因为它破坏了我们的开发环境。(我假设当我们准备好发布第15版时将完全可用,我非常希望能够在代码中使用merge语句)

我从主机上删除了postgresql,现在正在尝试在这些指示之后重新安装。

在步骤3. sudo -u postgres psql中,我收到了折叠错误:psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket?

这基本上是我在升级失败后所面临的问题(尽管我已经运行了systemctl start postgresql)。

有人能建议我该怎么做才能让postgres-15 (最好是beta-4)启动并运行吗?

代码语言:javascript
复制
hugh@ububtuvm:~$ systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor p>
     Active: active (exited) since Sun 2022-09-18 10:47:19 UTC; 31min ago
    Process: 2349 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 2349 (code=exited, status=0/SUCCESS)
        CPU: 905us

Sep 18 10:47:19 ububtuvm systemd[1]: Starting PostgreSQL RDBMS...
Sep 18 10:47:19 ububtuvm systemd[1]: Finished PostgreSQL RDBMS.


hugh@ububtuvm:~$ journalctl -xeu postgresql.service
░░ Subject: A stop job for unit postgresql.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit postgresql.service has begun execution.
░░
░░ The job identifier is 1675.
Sep 18 10:47:19 ububtuvm systemd[1]: Starting PostgreSQL RDBMS...
░░ Subject: A start job for unit postgresql.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit postgresql.service has begun execution.
░░
░░ The job identifier is 1675.
Sep 18 10:47:19 ububtuvm systemd[1]: Finished PostgreSQL RDBMS.
░░ Subject: A start job for unit postgresql.service has finished successfully
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit postgresql.service has finished successfully.
░░
░░ The job identifier is 1675.
代码语言:javascript
复制
root@ubuntuvm:/home/hugh# cat /usr/lib/systemd/system/postgresql.service
# postgresql.service is the meta unit for managing all PostgreSQL clusters on
# the system at once. Conceptually, this unit is more like a systemd target,
# but we are using a service since targets cannot be reloaded.
#
# The unit actually managing PostgreSQL clusters is postgresql@.service,
# instantiated as postgresql@15-main.service for individual clusters.

[Unit]
Description=PostgreSQL RDBMS

[Service]
Type=oneshot
ExecStart=/bin/true
ExecReload=/bin/true
RemainAfterExit=on

[Install]
WantedBy=multi-user.target

(由apt安装)

我找到了包含以下段落的

在从alpha或beta版本更新之后,我从alpha或beta包升级后得到了一个关于CATALOG_VERSION的错误,比如:数据库集群是用CATALOG_VERSION_NO X初始化的,但是服务器是用CATALOG_VERSION_NO Y编译的。这是因为在alpha版本之间,PostgreSQL数据格式可能会发生变化--如果真的有迫切的需求,有时甚至在beta版本之间也会发生变化。如果需要访问旧数据,则需要使用以前运行的包版本,并使用pg_dump或pg_upgrade。所需的二进制文件应该保存在/var/tmp/postgresql*中。或者,在/var/cache/apt/存档中查找旧包。

尽管如此,我仍然在挣扎--我还没有在任何地方找到以前的版本。

EN

回答 1

Server Fault用户

发布于 2022-09-18 13:16:57

Ubuntu对运行多个postgres实例有一些聪明的支持。postgresql.service单元只是一个虚拟单元:它只运行/bin/true。这听起来可能没什么用,但事实并非如此!关键是这个单元的依赖关系很重要,这些依赖在启动时由/lib/systemd/system-generators/postgresql-generator动态生成。

这将查看系统上的所有/etc/postgresql/*/*/postgresql.conf文件,并使用这些文件生成postgresql@.service模板单元的实例。

在安装postgresql-15包时,这应该是:

  1. 提供文件/etc/postgresql/15/main/postgresql.conf (以及该目录中的其他文件),以及
  2. 自动启动postgresql@15-main.service单元。

我在一个Ubuntu22.04系统上复制了这个例子,我从postgresql-14开始,然后按照您问题中的链接安装了postgresql-15,现在我已经:

代码语言:javascript
复制
root@ubuntu:~# systemctl list-units postgresql\*
  UNIT                       LOAD   ACTIVE SUB     DESCRIPTION
  postgresql.service         loaded active exited  PostgreSQL RDBMS
  postgresql@14-main.service loaded active running PostgreSQL Cluster 14-main
  postgresql@15-main.service loaded active running PostgreSQL Cluster 15-main

我可以成功地连接到数据库,但是由于在这里运行两个不同的postgres实例,我需要指定一个显式端口。查看/etc/postgresql/...中的配置文件,我发现postgres 15实例使用的是端口5433,因此我运行:

代码语言:javascript
复制
root@ubuntu:/# sudo -u postgres psql -p 5433
psql (15beta4 (Ubuntu 15~beta4-1.pgdg22.04+1))
Type "help" for help.

postgres=#

如果Postgresql 15服务启动失败,要查看我将运行的服务状态:

代码语言:javascript
复制
systemctl status postgresql@15-main.service

为了查看日志,我会运行:

代码语言:javascript
复制
journalctl -u postgresql@15-main.service
票数 3
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1110982

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档