PostgreSQL Version12 インストール手順 (RHEL系Linux)¶
警告
dnf module install postgresql:12/server を使用してください。MaxGaugeサーバがサポートするLinux OS(RHEL, CentOS、OracleLinux)へのPostgreSQL Version12のインストール手順を紹介します。 手順は、PostgreSQLの公式YUMリポジトリよりインストールする手順とRPMファイルをダウンロードしてインストールする手順を紹介します、 MaxGaugeサーバの環境にあわせてインストールしてください。
※ MaxGaugeのユーティリティツールで利用するPython用のPostgreSQLドライバもインストールします
OS |
インストール |
|---|---|
RHEL6(CentOS6,OracleLinux6) |
|
RHEL7(CentOS7,OracleLinux7) |
|
RHEL8(CentOS8,OracleLinux8) |
|
PostgreSQLの公式リポジトリよりインストール¶
PostgreSQLの公式リポジトリよりインストールします。MaxGaugeサーバがインターネットにアクセス出来る必要があります。
リポジトリ情報のRPMファイルをインストールします
[root]# rpm -ivh https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
インストール
[root]# dnf --disablerepo=* --enablerepo=pgdg12 install \ postgresql12 \ postgresql12-server \ postgresql12-libs
データベースの初期化
[root]# postgresql-12-setup initdb
PostgreSQLサービスの起動
[root]# systemctl start postgresql-12.service
Python3のPostgreSQLドライバをインストール
[root]# yum install --disablerepo=* --enablerepo=pgdg12 python3-psycopg2
リポジトリ情報のRPMファイルをインストールします
[root]# rpm -ivh https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
インストール
[root]# yum --disablerepo=* --enablerepo=pgdg12 install \ postgresql12 \ postgresql12-server \ postgresql12-libs
データベースの初期化
[root]# postgresql-12-setup initdb
PostgreSQLサービスの起動
[root]# systemctl start postgresql-12.service
PythonのPostgreSQLドライバをインストール
[root]# yum install --disablerepo=* --enablerepo=pgdg12 python-psycopg2
リポジトリ情報のRPMファイルをインストールします
[root]# rpm -ivh https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm
インストール
[root]# yum --disablerepo=* --enablerepo=pgdg12 install \ postgresql12 \ postgresql12-server \ postgresql12-libs
データベースの初期化
[root]# /etc/init.d/postgresql-12 initdb
PostgreSQLサービスの起動
[root]# service postgresql-12 start
PythonのPostgreSQLドライバをインストール
[root]# yum install --disablerepo=* --enablerepo=pgdg12 python-psycopg2
PostgreSQLのRPMをダウンロードしてインストール¶
YUMリポジトリのURLよりRPMをダウンロードする
URL : https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-8-x86_64/
- ダウンロードするRPM
postgresql12-12.*-*PGDG.rhel8.x86_64.rpmpostgresql12-server-12.*-*PGDG.rhel8.x86_64.rpmpostgresql12-libs-12.*-*PGDG.rhel8.x86_64.rpm
- ダウンロードするRPM(PostgreSQLドライバ)
python3-psycopg2-2.8.*-*.rhel8.x86_64
ダウンロードしたRPMをMaxGaugeサーバへアップロードします
アップロードしたRPMをインストールします
[root]# rpm -ivh ./postgresql12-12.*-*PGDG.rhel8.x86_64.rpm \ ./postgresql12-server-12.*-*PGDG.rhel8.x86_64.rpm \ ./postgresql12-libs-12.*-*PGDG.rhel8.x86_64.rpm
データベースの初期化
[root]# postgresql-12-setup initdb
PostgreSQLサービスの起動
[root]# systemctl start postgresql-12.service
PythonのPostgreSQLドライバをインストール
[root]# rpm -ivh ./python3-psycopg2-2.8.*-*.rhel8.x86_64
YUMリポジトリのURLよりRPMをダウンロードする
URL : https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64/
- ダウンロードするRPM
postgresql12-12.*-*PGDG.rhel7.x86_64.rpmpostgresql12-server-12.*-*PGDG.rhel7.x86_64.rpmpostgresql12-libs-12.*-*PGDG.rhel7.x86_64.rpm
- ダウンロードするRPM(PostgreSQLドライバ)
python-psycopg2-2.7.*-*.rhel7.x86_64
ダウンロードしたRPMをMaxGaugeサーバへアップロードします
アップロードしたRPMをインストールします
[root]# rpm -ivh ./postgresql12-12.*-*PGDG.rhel7.x86_64.rpm \ ./postgresql12-server-12.*-*PGDG.rhel7.x86_64.rpm \ ./postgresql12-libs-12.*-*PGDG.rhel7.x86_64.rpm
データベースの初期化
[root]# postgresql-12-setup initdb
PostgreSQLサービスの起動
[root]# systemctl start postgresql-12.service
PythonのPostgreSQLドライバをインストール
[root]# rpm -ivh ./python-psycopg2-2.7.*-*.rhel7.x86_64
YUMリポジトリのURLよりRPMをダウンロードする
URL : https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-6-x86_64/
- ダウンロードするRPM
postgresql12-12.*-*PGDG.rhel6.x86_64.rpmpostgresql12-server-12.*-*PGDG.rhel6.x86_64.rpmpostgresql12-libs-12.*-*PGDG.rhel6.x86_64.rpm
- ダウンロードするRPM(PostgreSQLドライバ)
python-psycopg2-2.7.*-*.rhel6.x86_64
ダウンロードしたRPMをMaxGaugeサーバへアップロードします
アップロードしたRPMをインストールします
[root]# rpm -ivh ./postgresql12-12.*-*PGDG.rhel6.x86_64.rpm \ ./postgresql12-server-12.*-*PGDG.rhel6.x86_64.rpm \ ./postgresql12-libs-12.*-*PGDG.rhel6.x86_64.rpm
データベースの初期化
[root]# postgresql-12-setup initdb
PostgreSQLサービスの起動
[root]# service postgresql-12 start
PythonのPostgreSQLドライバをインストール
[root]# rpm -ivh ./python-psycopg2-2.7.*-*.rhel6.x86_64
[RHEL8] AppStream よりインストール¶
ヒント
この手順は、RHEL8系の環境のみ対象となります
Postgres10のインストール
[root]# dnf module install postgresql:12
データベースの初期化
[root]# postgresql-setup initdb
PostgreSQLサービスの起動
[root]# systemctl start postgresql.service
PythonのPostgreSQLドライバをインストール
[root]# dnf install python3-psycopg2