# PostgreSQL 15のアップデート

**URL:** https://meta.discourse.org/t/postgresql-15-update/349515
**Category:** Announcements
**Created:** [2025 年 1 月 29 日午前 7:20 UTC](https://meta.discourse.org/t/postgresql-15-update/349515 "2025-01-29T07:20:00Z")
**Posts on this page:** 20
**Page:** 4

<div class="post-metadata">

### Author: ![sober](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sober/32/344783_2.png) [@sober](https://meta.discourse.org/u/sober)
#### Post date: [2025 年 2 月 8 日午前 3:57 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/110 "2025-02-08T03:57:09Z")

</div>

> [@PostgreSQL update fails from China](https://meta.discourse.org/t/postgresql-update-fails-from-china/350869/19?u=sober):
>
> I got the upgrade PostgreSQL15 Templates need to be used in sequence postgres.13.template.yml postgres.15.template.yml postgres.template.yml postgres.13.template.yml、postgres.15.template.yml file China network acceleration configuration run: - exec: cat /etc/os-release && psql --version - exec: | if [-f /etc/apt/sources.list]; then sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list else echo "deb http://mirrors.ustc.edu.cn/debian bo…

---

<div class="post-metadata">

### Author: ![henvo](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@henvo](https://meta.discourse.org/u/henvo)
#### Post date: [2025 年 2 月 8 日午前 6:56 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/111 "2025-02-08T06:56:31Z")

</div>

アップグレード中に、以下のようなエラーが発生しました。

> PostgreSQL 15 データベースサーバーを停止しています: mainエラー: 設定のオーナー (postgres:101) とデータのオーナー (runit-log:999) が一致せず、設定のオーナーが root ではありません… 失敗しました！  
> 失敗しました！  
> バージョンファイル “/shared/postgres\_data/PG\_VERSION” を開けませんでした: 権限がありません  
> 失敗、終了します

これは、以下によって解決されました。

> sudo ./launcher enter app

そして

> chown -R postgres:postgres /shared/postgres\_data  
> chown -R postgres:postgres /shared/postgres\_run  
> chmod -R 700 /shared/postgres\_data

---

<div class="post-metadata">

### Author: ![Vaping\_Community](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vaping_community/32/89248_2.png) [@Vaping\_Community](https://meta.discourse.org/u/Vaping_Community)
#### Post date: [2025 年 2 月 8 日午前 10:16 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/112 "2025-02-08T10:16:44Z")

</div>

無限ループに陥っています。データベースは正常に更新されましたが、`./launcher rebuild app` を実行するとループしてしまいます。見えるのは以下の情報だけです。

編集：このメッセージを見つけました…

`mv: デバイス間で移動できません: '/shared/postgres_data_new' を '/shared/postgres_data/postgres_data_new' に移動できません。ターゲットを削除できません: ディレクトリが空ではありません`

```plaintext
お使いのインストールには、ALTER EXTENSION コマンドで更新する必要がある拡張機能が含まれています。
    update_extensions.sql
ファイルをデータベースのスーパーユーザーが psql で実行すると、これらの拡張機能が更新されます。

```

アドバイスをお願いします。

```plaintext
アップグレード完了
----------------
オプティマイザ統計は pg_upgrade では転送されません。
新しいサーバーを起動したら、以下を実行することを検討してください。
    /usr/lib/postgresql/15/bin/vacuumdb --all --analyze-in-stages

このスクリプトを実行すると、古いクラスターのデータファイルが削除されます。
    ./delete_old_cluster.sh
-------------------------------------------------------------------------------------
POSTGRES のアップグレード完了
古い 13 データベースは /shared/postgres_data_old に保存されています。
アップグレードを完了するには、以下を使用して再度再構築してください。

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

```

さて、問題はここにあるようです。

これらは `shared/standalone/` にあり、すでに手動で移動されています…

```plaintext
mv: '/shared/postgres_data' を '/shared/postgres_data_old' に移動できません: デバイスまたはリソースがビジー状態です
mv: デバイス間で移動できません: '/shared/postgres_data_new' を '/shared/postgres_data/postgres_data_new' に移動できません。ターゲットを削除できません: ディレクトリが空ではありません
I, [2025-02-08T15:22:42.078189 #1] INFO -- : ロケールを生成しています (これにはしばらく時間がかかる場合があります)...

```

---

<div class="post-metadata">

### Author: ![sallypf](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@sallypf](https://meta.discourse.org/u/sallypf)
#### Post date: [2025 年 2 月 8 日午後 5:14 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/113 "2025-02-08T17:14:18Z")

</div>

どの解決策も効果がないようです。とてもイライラします。

---

<div class="post-metadata">

### Author: ![JimPas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimpas/32/148179_2.png) [@JimPas](https://meta.discourse.org/u/JimPas)
#### Post date: [2025 年 2 月 8 日午後 5:21 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/114 "2025-02-08T17:21:24Z")

</div>

> [@anon55243134](#):
>
> また、誰かが高額な料金でこれを修正すると申し出てきました。このフォーラムでそのような行為は適切ですか？

まず尋ねられることなく、そのようなサービスを提供すると申し出るのは非常に珍しいことです。  
誰かを雇いたい場合は、ここに行きましょう: [Marketplace - Discourse Meta](https://meta.discourse.org/c/marketplace/14)

---

<div class="post-metadata">

### Author: ![leilajean](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leilajean/32/262955_2.png) [@leilajean](https://meta.discourse.org/u/leilajean)
#### Post date: [2025 年 2 月 8 日午後 5:28 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/115 "2025-02-08T17:28:04Z")

</div>

アップグレード後にマルチサイトインスタンスがダウンしました。次のように表示されました。

> インストールには、ALTER EXTENSION コマンドで更新する必要がある拡張機能が含まれています。
> 
> ```
> update_extensions.sql
> 
> ```
> 
> ファイルをデータベースのスーパーユーザーが psql で実行すると、これらの拡張機能が更新されます。

update\_extensions.sql ファイルが見つかりません。どこにありますか？

---

<div class="post-metadata">

### Author: ![Vaping\_Community](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vaping_community/32/89248_2.png) [@Vaping\_Community](https://meta.discourse.org/u/Vaping_Community)
#### Post date: [2025 年 2 月 8 日午後 6:42 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/116 "2025-02-08T18:42:40Z")

</div>

これを確認してください

```plaintext
mv: '/shared/postgres_data' を '/shared/postgres_data_old' に移動できません: デバイスまたはリソースがビジー状態です
mv: デバイス間の移動に失敗しました: '/shared/postgres_data_new' から '/shared/postgres_data/postgres_data_new' へ。ターゲットを削除できません: ディレクトリが空ではありません
I, [2025-02-08T15:22:42.078189 #1] INFO -- : ロケールの生成中 (しばらく時間がかかる場合があります)...

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2025 年 2 月 8 日午後 6:48 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/117 "2025-02-08T18:48:18Z")

</div>

> [@JimPas](#):
>
> 誰かが最初に頼むことなく、そのようなサービスを単に提供することは非常に珍しいでしょう。

それは私でした。解決が難しいと思われる状況にある人がいる場合、私は助けを提供します。

---

<div class="post-metadata">

### Author: ![fuse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fuse/32/221005_2.png) [@fuse](https://meta.discourse.org/u/fuse)
#### Post date: [2025 年 2 月 8 日午後 7:55 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/118 "2025-02-08T19:55:30Z")

</div>

好奇心からの質問です。

Postgresのような主要コンポーネントのアップグレードに関する標準や戦略はありますか？

Postgres 13のサポートは11/25までで、15は2027年まで続き、現在のバージョンは17です。

本当に学び、理解したいだけです。データベースのバージョンを変更することは、一般的に大きな問題であり、大変な作業です。

よろしくお願いします！

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2025 年 2 月 8 日午後 8:12 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/119 "2025-02-08T20:12:37Z")

</div>

私はPostgreSQL 10から使っています。通常は2つのリリースごとにアップグレードしますが、12から13に進んだのは、いくつかの改善があり早めに切り替える価値があったためです。彼らが16に進まなかったので少し驚きました。

通常、十分なディスクスペースと最新のDockerがあれば、かなりスムーズに進みます。

---

<div class="post-metadata">

### Author: ![Vaping\_Community](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vaping_community/32/89248_2.png) [@Vaping\_Community](https://meta.discourse.org/u/Vaping_Community)
#### Post date: [2025 年 2 月 9 日午後 12:25 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/120 "2025-02-09T12:25:51Z")

</div>

修正があるまで13テンプレートに戻しました。ありがとうございます。

---

<div class="post-metadata">

### Author: ![chrisc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisc/32/119982_2.png) [@chrisc](https://meta.discourse.org/u/chrisc)
#### Post date: [2025 年 2 月 9 日午後 3:56 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/121 "2025-02-09T15:56:53Z")

</div>

PostgreSQL 13 から 15 へのアップグレードに関する[問題](https://meta.discourse.org/t/postgresql-15-update/349515/109?u=chrisc)を解決しました。失敗したアップグレードをバックアップからサーバーに復元した後、PostgreSQL `en_GB.UTF-8` ロケールで以下の手順が機能しました。

```bash
sudo -i
su - discourse
cd /var/discourse
git stash
git stash drop
git pull
./launcher stop app
docker run --rm \
    --entrypoint=/bin/bash \
    -e LANG='en_GB.UTF-8' \
    -v /var/discourse/shared/standalone/postgres_data:/var/lib/postgresql/13/data \
    -v /var/discourse/shared/standalone/postgres_data_new:/var/lib/postgresql/15/data \
    tianon/postgres-upgrade:13-to-15 \
    -c 'sed -i "s/^# $LANG/$LANG/" /etc/locale.gen && locale-gen &&
    apt-get update && apt-get install -y postgresql-13-pgvector postgresql-15-pgvector &&
    docker-upgrade'
exit
mv /var/discourse/shared/standalone/postgres_data /var/discourse/shared/standalone/postgres_data_old
mv /var/discourse/shared/standalone/postgres_data_new /var/discourse/shared/standalone/postgres_data
chown -R 101:104 /var/discourse/shared/standalone/postgres_data
su - discourse
cd /var/discourse
docker run --rm -v /var/discourse/shared/standalone:/shared \
local_discourse/app chown -R postgres:postgres /shared/postgres_data
./launcher rebuild app

```

PostgreSQL の LANG に対する過去のローカル変更を `git stash; git stash drop` で削除する必要があり、PostgreSQL データディレクトリの移動は `root` として実行し、`chown` が必要でした。

---

<div class="post-metadata">

### Author: ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)
#### Post date: [2025 年 2 月 10 日午前 12:31 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/122 "2025-02-10T00:31:34Z")

</div>

> [@aas](#):
>
> ```plaintext
> cd /var/discourse
> git pull
> ./launcher rebuild app
> 
> ```

今回 `git pull` は必要ですか？ 通常は不要ですが。

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2025 年 2 月 10 日午前 6:33 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/123 "2025-02-10T06:33:14Z")

</div>

今日では、リビルドがそれを行うため、決して必要ありません。

---

<div class="post-metadata">

### Author: ![mwaniki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mwaniki/32/313097_2.png) [@mwaniki](https://meta.discourse.org/u/mwaniki)
#### Post date: [2025 年 2 月 10 日午後 2:18 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/124 "2025-02-10T14:18:07Z")

</div>

> [@Vaping\_Community](#):
>
> ```plaintext
> mv: '/shared/postgres_data' を '/shared/postgres_data_old' に移動できません: デバイスまたはリソースがビジー状態です
> mv: デバイス間移動に失敗しました: '/shared/postgres_data_new' から '/shared/postgres_data/postgres_data_new' へ。ターゲットを削除できません: ディレクトリが空ではありません
> 
> ```

最初のエラーからの末尾のメッセージ `Device or resource busy` は、他の何かがその `postgres_data` ディレクトリのロックを保持しているため、移動できないことを示唆しています。

それがデータベースディレクトリであるため、`postgres_data` がマウントポイントである可能性が高いです。2番目の `mv` コマンドで `inter-device move failed` が表示され、`shared/postgres_data_new` と `shared/postgres_data` が異なるディスク/パーティション上にあることを示唆しているため、これはさらに可能性が高くなります。

`postgres_data` がマウントポイントであることを確認した場合は、手動で `postgres_data` 内のすべてのファイルを別のバックアップディレクトリに移動し、その後、`postgres_data_new` 内のすべてのファイルを（空になった）`postgres_data` ディレクトリに移動する必要があります。両方の移動は、最初の再構築が `UPGRADE OF POSTGRES COMPLETE` で完了した後、2番目の再構築を発行する前に行う必要があります。

`postgres_data` がマウントポイントでない場合は、[`lsof`](https://man7.org/linux/man-pages/man8/lsof.8.html) が役に立ちます。それを使用して、ロックの原因を特定してみてください。

もちろん、最初に必要なバックアップを取ってください。

---

<div class="post-metadata">

### Author: ![Vaping\_Community](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vaping_community/32/89248_2.png) [@Vaping\_Community](https://meta.discourse.org/u/Vaping_Community)
#### Post date: [2025 年 2 月 12 日午前 10:37 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/125 "2025-02-12T10:37:23Z")

</div>

完璧です、ありがとうございます。

> [@mwaniki](#):
>
> どちらの操作も、`UPGRADE OF POSTGRES COMPLETE` で最初の再構築が完了した後、2番目の操作を発行する前に行う必要があります。

ファイルは次のフォルダにありました。

`/var/postgres_data_discourse` （`postgres_data_new` として）

以下の手順で解決しました。

`postgres_data_new` を `/var` に移動しました。  
`postgres_data_discourse` を `postgres_data_discourse_old` にリネームしました。  
`postgres_data_new` を `postgres_data_discourse` にリネームしました。  
`./launcher rebuild app` を発行しました。

改めてありがとうございました 👍

---

<div class="post-metadata">

### Author: ![Saiano](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiano/32/153394_2.png) [@Saiano](https://meta.discourse.org/u/Saiano)
#### Post date: [2025 年 2 月 15 日午後 4:26 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/126 "2025-02-15T16:26:17Z")

</div>

62gのdbがあります。最高のアップグレードを実行するために何をお勧めしますか？

62G /var/discourse/shared/standalone/postgres\_data

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2025 年 2 月 15 日午後 5:08 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/127 "2025-02-15T17:08:15Z")

</div>

新しいVMに移行し、新しいDiscourseを起動し、データベースを空にして（ゼロダウンタイムの切り替えをご希望の場合は、sslとletsencryptのディレクトリをコピーしてください）、現在のデータベースを新しいサーバーに復元することを推奨します。これにより、ゼロダウンタイムでアップグレードを実行でき、問題が発生するリスクもゼロになります。

いずれにしても、OSのアップグレードもそろそろ時期かもしれません。

---

<div class="post-metadata">

### Author: ![Saiano](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiano/32/153394_2.png) [@Saiano](https://meta.discourse.org/u/Saiano)
#### Post date: [2025 年 2 月 15 日午後 5:15 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/128 "2025-02-15T17:15:08Z")

</div>

> [@pfaffman](#):
>
> 新しいVMに移動し、新しいDiscourseを起動し、データベースを空にします（ゼロダウンタイムの切り替えをご希望の場合は、sslおよびletsencryptディレクトリをコピーします）。現在のデータベースを新しいサーバーに復元します。これにより、ゼロダウンタイムでアップグレードを実行でき、問題が発生するリスクもゼロになります。
> 
> OSのアップグレードもそろそろ時期かもしれません。

それは良い考えですね。

### 3.4.0.beta4-dev バックアップを ### 最新バージョンの新規インストールに移動できますか？

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2025 年 2 月 15 日午後 5:18 UTC](https://meta.discourse.org/t/postgresql-15-update/349515/129 "2025-02-15T17:18:21Z")

</div>

古いバージョンのDiscourseを新しいバージョンに復元できるかどうか尋ねているのであれば、その答えはイエスです。

[Previous page](https://meta.discourse.org/t/postgresql-15-update/349515.md?page=3)

[Next page](https://meta.discourse.org/t/postgresql-15-update/349515.md?page=5)
