CentOS6にPostgresインストール

■yumで使用するリポジトリのrpmパッケージの設定ファイルダウンロード
cd /tmp/
wget http://yum.pgrpms.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm

■インストール
rpm -ivh ./pgdg-centos93-9.3-1.noarch.rpm

■確認
ls -l /etc/yum.repos.d/ [/etc/yum.repos.d]
-rw-r--r-- 1 root root 2001 10月 20 15:30 2013 CentOS-Base.repo



-rw-r--r-- 1 root root 442 5月 9 03:58 2013 pgdg-93-centos.repo

CentOS-Base.repoからpostgresのパッケージをインストールしないように設定
vim /etc/yum.repos.d/vim CentOS-Base.repo
[base]
末尾に
exclude=postgresql*
[update]
末尾に
exclude=postgresql*

■インストール

yum install postgresql-server [~]

Loaded plugins: fastestmirror, priorities, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* remi: mirror.smartmedia.net.id
* updates: ftp.iij.ad.jp
565 packages excluded due to repository priority protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql93-server.x86_64 0:9.3.1-1PGDG.rhel6 will be installed
--> Processing Dependency: postgresql93 = 9.3.1-1PGDG.rhel6 for package: postgresql93-server-9.3.1-1PGDG.rhel6.x86_64
--> Running transaction check
---> Package postgresql93.x86_64 0:9.3.1-1PGDG.rhel6 will be installed
--> Processing Dependency: postgresql93-libs = 9.3.1-1PGDG.rhel6 for package: postgresql93-9.3.1-1PGDG.rhel6.x86_64
--> Running transaction check
---> Package postgresql93-libs.x86_64 0:9.3.1-1PGDG.rhel6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
postgresql93-server x86_64 9.3.1-1PGDG.rhel6 pgdg93 4.0 M
Installing for dependencies:
postgresql93 x86_64 9.3.1-1PGDG.rhel6 pgdg93 1.0 M
postgresql93-libs x86_64 9.3.1-1PGDG.rhel6 pgdg93 189 k

Transaction Summary
================================================================================
Install 3 Package(s)

Total download size: 5.2 M
Installed size: 21 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): postgresql93-9.3.1-1PGDG.rhel6.x86_64.rpm | 1.0 MB 00:01 
(2/3): postgresql93-libs-9.3.1-1PGDG.rhel6.x86_64.rpm | 189 kB 00:00 
(3/3): postgresql93-server-9.3.1-1PGDG.rhel6.x86_64.rpm | 4.0 MB 00:00 
--------------------------------------------------------------------------------
Total 1.6 MB/s | 5.2 MB 00:03

■postgresのアカウント確認(自動で作られる)
id postgres
uid=26(postgres) gid=26(postgres) 所属グループ=26(postgres)

■コマンドの確認
which psql

■/etc/init.d/にpostgres起動コマンドがあることを確認
ls -la /etc/init.d/
postgresql-9.3があればOK

■OS起動したら自動で起動するように設定
chkconfig postgresql on

■DB起動
service postgresql-9.3 initdb