Amazon RDSで構築したPostgreSQLへの「 psql 」を用いた接続方法について記載しています。
環境
1.リポジトリを追加します。
次のコマンドを実行します。
yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm
実行結果
読み込んだプラグイン:priorities, update-motd, upgrade-helper
pgdg-ami201503-96-9.6-2.noarch.rpm | 4.6 kB 00:00
/var/tmp/yum-root-6FVnUE/pgdg-ami201503-96-9.6-2.noarch.rpm を調べています: pgdg-ami201503-96-9.6-2.noarch
/var/tmp/yum-root-6FVnUE/pgdg-ami201503-96-9.6-2.noarch.rpm をインストール済みとして設定しています
依存性の解決をしています
amzn-main/latest | 2.1 kB 00:00
amzn-updates/latest | 2.5 kB 00:00
--> トランザクションの確認を実行しています。
---> パッケージ pgdg-ami201503-96.noarch 0:9.6-2 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
================================================================================
Package アーキテクチャー
バージョン
リポジトリー 容量
================================================================================
インストール中:
pgdg-ami201503-96 noarch 9.6-2 /pgdg-ami201503-96-9.6-2.noarch 2.2 k
トランザクションの要約
================================================================================
インストール 1 パッケージ
合計容量: 2.2 k
インストール容量: 2.2 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : pgdg-ami201503-96-9.6-2.noarch 1/1
検証中 : pgdg-ami201503-96-9.6-2.noarch 1/1
インストール:
pgdg-ami201503-96.noarch 0:9.6-2
完了しました!
2.postgresqlのインストールします。
次のコマンドを実行します。
yum install -y postgresql96
実行結果
読み込んだプラグイン:priorities, update-motd, upgrade-helper
23 packages excluded due to repository priority protections
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ postgresql96.x86_64 0:9.6.4-1.77.amzn1 を インストール
--> 依存性の処理をしています: postgresql96-libs(x86-64) = 9.6.4-1.77.amzn1 のパ ッケージ: postgresql96-9.6.4-1.77.amzn1.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ postgresql96-libs.x86_64 0:9.6.4-1.77.amzn1 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
================================================================================
Package アーキテクチャー
バージョン リポジトリー 容量
================================================================================
インストール中:
postgresql96 x86_64 9.6.4-1.77.amzn1 amzn-updates 5.0 M
依存性関連でのインストールをします:
postgresql96-libs x86_64 9.6.4-1.77.amzn1 amzn-updates 283 k
トランザクションの要約
================================================================================
インストール 1 パッケージ (+1 個の依存関係のパッケージ)
総ダウンロード容量: 5.2 M
インストール容量: 20 M
Downloading packages:
(1/2): postgresql96-libs-9.6.4-1.77.amzn1.x86_64.rpm | 283 kB 00:00
(2/2): postgresql96-9.6.4-1.77.amzn1.x86_64.rpm | 5.0 MB 00:00
--------------------------------------------------------------------------------
合計 6.6 MB/s | 5.2 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
インストール中 : postgresql96-libs-9.6.4-1.77.amzn1.x86_64 1/2
インストール中 : postgresql96-9.6.4-1.77.amzn1.x86_64 2/2
検証中 : postgresql96-9.6.4-1.77.amzn1.x86_64 1/2
検証中 : postgresql96-libs-9.6.4-1.77.amzn1.x86_64 2/2
インストール:
postgresql96.x86_64 0:9.6.4-1.77.amzn1
依存性関連をインストールしました:
postgresql96-libs.x86_64 0:9.6.4-1.77.amzn1
完了しました!
3.接続を確認します。 ※[ ]は不要です。
次のコマンドを実行します。
psql -U[MASTER USER] -h[ENDPOINT] [DATABASE NAME]
実行結果
[DATABASE NAME]=>