PostgreSQL 15のアップデート

成功しました。次のコマンドを使用してデータベースサーバーを開始できます。

    pg_ctlcluster 13 main start

invoke-rc.d: 現在のランレベルを特定できませんでした
invoke-rc.d: policy-rc.d が start の実行を拒否しました。
postgresql-13-pgvector (0.8.0-1.pgdg120+1) の設定中...
libc-bin (2.36-9+deb12u9) のトリガーを処理中...
postgresql-common (267.pgdg120+1) のトリガーを処理中...
インストールされている myspell/hunspell パッケージから PostgreSQL 辞書を構築中...
古い辞書ファイルを削除中:
PostgreSQL 13 データベースサーバーを停止中: main。
PostgreSQL 15 データベースサーバーを停止中: main。
整合性チェックを実行中
-----------------------------
クラスターバージョンをチェック中                                   ok

ソースクラスターはクリーンにシャットダウンされませんでした。
失敗、終了します
-------------------------------------------------------------------------------------
POSTGRES のアップグレードに失敗しました
-------------------------------------------------------------------------------------

サポートについては、https://meta.discourse.org/t/postgresql-15-update/349515 をご覧ください。

それまでの間、./launcher start app を実行してアプリを再起動できます。
-------------------------------------------------------------------------------------


失敗しました
--------------------
Pups::ExecError: if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi
 失敗しました。リターンコード #<Process::Status: pid 17 exit 1>
