LoginSignup
0
0

More than 1 year has passed since last update.

FATAL: unrecognized configuration parameter "unix_socket_directory" が出力されてpg_upgradeが実行出来なかった

Posted at

調べても英語の記事しか引っかからなかったので、この手の記事はいくつあっても困らないだろうと思い書く。
調べ方が悪かったのかもしれない。

環境情報

  • OS : Red Hat 7.9
  • PostgreSQL : 9.2 から 14.x に上げる

結論

以下のコマンドを pg_upgrade を行う前にrootユーザで発行すれば解消できる。

# rootユーザで実行
mv /usr/bin/pg_ctl{,-orig}
echo '#!/bin/bash' > /usr/bin/pg_ctl
echo '"$0"-orig "${@/unix_socket_directory/unix_socket_directories}"' >> /usr/bin/pg_ctl
chmod +x /usr/bin/pg_ctl

# アップグレードコマンドの実行
sudo -u postgres /usr/pgsql-14/bin/pg_upgrade ...

# 変更したコマンドを元に戻す
mv -f /usr/bin/pg_ctl{-orig,}

※こちらのAnswerを使用しました。回答者に感謝
pg_upgrade unrecognized configuration parameter "unix_socket_directory" | stackexchange.com

経緯

RedHatのリポジトリからインストール出来る 9.2 から最新の 14 へDBをアップグレードする必要があった。
公式の手順に倣い pg_upgrade コマンドを使用してアップグレードを行ったところ以下のエラーに遭遇。

# sudo -u postgres /usr/pgsql-14/bin/pg_upgrade -d /var/lib/pgsql/data -D /var/lib/pgsql/14/data -b /usr/bin -B /usr/pgsql-14/bin
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 server on socket "/var/lib/pgsql/.s.PGSQL.50432" failed: No such file or directory
        Is the server running locally and accepting connections on that socket?

could not connect to source postmaster started with the command:
"/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/data" -o "-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/var/lib/pgsql'" start
Failure, exiting

Is the server running locally ... はDBが既に立ち上がっている場合などでよく見るエラーだが、今回はアップグレードの為にDBをストップさせている。
下段のエラーを見ると pg_upgrade 内部で発行している pg_ctl コマンドが失敗しているらしい。

pg_upgrade_server.logに出力されたエラーは以下の通り

command: "/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/data" -o "-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/var/lib/pgsql'" start >> "pg_upgrade_server.log" 2>&1
waiting for server to start....FATAL:  unrecognized configuration parameter "unix_socket_directory"
 stopped waiting
pg_ctl: could not start server
Examine the log output.

原因は、PostgreSQL 9.2 から 9.3 へのアップデートで、内部で使用するパラメータ unix_socket_directoryunix_socket_directories (末尾が複数形) に変更された影響。
新しいクラスタ内で pg_upgrade を実行したが、内部では古いクラスタの pg_ctl が実行され、古いパラメータの unix_socket_directory を参照しようとしたが、新しいクラスタ内なので無いというエラーらしい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0