PostgreSQL 11.2(RPM)

提供:あべたけの覚書
2023年5月11日 (木) 09:18時点におけるT.Abe (トーク | 投稿記録)による版 (ページの作成:「==インストール== ==='''本家のリポジトリを追加する'''=== <syntaxhighlight lang="bash"> [root@XXXXX ~]# su - rpmdevel [rpmdevel@XXXXX ~]$ cd /home/rpmdevel/src [rpmdevel@XXXXX ~]$ wget https://yum.postgresql.org/11/redhat/rhel-6-i386/pgdg-centos11-11-2.noarch.rpm [rpmdevel@XXXXX ~]$ sudo rpm -ivh /home/rpmdevel/src/pgdg-centos11-11-2.noarch.rpm 警告: /home/rpmdevel/src/pgdg-centos11-11-2.noarch.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID *…」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

インストール

本家のリポジトリを追加する

 [root@XXXXX ~]# su - rpmdevel
 [rpmdevel@XXXXX ~]$ cd /home/rpmdevel/src
 [rpmdevel@XXXXX ~]$ wget https://yum.postgresql.org/11/redhat/rhel-6-i386/pgdg-centos11-11-2.noarch.rpm
 
 [rpmdevel@XXXXX ~]$ sudo rpm -ivh /home/rpmdevel/src/pgdg-centos11-11-2.noarch.rpm
 警告: /home/rpmdevel/src/pgdg-centos11-11-2.noarch.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID ********: NOKEY
 準備中...                   ########################################### [100%]
    1:pgdg-centos11          ########################################### [100%]


リポジトリの確認

 [root@XXXXX ~]# yum list | grep postgresql
 
 postgresql11.i686                          11.2-2PGDG.rhel6            @pgdg11
 postgresql11-devel.i686                    11.2-2PGDG.rhel6            @pgdg11
 postgresql11-libs.i686                     11.2-2PGDG.rhel6            @pgdg11
 postgresql11-server.i686                   11.2-2PGDG.rhel6            @pgdg11
 bacula-director-postgresql.i686            5.0.0-13.el6                base
 bacula-storage-postgresql.i686             5.0.0-13.el6                base
 freeradius-postgresql.i686                 2.2.6-7.el6_9               base
 pcp-pmda-postgresql.i686                   3.10.9-9.el6                base
 postgresql.i686                            8.4.20-8.el6_9              base
 postgresql-contrib.i686                    8.4.20-8.el6_9              base
 postgresql-devel.i686                      8.4.20-8.el6_9              base
 postgresql-docs.i686                       8.4.20-8.el6_9              base
 postgresql-jdbc.noarch                     42.2.5-1.rhel6.1            pgdg11
 postgresql-jdbc-javadoc.noarch             42.2.5-1.rhel6.1            pgdg11
 postgresql-libs.i686                       8.4.20-8.el6_9              base
 postgresql-odbc.i686                       08.04.0200-1.el6            base
 postgresql-plperl.i686                     8.4.20-8.el6_9              base
 postgresql-plpython.i686                   8.4.20-8.el6_9              base
 postgresql-pltcl.i686                      8.4.20-8.el6_9              base
 postgresql-server.i686                     8.4.20-8.el6_9              base
 postgresql-test.i686                       8.4.20-8.el6_9              base
 postgresql-unit94.i686                     2.0-1.rhel6                 pgdg94
 postgresql-unit94-debuginfo.i686           2.0-1.rhel6                 pgdg94
 postgresql-unit96.i686                     2.0-1.rhel6                 pgdg96
 postgresql-unit96-debuginfo.i686           2.0-1.rhel6                 pgdg96
 postgresql10.i686                          10.7-2PGDG.rhel6            pgdg10
 postgresql10-contrib.i686                  10.7-2PGDG.rhel6            pgdg10
 postgresql10-debuginfo.i686                10.7-2PGDG.rhel6            pgdg10
 postgresql10-devel.i686                    10.7-2PGDG.rhel6            pgdg10
 postgresql10-docs.i686                     10.7-2PGDG.rhel6            pgdg10
 postgresql10-libs.i686                     10.7-2PGDG.rhel6            pgdg10
 postgresql10-odbc.i686                     11.00.0000-1PGDG.rhel6      pgdg10
 postgresql10-plperl.i686                   10.7-2PGDG.rhel6            pgdg10
 postgresql10-plpython.i686                 10.7-2PGDG.rhel6            pgdg10
 postgresql10-pltcl.i686                    10.7-2PGDG.rhel6            pgdg10
 postgresql10-server.i686                   10.7-2PGDG.rhel6            pgdg10
 postgresql10-tcl.i686                      2.4.0-1.rhel6               pgdg10
 postgresql10-tcl-debuginfo.i686            2.3.1-1.rhel6               pgdg10
 postgresql10-test.i686                     10.7-2PGDG.rhel6            pgdg10
 postgresql11-contrib.i686                  11.2-2PGDG.rhel6            pgdg11
 postgresql11-debuginfo.i686                11.2-2PGDG.rhel6            pgdg11
 postgresql11-docs.i686                     11.2-2PGDG.rhel6            pgdg11
 postgresql11-odbc.i686                     11.00.0000-1PGDG.rhel6      pgdg11
 postgresql11-plperl.i686                   11.2-2PGDG.rhel6            pgdg11
 postgresql11-plpython.i686                 11.2-2PGDG.rhel6            pgdg11
 postgresql11-pltcl.i686                    11.2-2PGDG.rhel6            pgdg11
 postgresql11-tcl.i686                      2.4.0-2.rhel6.1             pgdg11
 postgresql11-test.i686                     11.2-2PGDG.rhel6            pgdg11
 postgresql94.i686                          9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-contrib.i686                  9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-debuginfo.i686                9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-devel.i686                    9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-docs.i686                     9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-jdbc.i686                     9.3.1101-1PGDG.rhel6        pgdg94
 postgresql94-jdbc.noarch                   9.4.1207-1.rhel6            pgdg95
 postgresql94-jdbc-debuginfo.i686           9.3.1101-1PGDG.rhel6        pgdg94
 postgresql94-jdbc-javadoc.noarch           9.4.1207-1.rhel6            pgdg95
 postgresql94-libs.i686                     9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-odbc.i686                     11.00.0000-1PGDG.rhel6      pgdg94
 postgresql94-odbc-debuginfo.i686           09.03.0400-1PGDG.rhel6      pgdg94
 postgresql94-plperl.i686                   9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-plpython.i686                 9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-pltcl.i686                    9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-server.i686                   9.4.21-1PGDG.rhel6          pgdg94
 postgresql94-tcl.i686                      2.4.0-1.rhel6               pgdg94
 postgresql94-tcl-debuginfo.i686            2.3.1-1.rhel6               pgdg94
 postgresql94-test.i686                     9.4.21-1PGDG.rhel6          pgdg94
 postgresql95.i686                          9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-contrib.i686                  9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-debuginfo.i686                9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-devel.i686                    9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-docs.i686                     9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-libs.i686                     9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-odbc.i686                     11.00.0000-1PGDG.rhel6      pgdg95
 postgresql95-odbc-debuginfo.i686           09.03.0400-1PGDG.rhel6      pgdg95
 postgresql95-plperl.i686                   9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-plpython.i686                 9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-pltcl.i686                    9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-server.i686                   9.5.16-1PGDG.rhel6          pgdg95
 postgresql95-tcl.i686                      2.4.0-1.rhel6               pgdg95
 postgresql95-tcl-debuginfo.i686            2.3.1-1.rhel6               pgdg95
 postgresql95-test.i686                     9.5.16-1PGDG.rhel6          pgdg95
 postgresql96.i686                          9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-contrib.i686                  9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-debuginfo.i686                9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-devel.i686                    9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-docs.i686                     9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-libs.i686                     9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-odbc.i686                     11.00.0000-1PGDG.rhel6      pgdg96
 postgresql96-plperl.i686                   9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-plpython.i686                 9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-pltcl.i686                    9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-server.i686                   9.6.12-1PGDG.rhel6          pgdg96
 postgresql96-tcl.i686                      2.4.0-1.rhel6               pgdg96
 postgresql96-tcl-debuginfo.i686            2.3.1-1.rhel6               pgdg96
 postgresql96-test.i686                     9.6.12-1PGDG.rhel6          pgdg96
 postgresql_anonymizer10.noarch             0.2.1-1.rhel6               pgdg10
 postgresql_anonymizer11.noarch             0.2.1-1.rhel6               pgdg11
 postgresql_anonymizer95.noarch             0.2.1-1.rhel6               pgdg95
 postgresql_anonymizer96.noarch             0.2.1-1.rhel6               pgdg96
 qt-postgresql.i686                         1:4.6.2-28.el6_5            base


インストール

 [root@XXXXX ~]# yum install postgresql11-server postgresql11-devel


確認

  • postgres ユーザー
 [root@XXXXX ~]# id postgres
 uid=26(postgres) gid=26(postgres) 所属グループ=26(postgres)


  • バージョン
 [root@XXXXX ~]# psql --version
 psql (PostgreSQL) 11.2


  • chkconfig
 [root@XXXXX ~]# chkconfig --list | grep postgresql
 postgresql-11  0:off   1:off   2:off   3:off   4:off   5:off   6:off


起動

 [root@XXXXX ~]# /etc/rc.d/init.d/postgresql-11 start
 /var/lib/pgsql/11/data is missing. Use "service postgresql-11 initdb" to initialize the cluster first.
                                                           [失敗]

失敗するので指示の通り、

 [root@XXXXX ~]# service postgresql-11 initdb -E EUC_JP --no-locale
 データベースを初期化中:                                    [  OK  ]

再度、

 [root@XXXXX ~]# /etc/rc.d/init.d/postgresql-11 start
 postgresql-11 サービスを開始中:                           [  OK  ]


設定

bash_profile

 [root@XXXXX ~]# su - postgres
 [rpmdevel@XXXXX ~]$ vi .bash_profile
 
 [ -f /etc/profile ] && source /etc/profile
 PGDATA=/var/lib/pgsql/11/data
 export PGDATA
 
 ↓修正
 
 [ -f /etc/profile ] && source /etc/profile
 PGHOME=/usr/pgsql-11
 PGDATA=/var/lib/pgsql/11/data
 PATH=$PATH:$PGHOME/bin
 export PGHOME PGDATA PGLIB


自動起動

 [root@XXXXX ~]# chkconfig postgresql-11 on


シンボリックリンクの作成

 [root@XXXXX ~]# ln -s /usr/pgsql-11 /usr/pgsql