Amazon LinuxにPostgreSQL 9.0をインストールする
2011年10月25日(火)

yumでPostgreSQL関連パッケージをインストール
yumコマンドでPostgreSQL関連パッケージをインストールする。インストールするのはpostgresql、postgresql-libs、postgresql-serverの3つのパッケージだ。
yumコマンドでのインストール実行例
# yum install postgresql postgresql-libs postgresql-server
Loaded plugins: fastestmirror, priorities, security, update-motd
Loading mirror speeds from cached hostfile
* amzn-main: packages.ap-northeast-1.amazonaws.com
* amzn-updates: packages.ap-northeast-1.amazonaws.com
amzn-main | 2.1 kB 00:00
amzn-updates | 2.1 kB 00:00
4 packages excluded due to repository priority protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql90.i686 0:9.0.5-1PGDG.rhel6 will be installed
---> Package postgresql90-libs.i686 0:9.0.5-1PGDG.rhel6 will be installed
---> Package postgresql90-server.i686 0:9.0.5-1PGDG.rhel6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
postgresql90 i686 9.0.5-1PGDG.rhel6 pgdg90 903 k
postgresql90-libs i686 9.0.5-1PGDG.rhel6 pgdg90 191 k
postgresql90-server i686 9.0.5-1PGDG.rhel6 pgdg90 3.3 M
Transaction Summary
================================================================================
Install 3 Package(s)
Total download size: 4.3 M
Installed size: 19 M
Is this ok [y/N]: y ★← yと入力
Downloading Packages:
(1/3): postgresql90-9.0.5-1PGDG.rhel6.i686.rpm | 903 kB 00:01
(2/3): postgresql90-libs-9.0.5-1PGDG.rhel6.i686.rpm | 191 kB 00:00
(3/3): postgresql90-server-9.0.5-1PGDG.rhel6.i686.rpm | 3.3 MB 00:00
--------------------------------------------------------------------------------
Total 1.4 MB/s | 4.3 MB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
pgdg-centos90-9.0-5.noarch has missing requires of centos-release
Installing : postgresql90-libs-9.0.5-1PGDG.rhel6.i686 1/3
Installing : postgresql90-9.0.5-1PGDG.rhel6.i686 2/3
Installing : postgresql90-server-9.0.5-1PGDG.rhel6.i686 3/3
Installed:
postgresql90.i686 0:9.0.5-1PGDG.rhel6
postgresql90-libs.i686 0:9.0.5-1PGDG.rhel6
postgresql90-server.i686 0:9.0.5-1PGDG.rhel6
Complete!
RPMパッケージをダウンロードしてインストール
yumを使うと以後のアップデートが容易になるが、取りあえずインストールしてデータベースを動かしたいのであればRPMパッケージをダウンロードしてインストールする方法の方が容易である。
RPMパッケージのダウンロード
RPMパッケージは以下のアドレスから辿っていくことができる。
→参照:PostgreSQL RPM Building Project Available Package List
インスタンスで使用しているAmazon Linuxが32ビットなので、PostgreSQL 9.0のリストにある「RHEL/CentOS/Scientific Linux 6 - i386」から辿って、postgresql90、postgresql90-libs、postgresql90-serverの3つのRPMパッケージをダウンロードする。Webブラウザでそのままダウンロードするのではなく、RPMパッケージへのURLを取得し、インスタンス上でwgetコマンドを使用してダウンロードすると手間が省けて良いだろう。
RPMパッケージのダウンロード例
# wget http://yum.pgrpms.org/9.0/redhat/rhel-6-i386/postgresql90-9.0.5-1PGDG.rhel6.i686.rpm # wget http://yum.pgrpms.org/9.0/redhat/rhel-6-i386/postgresql90-libs-9.0.5-1PGDG.rhel6.i686.rpm # wget http://yum.pgrpms.org/9.0/redhat/rhel-6-i386/postgresql90-server-9.0.5-1PGDG.rhel6.i686.rpm
ダウンロードが終わったら、rpmコマンドでインストールする。
RPMパッケージのインストール例
# rpm -ivh *.rpm
準備中... ########################################### [100%]
1:postgresql90-libs ########################################### [ 33%]
2:postgresql90 ########################################### [ 67%]
3:postgresql90-server ########################################### [100%]
ここまででPostgreSQL 9.0のインストールが完了した。最終回では、PostgreSQL 9.0の初期化とWebアプリケーションサーバーのインストールを行う。
連載バックナンバー
Think ITメルマガ会員登録受付中
Think ITでは、技術情報が詰まったメールマガジン「Think IT Weekly」の配信サービスを提供しています。メルマガ会員登録を済ませれば、メルマガだけでなく、さまざまな限定特典を入手できるようになります。