失敗場所: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec はパラメータ {\"tag\"=>\"db\", \"cmd\"=>\"if [ -f /root/install_postgres ]; then\\n  /root/install_postgres && rm -f /root/install_postgres\\nelif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then\\n  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1\\nfi\\n\"} で失敗しました。
ブートストラップに失敗しました。終了コード 1
** ブートストラップに失敗しました ** 上記にスクロールして、以前のエラーメッセージを探してください。複数ある場合があります。
./discourse-doctor が問題を診断するのに役立つかもしれません。
cbebd339ee3bd1e246300784f7825042702c1b5032877bfe580cb7f635fb852b

ディスク情報:

========================================
Discourse 3.4.0.beta3
mydomian の Discourse バージョン: Discourse 3.4.0.beta3
localhost の Discourse バージョン: Discourse 3.4.0.beta3


==================== メモリ情報 ====================
RAM (MB): 2055

              合計        使用中        空き        共有  バッファ/キャッシュ    利用可能
メモリ:           1960        1463         100          43         396         255
スワップ:          2047          66        1981

==================== ディスク空き容量チェック ====================
---------- OS ディスク空き容量 ----------
ファイルシステム      サイズ  使用量  利用可能 使用% マウントポイント
/dev/root        59G   45G   14G  77% /

---------- コンテナディスク空き容量 ----------
ファイルシステム      サイズ  使用量  利用可能 使用% マウントポイント
overlay          59G   45G   14G  77% /
/dev/root        59G   45G   14G  77% /shared
/dev/root        59G   45G   14G  77% /var/log

==================== ディスク情報 ====================
ディスク /dev/loop0: 110.24 MiB, 115593216 バイト, 225768 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop2: 73.91 MiB, 77479936 バイト, 151328 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop3: 103.102 MiB, 109043712 バイト, 212976 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop4: 73.89 MiB, 77459456 バイト, 151288 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop5: 55.68 MiB, 58363904 バイト, 113992 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop6: 63.71 MiB, 66789376 バイト, 130448 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop7: 63.10 MiB, 67080192 バイト, 131016 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/xvda: 60 GiB, 64424509440 バイト, 125829120 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト
ディスクラベルタイプ: dos
ディスク識別子: 0x15e6b846

デバイス     ブート 開始       終了   セクター サイズ Id タイプ
/dev/xvda1 *     2048 125829086 125827039  60G 83 Linux


ディスク /dev/loop8: 26.33 MiB, 27602944 バイト, 53912 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop9: 110.4 MiB, 115384320 バイト, 225360 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop10: 55.37 MiB, 58052608 バイト, 113384 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop11: 104.2 MiB, 109252608 バイト, 213384 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト


ディスク /dev/loop13: 25.76 MiB, 26992640 バイト, 52720 セクター
単位: セクター (1 * 512 = 512 バイト)
セクターサイズ (論理/物理): 512 バイト / 512 バイト
I/O サイズ (最小/最適): 512 バイト / 512 バイト

==================== ディスク情報終了 ====================

この問題が発生した場合、Docker を先にアップグレードする必要があるということでしょうか?
現在、3.4.0.beta3-dev(93983286b5) を使用しています。

更新: 再度ビルドしたところ、今回は正常に完了しました。

「いいね!」 2

OPにそのための具体的な手順があります。

問題があるかどうかに関わらず、Dockerをアップグレードすべきでしょう。

「いいね!」 2

私にとって最終的に役立ったのは、docker を更新することでした。
https://stackoverflow.com/a/30794189 に従い、その後以下を実行しました。
sudo service docker start

その後、初めて以下を実行しました。

./launcher start app
./launcher stop app
./launcher rebuild app
「いいね!」 3

I’m having significant problems doing this upgrade too. Similar @Vaping_Community, I have postgres on a different mounted volume (/mnt/volume_tor1_01/shared/standalone).

I am getting this error

mv: cannot move '/shared/postgres_data' to '/shared/postgres_data_old': Device or resource busy
mv: inter-device move failed: '/shared/postgres_data_new' to '/shared/postgres_data/postgres_data_new'; unable to remove target: Directory not empty

 [...]

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
    /usr/lib/postgresql/15/bin/vacuumdb --all --analyze-in-stages

Running this script will delete the old cluster's data files:
    ./delete_old_cluster.sh
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES COMPLETE

Old 13 database is stored at /shared/postgres_data_old

To complete the upgrade, rebuild again using:

./launcher rebuild app
-------------------------------------------------------------------------------------

My understanding is that the solution is to basically manually rename
postgres_datapostgres_data_old
postgres_newpostgres_data

then run ./launcher rebuild app. Seems simple enough, but when I rebuild, I still am stuck in the loop and end up with the following directories:

  • postgres_data_older
  • postgres_data_old (I think it becomes postgres_data_older)
  • postgres_data
  • postgres_data_new

It seems like for some reason it’s not recognizing that postgres_data has updated, tries to do it again, fails when trying to move the directory.

$ cat postgres_data/PG_VERSION 
15

I tried the manual approach laid out in the OP but no luck either. Please help!

full log
x86_64 arch detected.
Ensuring launcher is up to date
Fetching origin
Launcher is up-to-date
Stopping old container
+ /usr/bin/docker stop -t 600 app
app
2.0.20250129-0720: Pulling from discourse/base
Digest: sha256:01b8516e5504c0e9bc3707773015ff4407be03a89154194ff3b5b8699291bc26
Status: Image is up to date for discourse/base:2.0.20250129-0720
docker.io/discourse/base:2.0.20250129-0720
/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups.rb
/usr/local/bin/pups --stdin
I, [2025-02-23T11:41:32.477354 #1]  INFO -- : Reading from stdin
I, [2025-02-23T11:41:32.504068 #1]  INFO -- : File > /etc/service/postgres/run  chmod: +x  chown: 
I, [2025-02-23T11:41:32.508552 #1]  INFO -- : File > /etc/service/postgres/log/run  chmod: +x  chown: 
I, [2025-02-23T11:41:32.513290 #1]  INFO -- : File > /etc/runit/3.d/99-postgres  chmod: +x  chown: 
I, [2025-02-23T11:41:32.517671 #1]  INFO -- : File > /root/install_postgres  chmod: +x  chown: 
I, [2025-02-23T11:41:32.522244 #1]  INFO -- : File > /root/upgrade_postgres  chmod: +x  chown: 
I, [2025-02-23T11:41:32.523354 #1]  INFO -- : Replacing data_directory = '/var/lib/postgresql/15/main' with data_directory = '/shared/postgres_data' in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-23T11:41:32.523912 #1]  INFO -- : Replacing (?-mix:#?listen_addresses *=.*) with listen_addresses = '*' in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-23T11:41:32.524756 #1]  INFO -- : Replacing (?-mix:#?synchronous_commit *=.*) with synchronous_commit = $db_synchronous_commit in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-23T11:41:32.525365 #1]  INFO -- : Replacing (?-mix:#?shared_buffers *=.*) with shared_buffers = $db_shared_buffers in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-23T11:41:32.526239 #1]  INFO -- : Replacing (?-mix:#?work_mem *=.*) with work_mem = $db_work_mem in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-23T11:41:32.526873 #1]  INFO -- : Replacing (?-mix:#?default_text_search_config *=.*) with default_text_search_config = '$db_default_text_search_config' in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-23T11:41:32.527613 #1]  INFO -- : Replacing (?-mix:#?checkpoint_segments *=.*) with checkpoint_segments = $db_checkpoint_segments in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-23T11:41:32.531734 #1]  INFO -- : Replacing (?-mix:#?logging_collector *=.*) with logging_collector = $db_logging_collector in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-23T11:41:32.532882 #1]  INFO -- : Replacing (?-mix:#?log_min_duration_statement *=.*) with log_min_duration_statement = $db_log_min_duration_statement in /etc/postgresql/15/main/postgresql.conf
I, [2025-02-23T11:41:32.534021 #1]  INFO -- : Replacing (?-mix:^#local +replication +postgres +peer$) with local replication postgres  peer in /etc/postgresql/15/main/pg_hba.conf
I, [2025-02-23T11:41:32.534342 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*127.*$) with host all all 0.0.0.0/0 md5 in /etc/postgresql/15/main/pg_hba.conf
I, [2025-02-23T11:41:32.534935 #1]  INFO -- : Replacing (?-mix:^host.*all.*all.*::1\/128.*$) with host all all ::/0 md5 in /etc/postgresql/15/main/pg_hba.conf
I, [2025-02-23T11:41:32.535476 #1]  INFO -- : > if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
W: https://dl.yarnpkg.com/debian/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
debconf: delaying package configuration, since apt-utils is not installed
mv: cannot move '/shared/postgres_data' to '/shared/postgres_data_old': Device or resource busy
mv: inter-device move failed: '/shared/postgres_data_new' to '/shared/postgres_data/postgres_data_new'; unable to remove target: Directory not empty
I, [2025-02-23T11:42:52.303584 #1]  INFO -- : Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
Upgrading PostgreSQL from version 13 to 15
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /shared/postgres_data_new ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok


Success. You can now start the database server using:

    /usr/lib/postgresql/15/bin/pg_ctl -D /shared/postgres_data_new -l logfile start

Get:1 http://deb.debian.org/debian bookworm-backports InRelease [59.0 kB]
Get:2 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:4 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:5 https://dl.yarnpkg.com/debian stable InRelease [17.1 kB]
Get:6 https://deb.nodesource.com/node_22.x nodistro InRelease [12.1 kB]
Get:7 http://deb.debian.org/debian bookworm-backports/main amd64 Packages [283 kB]
Get:8 http://deb.debian.org/debian bookworm/main amd64 Packages [8,792 kB]
Get:9 http://deb.debian.org/debian bookworm-updates/main amd64 Packages [13.5 kB]
Get:10 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [246 kB]
Get:11 https://dl.yarnpkg.com/debian stable/main amd64 Packages [10.9 kB]
Get:12 https://dl.yarnpkg.com/debian stable/main all Packages [10.9 kB]
Get:13 https://apt.postgresql.org/pub/repos/apt bookworm-pgdg InRelease [129 kB]
Get:14 https://deb.nodesource.com/node_22.x nodistro/main amd64 Packages [5,636 B]
Get:15 https://apt.postgresql.org/pub/repos/apt bookworm-pgdg/main amd64 Packages [360 kB]
Fetched 10.2 MB in 2s (6,490 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  libllvm19 postgresql-client-13
Suggested packages:
  postgresql-doc-13
The following NEW packages will be installed:
  libllvm19 postgresql-13 postgresql-13-pgvector postgresql-client-13
0 upgraded, 4 newly installed, 0 to remove and 12 not upgraded.
Need to get 41.6 MB of archives.
After this operation, 184 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 libllvm19 amd64 1:19.1.4-1~deb12u1 [25.9 MB]
Get:2 https://apt.postgresql.org/pub/repos/apt bookworm-pgdg/main amd64 postgresql-client-13 amd64 13.20-1.pgdg120+1 [1,538 kB]
Get:3 https://apt.postgresql.org/pub/repos/apt bookworm-pgdg/main amd64 postgresql-13 amd64 13.20-1.pgdg120+1 [13.9 MB]
Get:4 https://apt.postgresql.org/pub/repos/apt bookworm-pgdg/main amd64 postgresql-13-pgvector amd64 0.8.0-1.pgdg120+1 [297 kB]
Fetched 41.6 MB in 2s (18.8 MB/s)
Selecting previously unselected package libllvm19:amd64.
(Reading database ... 33363 files and directories currently installed.)
Preparing to unpack .../libllvm19_1%3a19.1.4-1~deb12u1_amd64.deb ...
Unpacking libllvm19:amd64 (1:19.1.4-1~deb12u1) ...
Selecting previously unselected package postgresql-client-13.
Preparing to unpack .../postgresql-client-13_13.20-1.pgdg120+1_amd64.deb ...
Unpacking postgresql-client-13 (13.20-1.pgdg120+1) ...
Selecting previously unselected package postgresql-13.
Preparing to unpack .../postgresql-13_13.20-1.pgdg120+1_amd64.deb ...
Unpacking postgresql-13 (13.20-1.pgdg120+1) ...
Selecting previously unselected package postgresql-13-pgvector.
Preparing to unpack .../postgresql-13-pgvector_0.8.0-1.pgdg120+1_amd64.deb ...
Unpacking postgresql-13-pgvector (0.8.0-1.pgdg120+1) ...
Setting up libllvm19:amd64 (1:19.1.4-1~deb12u1) ...
Setting up postgresql-client-13 (13.20-1.pgdg120+1) ...
Setting up postgresql-13 (13.20-1.pgdg120+1) ...
Creating new PostgreSQL cluster 13/main ...
/usr/lib/postgresql/13/bin/initdb -D /var/lib/postgresql/13/main --auth-local peer --auth-host md5
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "C.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/13/main ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctlcluster 13 main start

invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up postgresql-13-pgvector (0.8.0-1.pgdg120+1) ...
Processing triggers for libc-bin (2.36-9+deb12u9) ...
Processing triggers for postgresql-common (267.pgdg120+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Stopping PostgreSQL 13 database server: main.
Stopping PostgreSQL 15 database server: main.
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for system-defined composite types in user tables  ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for user-defined encoding conversions              ok
Checking for user-defined postfix operators                 ok
Checking for incompatible polymorphic functions             ok
Creating dump of global objects                             ok
Creating dump of database schemas                           ok
Checking for presence of required libraries                 ok
Checking database user is the install user                  ok
Checking for prepared transactions                          ok
Checking for new cluster tablespace directories             ok

If pg_upgrade fails after this point, you must re-initdb the
new cluster before continuing.

Performing Upgrade
------------------
Analyzing all rows in the new cluster                       ok
Freezing all rows in the new cluster                        ok
Deleting files from new pg_xact                             ok
Copying old pg_xact to new server                           ok
Setting oldest XID for new cluster                          ok
Setting next transaction ID and epoch for new cluster       ok
Deleting files from new pg_multixact/offsets                ok
Copying old pg_multixact/offsets to new server              ok
Deleting files from new pg_multixact/members                ok
Copying old pg_multixact/members to new server              ok
Setting next multixact ID and offset for new cluster        ok
Resetting WAL archives                                      ok
Setting frozenxid and minmxid counters in new cluster       ok
Restoring global objects in the new cluster                 ok
Restoring database schemas in the new cluster               ok
Copying user relation files                                 ok
Setting next OID for new cluster                            ok
Sync data directory to disk                                 ok
Creating script to delete old cluster                       ok
Checking for extension updates                              notice

Your installation contains extensions that should be updated
with the ALTER EXTENSION command.  The file
    update_extensions.sql
when executed by psql by the database superuser will update
these extensions.


Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
    /usr/lib/postgresql/15/bin/vacuumdb --all --analyze-in-stages

Running this script will delete the old cluster's data files:
    ./delete_old_cluster.sh
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES COMPLETE

Old 13 database is stored at /shared/postgres_data_old

To complete the upgrade, rebuild again using:

./launcher rebuild app
-------------------------------------------------------------------------------------
「いいね!」 1

ARM (aarch64) での非デフォルトロケールでのアップグレード

コンテナ2つで構成された単一サーバーでの不具合のあるアップグレードの修正に時間を費やしました。

  1. CPUはARMです。
  2. Discourseは en_UK.UTF-8 ロケールで設定されていました。

段階的に、以下のことがわかりました。

  1. tianon/postgres-upgrade:13-to-15 はARMでは動作しません。
  2. ロケール設定は share/${CONTAINER}/postgres_data/postgresql.conf に保存されています。

まず、デフォルトロケールを使用するように、データコンテナの env: 部分をコメントアウトしました。

そこで、アップグレードの混乱から抜け出すために、en_GBen_US の照合順序の違いは無視できると仮定し、クラスタ全体を en_US に強制的に更新するという 危険な ステップを取りました。

UPDATE pg_database SET datctype='en_US.UTF-8', datcollate='en_US.UTF-8';

このステップが必要かどうかは 定かではありませんYMMV(結果は異なる場合があります)。より知識のある方がコメントできるようにここに残しておきますが、異なる言語の場合は 全くお勧めしません

次に postgresql.conf のロケールを置き換えました。

sed -i -e 's/en_GB/en_US/g' shared/data/postgres_data/postgresql.conf
sudo -H -u discourse ./launcher rebuild data
...
UPGRADE OF POSTGRES COMPLETE

:tada:

簡単だったと思わないでください。特に、私が介入したときには管理インターフェースが利用できず、最後のバックアップが6日前に作成されていたため、オプションの探索に費やした長い道のりは言及していません。適切な、あるいは少なくとも動作する解決策にたどり着く前に、 いじくり回す必要がありました

これが皆さんの時間を節約できれば幸いです。

「いいね!」 5

すべての再構築で、ログにこのメッセージが表示されていますか?もしそうなら、おそらく誤ったディレクトリを参照(手動で名前を変更)していた可能性があります。

コンテナの /shared ボリュームがホストの /mnt/volume_tor1_01/shared/standalone にマッピングされている場合、cat /mnt/volume_tor1_01/shared/standalone/postgres_data/PG_VERSION15 ではなく 13 を返すはずです。

サニタイズされた app.yml ファイルを共有していただけますか?

「いいね!」 4

問題点を正しく特定されたと思います。私のアプリの app.yml は以下のようになっています。

## Dockerコンテナはステートレスであり、すべてのデータは /shared に保存されます
volumes:
  - volume:
      host: /mnt/volume_tor1_01/shared/standalone
      guest: /shared
  - volume:
      host: /mnt/volume_tor1_01/shared/standalone/log/var-log
      guest: /var/log
  - volume:
      host: /var/postgres_data_discourse
      guest: /shared/postgres_data

(このガイドに基づいています: https://meta.discourse.org/t/move-uploads-and-backups-to-digitalocean-block-storage/89274)

$ cat postgres_data/PG_VERSION
15
$ cat /var/postgres_data_discourse/PG_VERSION
13

したがって、このアプローチで問題が解決されると考えています: PostgreSQL 15 update - #125 by Vaping_Community

私を混乱させたのは、mntボリュームに複数の postgres_data フォルダがあったこと(再ビルドを複数回実行したため)で、ソースフォルダが実際には /var/ にあることに気づかなかったことだと思います。

今夜試してみます。

「いいね!」 2

新しいVMを立ち上げてバックアップを復元する方がはるかに簡単です。そうすれば、PGのアップグレードステップを完全にスキップでき、新しいサイトが動作する前に古いサイトを壊すことはありません。

「いいね!」 8

うまくいきました:)

「いいね!」 2

UID が変更されることに注意してください!

/launcher enter app
x86_64 アーキテクチャが検出されました。
grep postgres /etc/passwd
postgres:x:101:104:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash

これは私を引っ掛けました…

はい、うまくいきましたが、OP投稿の更新された指示を使用した方が良いでしょう。

投稿を編集してメモを追加することができません。

「いいね!」 2

私も失敗しています。

more /var/discourse/shared/standalone/postgres_data_new/pg_upgrade_output.d/20250416T103311.340/log/pg_upgrade_server.log

-----------------------------------------------------------------
  pg_upgrade run on Wed Apr 16 10:33:11 2025
-----------------------------------------------------------------

command: "/usr/lib/postgresql/13/bin/pg_ctl" -w -l "/shared/postgres_data_new/pg_upgrade_output.d/20250416T103311.340/log/pg_upgrade_server.log" -D "/shared/postgres_data" -o
"-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/postgresql'" start >> "/shared/postgres_data_new/pg_upgrade_output.d/
20250416T103311.340/log/pg_upgrade_server.log" 2>&1
waiting for server to start....2025-04-16 10:33:11.515 UTC [1887] LOG:  starting PostgreSQL 13.20 (Debian 13.20-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12
.2.0-14) 12.2.0, 64-bit
2025-04-16 10:33:11.517 UTC [1887] LOG:  listening on Unix socket "/var/lib/postgresql/.s.PGSQL.50432"
2025-04-16 10:33:11.525 UTC [1887] LOG:  could not open configuration file "/etc/postgresql/13/main/pg_hba.conf": No such file or directory
2025-04-16 10:33:11.525 UTC [1887] FATAL:  could not load pg_hba.conf
2025-04-16 10:33:11.526 UTC [1887] LOG:  database system is shut down

/etc/postgresql/13/main/pg_hba.conf が見つからないようですが、それは存在しないため正しいです。ただし、複数の場所に存在します。

/var/discourse/shared/standalone/postgres_data_older/pg_hba.conf
/var/discourse/shared/standalone/postgres_data_new/pg_hba.conf
/var/discourse/shared/standalone/postgres_data/pg_hba.conf
/var/lib/docker/overlay2/6514156241efd883dd59b27a0275ba1cc73a7365fb78c5782536a39ee2d6d641/diff/etc/postgresql/13/main/pg_hba.conf
/var/lib/docker/overlay2/8afed861b039e5a366dc9a5513cd7df5a958d86a41f05063ce5256fb9f8fdfec/diff/etc/postgresql/13/main/pg_hba.conf
/var/lib/docker/overlay2/fa8893e9f714439469d391635d8882b345e90705a886d74cf6fea8d5460df3f0/diff/etc/postgresql/15/main/pg_hba.conf
/var/lib/docker/overlay2/e4eec92eb7b181648ca2bc6744ac3af0935745b75b1abe89170fc4b82a8eca42/diff/etc/postgresql/13/main/pg_hba.conf
/var/lib/docker/overlay2/4cd3189b9d554b1c60891dc5d48cc670e5d7d847ec5a0f2dfa91ad7f66b3a211/diff/etc/postgresql/13/main/pg_hba.conf
/var/lib/docker/overlay2/0db2210fc76fce6f41912183f744517154f46af15a0b1a1e976999eabbd801d9/diff/etc/postgresql/15/main/pg_hba.conf
/var/postgres_data/postgres_data_new/pg_hba.conf
/var/postgres_data/pg_hba.conf

何かヒントはありますか?

あなたの docker run…コマンドを試しましたが、次のようになりました:

クラスタのバージョンを確認しています
古いクラスタのデータとバイナリディレクトリは異なるメジャーバージョンです。

あなたの Docker のバージョンは何ですか?あなたの OS のバージョンは何ですか?新しい VM に移行する方がしばしば簡単だということに気づきました。

Dockerのバージョン: 28.0.4
Linuxのバージョン: 5.15.0-131-generic

app.yml で postgres 13 テンプレートに変更してみてください。

それはコンテナの中です。コンテナの外を見ています。

Discourseをアップグレードするために変更したところ、正常に完了しました。現在は以下のようになっています。

templates:
  - "templates/postgres.13.template.yml"

これはPostgresをアップグレードできないということでしょうか?

これで通常のテンプレートに戻して、もう一度試すことができると思います。私なら新しいVMに移動しますが、試したいのであればもう一度試すこともできます。

Postgresは最初の投稿の説明に従って手動でアップグレードしましたが、テンプレートをpostgres.template.ymlに戻すことができません。同じ問題で再構築できないためです。

2025-04-16 13:40:07.815 UTC [1888] LOG: 設定ファイル「/etc/postgresql/13/main/pg_hba.conf」を開けませんでした: そのようなファイルやディレクトリはありません
2025-04-16 13:40:07.815 UTC [1888] FATAL: pg_hba.conf を読み込めませんでした

バージョン13のままにしておきます。将来壊れないことを願っています。
@pfaffman、ありがとうございました。

アップグレードを実行しようとしていますが、ファイルが見つからないため失敗しています。ファイルは存在することを確認しました。

ログの末尾 + ファイルの確認

-----------------------------
クラスターのバージョンを確認中                                   ok
 
*失敗*
失敗の可能性のある原因については、「/shared/postgres_data_new/pg_upgrade_output.d/20250605T024052.178/log/pg_upgrade_server.log」の最後の数行を参照してください。
 
「/var/lib/postgresql/.s.PGSQL.50432」というソケットへのサーバーへの接続に失敗しました: そのようなファイルやディレクトリはありません
        サーバーはローカルで実行されており、そのソケットで接続を受け付けていますか?
 
コマンドで起動されたソースのpostmasterに接続できませんでした:
「/usr/lib/postgresql/13/bin/pg_ctl」-w -l 「/shared/postgres_data_new/pg_upgrade_output.d/20250605T024052.178/log/pg_upgrade_server.log」 -D 「/shared/postgres_data」 -o 「-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/postgresql'」 start
失敗、終了します
-------------------------------------------------------------------------------------
POSTGRESのアップグレードに失敗しました
 
サポートについては、https://meta.discourse.org/t/postgresql-15-update/349515 を参照してください。
 
それまでの間、./launcher start app を実行してアプリを再起動できます
-------------------------------------------------------------------------------------
 
 
 
失敗
--------------------
Pups::ExecError: if [ -f /root/install_postgres ]; then
  /root/install_postgres && rm -f /root/install_postgres
elif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
fi
 1 の終了コード #<Process::Status: pid 17 exit 1> で失敗しました
失敗の場所: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec はパラメータ {\"tag\"=>\"db\", \"cmd\"=>\"if [ -f /root/install_postgres ]; then\\n  /root/install_postgres && rm -f /root/install_postgres\\nelif [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then\\n  socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1\\nfi\\n\"} で失敗しました
ブートストラップは終了コード 1 で失敗しました
** ブートストラップに失敗しました ** 上にスクロールして、以前のエラーメッセージを探してください。複数ある可能性があります。
./discourse-doctor は問題を診断するのに役立つかもしれません。
afa058b1ff7d14d9469fe27bc39dc08562c4e249bdf7c7e153b4030a1bb0dbc2
root@amcforum:/var/discourse# ./launcher start app && ./launcher enter app
x86_64 アーキテクチャを検出しました。
 
既存のコンテナを起動しています
+ /usr/bin/docker start app
app
x86_64 アーキテクチャを検出しました。
root@amcforum-app:/var/www/discourse# cat /shared/postgres_data_new/pg_upgrade_output.d/0250605T024052.178/log/pg_upgrade_server.log 
-----------------------------------------------------------------
  pg_upgrade は Thu Jun  5 02:40:52 2025 に実行されました
-----------------------------------------------------------------
 
コマンド: 「/usr/lib/postgresql/13/bin/pg_ctl」-w -l 「/shared/postgres_data_new/pg_upgrade_output.d/20250605T024052.178/log/pg_upgrade_server.log」 -D 「/shared/postgres_data」 -o 「-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directories='/var/lib/postgresql'」 start >> 「/shared/postgres_data_new/pg_upgrade_output.d/20250605T024052.178/log/pg_upgrade_server.log」 2>&1
サーバーの起動を待っています....2025-06-05 02:40:52.313 UTC [1886] LOG:  PostgreSQL 13.21 (Debian 13.21-1.pgdg120+1) を x86_64-pc-linux-gnu で起動しています。gcc (Debian 12.2.0-14) 12.2.0 でコンパイル済み、64ビット
2025-06-05 02:40:52.316 UTC [1886] LOG:  Unix ソケット「/var/lib/postgresql/.s.PGSQL.50432」でリッスンしています
2025-06-05 02:40:52.324 UTC [1886] LOG:  設定ファイル「/etc/postgresql/13/main/pg_hba.conf」を開けませんでした: そのようなファイルやディレクトリはありません
2025-06-05 02:40:52.324 UTC [1886] FATAL:  pg_hba.conf を読み込めませんでした
2025-06-05 02:40:52.327 UTC [1886] LOG:  データベースシステムはシャットダウンされています
  待機を停止しました
pg_ctl: サーバーを起動できませんでした
ログ出力を確認してください。
 
 
root@amcforum-app:/var/www/discourse# ls -lah "/etc/postgresql/13/main/pg_hba.conf"
-rw-r----- 1 postgres postgres 4.8K Jan  3 13:02 /etc/postgresql/13/main/pg_hba.conf
root@amcforum-app:/var/www/discourse#
「いいね!」 1