[AWS][CentOS]postgres9.2入れる | iii threetreeslight

November 1, 2012

[AWS][CentOS]postgres9.2入れる

herokuをdev環境やstagingとして使う事出来るので、postgresを使う事にする。

CentOSリポジトリの物は古いので、新しいのをとってきていれる

$ sudo rpm -ivh http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm
警告: /http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
準備中...                ########################################### [100%]
   1:pgdg-centos92          ########################################### [100%]

$ yum list | grep postgres
bacula-director-postgresql.x86_64    5.0.0-9.el6               base             
bacula-storage-postgresql.x86_64     5.0.0-9.el6               base             
check_postgres.noarch                2.19.0-1.rhel6            pgdg92           
freeradius-postgresql.x86_64         2.1.12-4.el6_3            updates          
postgresql.i686                      8.4.13-1.el6_3            updates          
postgresql.x86_64                    8.4.13-1.el6_3            updates          
postgresql-contrib.x86_64            8.4.13-1.el6_3            updates          
postgresql-devel.i686                8.4.13-1.el6_3            updates          
postgresql-devel.x86_64              8.4.13-1.el6_3            updates          
postgresql-docs.x86_64               8.4.13-1.el6_3            updates          
postgresql-jdbc.x86_64               8.4.701-3.el6             base             
postgresql-jdbc.noarch               8.4.701-8.el6             base             
postgresql-libs.i686                 8.4.13-1.el6_3            updates          
postgresql-libs.x86_64               8.4.13-1.el6_3            updates          
postgresql-odbc.x86_64               08.04.0200-1.el6          base             
postgresql-plperl.x86_64             8.4.13-1.el6_3            updates          
postgresql-plpython.x86_64           8.4.13-1.el6_3            updates          
postgresql-pltcl.x86_64              8.4.13-1.el6_3            updates          
postgresql-server.x86_64             8.4.13-1.el6_3            updates          
postgresql-test.x86_64               8.4.13-1.el6_3            updates          
postgresql92.x86_64                  9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-contrib.x86_64          9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-debuginfo.x86_64        9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-devel.x86_64            9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-docs.x86_64             9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-jdbc.x86_64             9.2.1000-1PGDG.rhel6      pgdg92           
postgresql92-jdbc-debuginfo.x86_64   9.2.1000-1PGDG.rhel6      pgdg92           
postgresql92-libs.x86_64             9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-odbc.x86_64             09.01.0200-1PGDG.rhel6    pgdg92           
postgresql92-odbc-debuginfo.x86_64   09.01.0200-1PGDG.rhel6    pgdg92           
postgresql92-plperl.x86_64           9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-plpython.x86_64         9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-pltcl.x86_64            9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-server.x86_64           9.2.1-1PGDG.rhel6         pgdg92           
postgresql92-tcl.x86_64              2.0.0-1.rhel6             pgdg92           
postgresql92-tcl-debuginfo.x86_64    2.0.0-1.rhel6             pgdg92           
postgresql92-test.x86_64             9.2.1-1PGDG.rhel6         pgdg92           
qt-postgresql.i686                   1:4.6.2-24.el6            base             
qt-postgresql.x86_64                 1:4.6.2-24.el6            base    


$ yum info postgresql92-server
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirror.usonyx.net
 * extras: mirror.usonyx.net
 * updates: mirror.usonyx.net
Available Packages
Name        : postgresql92-server
Arch        : x86_64
Version     : 9.2.1
Release     : 1PGDG.rhel6
Size        : 3.7 M
Repo        : pgdg92
Summary     : The programs needed to create and run a PostgreSQL server
URL         : http://www.postgresql.org/
License     : PostgreSQL
Description : The postgresql92-server package includes the programs needed to create
            : and run a PostgreSQL server, which will in turn allow you to create
            : and maintain PostgreSQL databases.  PostgreSQL is an advanced
            : Object-Relational database management system (DBMS) that supports
            : almost all SQL constructs (including transactions, subselects and
            : user-defined types and functions). You should install
            : postgresql92-server if you want to create and maintain your own
            : PostgreSQL databases and/or your own PostgreSQL server. You also need
            : to install the postgresql package.


$ sudo yum install postgresql92-server

確認

$ rpm -qa | grep postgres
postgresql92-server-9.2.1-1PGDG.rhel6.x86_64
postgresql92-9.2.1-1PGDG.rhel6.x86_64
postgresql92-libs-9.2.1-1PGDG.rhel6.x86_64

$ psql --version
psql (PostgreSQL) 9.2.1


サービスの立ち上げ

$ sudo service postgresql-9.2 initdb 
Initializing database:                                     [  OK  ] 
$ sudo service postgresql-9.2 start
Starting postgresql-9.2 service:                           [  OK  ]

$ sudo su postgres
bash-4.1$ psql -l
could not change directory to "/home/webadmin"
                             List of databases
   Name    |  Owner   | Encoding  | Collate | Ctype |   Access privileges   
-----------+----------+-----------+---------+-------+-----------------------
 postgres  | postgres | SQL_ASCII | C       | C     | 
 template0 | postgres | SQL_ASCII | C       | C     | =c/postgres          +
           |          |           |         |       | postgres=CTc/postgres
 template1 | postgres | SQL_ASCII | C       | C     | =c/postgres          +
           |          |           |         |       | postgres=CTc/postgres


参考
http://people.planetpostgresql.org/devrim/index.php?/archives/48-What-is-new-in-PostgreSQL-9.0-RPMs.html