PostgreSQL Version9.6 インストール手順 (RHEL系Linux)

MaxGaugeサーバがサポートするLinux OS(RHEL, CentOS、OracleLinux)へのPostgreSQL Version9.6のインストール手順を紹介します。 手順は、PostgreSQLの公式YUMリポジトリよりインストールする手順とRPMファイルをダウンロードしてインストールする手順を紹介します、 MaxGaugeサーバの環境にあわせてインストールしてください。

※ MaxGaugeのユーティリティツールで利用するPython用のPostgreSQLドライバもインストールします

OS別インストール手順

OS

インストール

RHEL6(CentOS6,OracleLinux6)

  • PostgreSQL公式リポジトリよりインストール

  • PostgreSQLのRPMをダウンロードしてインストール

RHEL7(CentOS7,OracleLinux7)

  • PostgreSQL公式リポジトリよりインストール

  • PostgreSQLのRPMをダウンロードしてインストール

RHEL8(CentOS8,OracleLinux8)

  • PostgreSQL公式リポジトリよりインストール

  • PostgreSQLのRPMをダウンロードしてインストール

  • ディストリビューションに付属するPostgreSQL-9.6をAppStreaからインストール

PostgreSQLの公式リポジトリよりインストール

PostgreSQLの公式リポジトリよりインストールします。MaxGaugeサーバがインターネットにアクセス出来る必要があります。

RHEL8

  1. リポジトリ情報のRPMファイルをインストールします

    rpm -ivh https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    
  2. インストール

    dnf --disablerepo=* --enablerepo=pgdg96 install \
     postgresql96 \
     postgresql96-server \
     postgresql96-libs
    
  3. データベースの初期化

    postgresql-9.6-setup initdb
    
  4. PostgreSQLサービスの起動

    systemctl start postgresql-9.6.service
    
  5. Python3のPostgreSQLドライバをインストール

    yum install --disablerepo=* --enablerepo=pgdg96 python3-psycopg2
    

RHEL7

  1. リポジトリ情報のRPMファイルをインストールします

    rpm -ivh https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    
  2. インストール

    yum --disablerepo=* --enablerepo=pgdg96 install \
     postgresql96 \
     postgresql96-server \
     postgresql96-libs
    
  3. データベースの初期化

    postgresql-9.6-setup initdb
    
  4. PostgreSQLサービスの起動

    systemctl start postgresql-9.6.service
    
  5. PythonのPostgreSQLドライバをインストール

    yum install --disablerepo=* --enablerepo=pgdg96 python-psycopg2
    

RHEL6

  1. リポジトリ情報のRPMファイルをインストールします

    rpm -ivh https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    
  2. インストール

    yum --disablerepo=* --enablerepo=pgdg96 install \
     postgresql96 \
     postgresql96-server \
     postgresql96-libs
    
  3. データベースの初期化

    /etc/init.d/postgresql-9.6 initdb
    
  4. PostgreSQLサービスの起動

    service postgresql-9.6 start
    
  5. PythonのPostgreSQLドライバをインストール

    yum install --disablerepo=* --enablerepo=pgdg96 python-psycopg2
    

PostgreSQLのRPMをダウンロードしてインストール

RHEL8

  1. YUMリポジトリのURLよりRPMをダウンロードする

    URL : https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-8-x86_64/

    • ダウンロードするRPM

      • postgresql96-9.6.*-*PGDG.rhel8.x86_64.rpm

      • postgresql96-server-9.6.*-*PGDG.rhel8.x86_64.rpm

      • postgresql96-libs-9.6.*-*PGDG.rhel8.x86_64

    • ダウンロードするRPM(PostgreSQLドライバ)

      • python3-psycopg2-2.8.*-*.rhel8.x86_64

  2. ダウンロードしたRPMをMaxGaugeサーバへアップロードします

  3. アップロードしたRPMをインストールします

    rpm -ivh ./postgresql96-9.6.*-*PGDG.rhel8.x86_64.rpm  \
     ./postgresql96-server-9.6.*-*PGDG.rhel8.x86_64.rpm  \
     ./postgresql96-libs-9.6.*-*PGDG.rhel8.x86_64
    
  4. データベースの初期化

    postgresql-9.6-setup initdb
    
  5. PostgreSQLサービスの起動

    systemctl start postgresql-9.6.service
    
  6. PythonのPostgreSQLドライバをインストール

    rpm -ivh ./python3-psycopg2-2.8.*-*.rhel8.x86_64
    

RHEL7

  1. YUMリポジトリのURLよりRPMをダウンロードする

    URL : https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/

    • ダウンロードするRPM

      • postgresql96-9.6.**-*PGDG.rhel7.x86_64.rpm

      • postgresql96-server-9.6.**-*PGDG.rhel7.x86_64.rpm

      • postgresql96-libs-9.6.**-*PGDG.rhel7.x86_64.rpm

    • ダウンロードするRPM(PostgreSQLドライバ)

      • python-psycopg2-2.7.*-*.rhel7.x86_64

  2. ダウンロードしたRPMをMaxGaugeサーバへアップロードします

  3. アップロードしたRPMをインストールします

    rpm -ivh ./postgresql96-9.6.**-*PGDG.rhel7.x86_64.rpm  \
     ./postgresql96-server-9.6.**-*PGDG.rhel7.x86_64.rpm  \
     ./postgresql96-libs-9.6.**-*PGDG.rhel7.x86_64.rpm
    
  4. データベースの初期化

    postgresql-9.6-setup initdb
    
  5. PostgreSQLサービスの起動

    systemctl start postgresql-9.6.service
    
  6. PythonのPostgreSQLドライバをインストール

    rpm -ivh ./python-psycopg2-2.7.*-*.rhel7.x86_64
    

RHEL6

  1. YUMリポジトリのURLよりRPMをダウンロードする

    URL : https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/

    • ダウンロードするRPM

      • postgresql96-9.6.**-*PGDG.rhel6.x86_64.rpm

      • postgresql96-server-9.6.**-*PGDG.rhel6.x86_64.rpm

      • postgresql96-libs-9.6.**-*PGDG.rhel6.x86_64.rpm

    • ダウンロードするRPM(PostgreSQLドライバ)

      • python-psycopg2-2.7.*-*.rhel6.x86_64

  2. ダウンロードしたRPMをMaxGaugeサーバへアップロードします

  3. アップロードしたRPMをインストールします

    rpm -ivh ./postgresql96-9.6.**-*PGDG.rhel6.x86_64.rpm  \
    ./postgresql96-server-9.6.**-*PGDG.rhel6.x86_64.rpm  \
    ./postgresql96-libs-9.6.**-*PGDG.rhel6.x86_64.rpm
    
  4. データベースの初期化

    /etc/init.d/postgresql-9.6 initdb
    
  5. PostgreSQLサービスの起動

    service postgresql-9.6 start
    
  6. PythonのPostgreSQLドライバをインストール

    rpm -ivh ./python-psycopg2-2.7.*-*.rhel6.x86_64
    

[RHEL8] AppStream よりインストール

ヒント

この手順は、RHEL8系の環境のみ対象となります

RHEL8:手順

  1. Postgres9.6のインストール

    dnf module install postgresql:9.6
    
  2. データベースの初期化

    postgresql-setup initdb
    
  3. PostgreSQLサービスの起動

    systemctl start postgresql.service
    
  4. PythonのPostgreSQLドライバをインストール

    dnf install python3-psycopg2