LoginSignup
36
30

More than 5 years have passed since last update.

AmazonLinuxにPostgreSQL9.6をインストールする

Last updated at Posted at 2016-06-12

目的

  • AmazonLinuxの標準yumリポジトリには、PostgreSQL9.5までしか登録されていません。(2017.1時点)
  • 9.6をインストールして試したいこともありますよね。(またはtestバージョンの10系?)

概要

手順

yumリポジトリURLを確認

  • 今回はAmazonLinuxにPostgreSQL9.6をインストールするので、このページから、「PostgreSQL 9.6」→「Amazon Linux AMI 2015.03 - x86_64」のリンク先を確認。
  • 今日時点ではhttps://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpmでした。

yumリポジトリをインストール

  • 下記コマンド実行
$ sudo yum localinstall -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm
  • 何がインストールされたか見ておく
$ rpm -ql pgdg-ami201503-96-9.6-2.noarch
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96
/etc/yum.repos.d/pgdg-96-ami201503.repo

PostgreSQLをインストール

  • あとは通常どおり
$ sudo yum install -y postgresql96 postgresql96-server postgresql96-libs postgresql96-contrib

PostgreSQL初期化と開始

$ sudo /etc/init.d/postgresql96 initdb
$ sudo /etc/init.d/postgresql96 start
  • いつも使いたい人は自動起動
$ sudo chkconfig postgresql96 on

接続確認

$ sudo -u postgres -i psql -c 'SELECT version();'
                                                   version
--------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.6.6 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11), 64-bit
(1 row)
  • デフォルトのデータディレクトリは /var/lib/pgsql96/data でした。
  • ※2017.12.12現在
36
30
1

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
36
30