0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PostgreSQL のバージョンの違いを解消

Posted at

RDS のバージョンと設定した PostgreSQL のバージョンが違っていたため、解消しました。
自分の設定ミスで起こったことなので、あまり皆さんに転用できないとは思いますが、解消まで苦労したので、よかったら見ていってください。

参考資料

では、下記より内容に入ります。

RDS に接続した際にバージョンの違いに気づく

psql (9.2.24, サーバー 12.4)
注意: psql バージョン 9.2, サーバーバージョン 12.0.
         psql の機能の中で、動作しないものがあるかもしれません。
SSL 接続 (暗号化方式: ECDHE-RSA-AES256-GCM-SHA384, ビット長: 256)
"help" でヘルプを表示します.

手違いで違うバージョンをインストールしてしまっていたようなので、解消する。

【PostgreSQL】psql version 8.4, server version 9.5

[〇〇@ip-10-0-0-87 ~]$ su postgres
パスワード:
bash-4.2$ find / -name psql 2>/dev/null
/usr/bin/psql
/usr/pgsql-12/bin/psql
bash-4.2$ mv /usr/bin/psql /usr/bin/psql.old
mv: `/usr/bin/psql' から `/usr/bin/psql.old' へ移動できません: Permission denied

mv コマンド実行できないエラー

Permission dinied

Linuxの権限確認と変更(chmod)(超初心者向け) - Qiita

bash-4.2$ ls -al /usr/bin/psql
-rwxr-xr-x 1 root root 445160  9月  7  2018 /usr/bin/psql

権限ない?以下コマンド実施

bash-4.2$ chmod 777 /usr/bin/psql
chmod: `/usr/bin/psql' のパーミッションを変更しています: Operation not permitted

sudo コマンドで強制変更

-bash-4.2$ sudo chmod 777 /usr/bin/psql
[sudo] password for postgres:
postgres is not in the sudoers file.  This incident will be reported.

postgres is not in the sudoers file.

なんやねんコレ。。。。

sudoers ファイルについて

調べてみると sudo コマンドを使うためのユーザー設定が必要らしい。

【CeontOS】「sudoers ファイル内にありません。この事象は記録・報告されます」というメッセージが出た時の対処

[〇〇@ip-10-0-0-87 ~]$ sudo visudo
## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL
postgres ALL=(ALL)      ALL  ## ここ追加

設定したら再度ログイン

[kouhei@ip-10-0-0-87 ~]$ su - postgres

-bash-4.2$ sudo mv /usr/bin/psql /usr/bin/psql.old

-bash-4.2$ sudo ln -s /usr/pgsql-12/bin/psql /usr/bin/psql

上記コマンド打ってエラーが出なかったので、一旦ログアウト

RDS の方に入ってみる。

psql (12.5、サーバ 12.4)
SSL 接続 (プロトコル: TLSv1.2、暗号化方式: ECDHE-RSA-AES256-GCM-SHA384、ビット長: 256、圧縮: オフ)
"help"でヘルプを表示します。

できた!

学んだこと

  • 意味の分かっていないコマンドは打たない方が良い。

公式サイトや様々な記事を参考にしながら環境構築行っていましたが、途中から完全に迷子になってしまい、よくわからないままあれやこれやとコマンド打っていました。

こちらのエラーを解消していく中で、自分が何を設定したのか位置関係がなんとなく理解できました。

当たり前の話ですが、環境構築やってると自分が今どこにいて何をやってるのか把握しておくことが大事だと改めて思いました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?