pg_upgrade 找不到配置文件

ygo*_*goe 7 postgresql

我正在尝试将 Ubuntu Server 上的 PostgreSQL 从 9.6 升级到 10。这是我第一次这样做。服务器尚不包含任何有用的数据,但我想确保下次我可以正确执行此操作。

我按照手册中的说明进行操作。这是我所做的:

  • 安装了版本 10 的新软件包
  • 停止了服务器上的两个版本
  • 运行 pg_upgrade 脚本:

    须藤 -u postgres /usr/lib/postgresql/10/bin/pg_upgrade -b /usr/lib/postgresql/9.6/bin -B /usr/lib/postgresql/10/bin -d /var/lib/postgresql/9.6 /main/ -D /var/lib/postgresql/10/main/

这是控制台输出:

Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok

*failure*
Consult the last few lines of "pg_upgrade_server.log" for
the probable cause of the failure.

connection to database failed: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/lib/postgresql/.s.PGSQL.50432"?

could not connect to source postmaster started with the command:
"/usr/lib/postgresql/9.6/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/postgresql/9.6/main/" -o "-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/postgresql'" start
Failure, exiting
Run Code Online (Sandbox Code Playgroud)

这是 pg_upgrade_server.log 的内容:

command: "/usr/lib/postgresql/9.6/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/postgresql/9.6/main/" -o "-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/postgresql'" start >> "pg_upgrade_server.log" 2>&1
waiting for server to start....postgres: could not access the server configuration file "/var/lib/postgresql/9.6/main/postgresql.conf": No such file or directory
 stopped waiting
pg_ctl: could not start server
Examine the log output.
Run Code Online (Sandbox Code Playgroud)

我现在完全糊涂了。我该怎么办?

ama*_*var 8

你知道他们怎么说假设这个词

我假设配置目录和数据目录是相同的。

答案 1:

将您的命令更改为此,它将起作用。

sudo -u postgres /usr/lib/postgresql/10/bin/pg_upgrade \
-b /usr/lib/postgresql/9.6/bin -B /usr/lib/postgresql/10/bin \
-d /var/lib/postgresql/9.6/main/ -D /var/lib/postgresql/10/main/
-o 'config_file=/etc/postgresql/9.6/main/postgresql.conf' \
-O 'config_file=/etc/postgresql/10/main/postgresql.conf'
Run Code Online (Sandbox Code Playgroud)

我们可以提供特殊的配置文件位置作为选项

另外,我相信您已经确定了默认安装问题或需要更新文档

默认安装应该在 datadir 中创建配置文件

答案 2:

既然这是玩,也试试这个:

sudo -u postgres pg_dropcluster 10 main
sudo -u postgres pg_upgradecluster 9.6 main
Run Code Online (Sandbox Code Playgroud)

保留这个,因为它可能会帮助别人。

空数据库似乎尚未创建。或者在不同的目录中。这就是为什么在错误消息中找不到 postgresql.conf 的原因。

ls -l /var/lib/postgresql/9.6/main/postgresql.conf /var/lib/postgresql/10/main/postgresql.conf

应该显示两个文件。

应该运行两个版本的等效 initdb 命令

pg_ctl -D /var/lib/postgresql/9.6/main initdb

pg_ctl -D /var/lib/postgresql/10/main initdb
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,我在这个答案之后取得了一些进展。然而,旧的和新的选项参数都应该在 `config_file` 之前有 `-c`,所以 `-o '-c config_file=/path/to/postgresql.conf'`。另外,我认为您的答案 1 中的第三行缺少反斜杠。 (6认同)
  • 所以我说 -d & -D 是数据和配置文件所在的位置是错误的。它实际上是*config 目录*。谢谢 - 我今天学到了一些东西,文档也需要更新 (2认同)