Linux(CentOS 6) - yum installコマンドでpostgresqlパッケージをインストールする

以下は、minimal install(ミニマルインストール)したCentOS 6.4でpostgresqlパッケージをインストールした時のメモとなる。

[root@test ~]# rpm -q postgresql   ←rpmコマンドで「postgresql」パッケージのインストール状況を調べる。
パッケージ postgresql はインストールされていません。
[root@test ~]# yum list postgresql   ←「yum list」コマンドで「postgresql」パッケージを探す。
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Available Packages
postgresql.i686 8.4.13-1.el6_3 base
postgresql.x86_64 8.4.13-1.el6_3 base
[root@test ~]# yum install postgresql   ←「yum install」コマンドで「postgresql」パッケージをインストールする。
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql.x86_64 0:8.4.13-1.el6_3 will be installed
--> Processing Dependency: postgresql-libs(x86-64) = 8.4.13-1.el6_3 for package: postgresql-8.4.13-1.el6_3.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-8.4.13-1.el6_3.x86_64
--> Running transaction check
---> Package postgresql-libs.x86_64 0:8.4.13-1.el6_3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
postgresql x86_64 8.4.13-1.el6_3 base 2.8 M
Installing for dependencies:
postgresql-libs x86_64 8.4.13-1.el6_3 base 200 k

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

Total download size: 3.0 M
Installed size: 15 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): postgresql-8.4.13-1.el6_3.x86_64.rpm | 2.8 MB 00:02
(2/2): postgresql-libs-8.4.13-1.el6_3.x86_64.rpm | 200 kB 00:00
--------------------------------------------------------------------------------
Total 980 kB/s | 3.0 MB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : postgresql-libs-8.4.13-1.el6_3.x86_64 1/2
Installing : postgresql-8.4.13-1.el6_3.x86_64 2/2
Verifying : postgresql-libs-8.4.13-1.el6_3.x86_64 1/2
Verifying : postgresql-8.4.13-1.el6_3.x86_64 2/2

Installed:
postgresql.x86_64 0:8.4.13-1.el6_3

Dependency Installed:
postgresql-libs.x86_64 0:8.4.13-1.el6_3

Complete!   ←左記のメッセージが表示されたら、「postgresql」パッケージのインストールは完了。
[root@test ~]# rpm -q postgresql   ←rpmコマンドで「postgresql」パッケージのインストール状況を調べる。
postgresql-8.4.13-1.el6_3.x86_64
[root@test ~]# ls -ahl /var/lib/pgsql   ←lsコマンドで、/var/lib/pgsqlディレクトリが作成されたかを確認する。
ls: cannot access /var/lib/pgsql: そのようなファイルやディレクトリはありません   ←あれ....../var/lib/pgsqlディレクトリがない!?
[root@test ~]# rpm -qa | grep postgres ←rpmコマンドで「postgres」の文字列を含むパッケージのインストール状況を調べる。
postgresql-libs-8.4.13-1.el6_3.x86_64
postgresql-8.4.13-1.el6_3.x86_64

何か足りないことに気付く。何となく想像はつくが、念のため、ネットで調べる。

《参考》CentOS で PostgreSQL を使ってみよう!(1) - Let's Postgres
http://lets.postgresql.jp/documents/tutorial/centos

こちらのサイトで確認したところ、「postgresql-libs」と「postgresql」以外に「postgresql-server」が必要であることを確認できた。

postgresql-serverがインストールされていなかったので、インストールすることとする。

[root@test ~]# yum list postgresql-server   ←「yum list」コマンドで「postgresql-server」パッケージを探す。
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Available Packages
postgresql-server.x86_64 8.4.13-1.el6_3 base
[root@test ~]# yum install postgresql-server   ←「yum install」コマンドで「postgresql-server」パッケージをインストールする。
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql-server.x86_64 0:8.4.13-1.el6_3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
postgresql-server x86_64 8.4.13-1.el6_3 base 3.4 M

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

Total download size: 3.4 M
Installed size: 14 M
Is this ok [y/N]: y
Downloading Packages:
postgresql-server-8.4.13-1.el6_3.x86_64.rpm | 3.4 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : postgresql-server-8.4.13-1.el6_3.x86_64 1/1
Verifying : postgresql-server-8.4.13-1.el6_3.x86_64 1/1

Installed:
postgresql-server.x86_64 0:8.4.13-1.el6_3

Complete!   ←左記のメッセージが表示されたら、「postgresql-server」パッケージのインストールは完了。
[root@test ~]# rpm -qa | grep postgres ←rpmコマンドで「postgres」の文字列を含むパッケージのインストール状況を調べる。
postgresql-libs-8.4.13-1.el6_3.x86_64
postgresql-server-8.4.13-1.el6_3.x86_64
postgresql-8.4.13-1.el6_3.x86_64
[root@test ~]# ls -ahl /var/lib/pgsql   ←lsコマンドで、/var/lib/pgsqlディレクトリが作成されたかを確認する。(今度は無事に作成できていた。)
合計 20K
drwx------. 4 postgres postgres 4.0K 5月 6 15:18 2013 .
drwxr-xr-x. 18 root root 4.0K 5月 6 15:18 2013 ..
-rw-r--r--. 1 postgres postgres 85 9月 14 02:25 2012 .bash_profile
drwx------. 2 postgres postgres 4.0K 9月 14 02:25 2012 backups
drwx------. 2 postgres postgres 4.0K 9月 14 02:25 2012 data
[root@test ~]# /etc/rc.d/init.d/postgresql status   ←postgresqlサービスの起動状況を確認する。(左記のコマンドは、「postgresql-server」パッケージをインストールするまでは実行できないコマンド。)
postmaster は停止しています
[root@test ~]# ps -ef | grep postgres   ←postgresqlサービスのプロセス実行状況を確認する。
root 11838 11443 0 15:28 pts/1 00:00:00 grep postgres
[root@test ~]# chkconfig --list postgres   ←chkconfigコマンドで、postgresqlサービスの自動起動設定を確認する。
サービス postgres に関する情報の読み込み中にエラーが発生しました: そのようなファイルやディレクトリはありません
[root@test ~]# chkconfig postgresql on   ←chkconfigコマンドで、postgresqlサービスの自動起動設定を行う。
[root@test ~]# chkconfig --list postgresql   ←chkconfigコマンドで、postgresqlサービスの自動起動設定を確認する。(ランレベル2345でonになっていることを確認する。)
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@test ~]# /etc/rc.d/init.d/postgresql start   ←postgresqlサービスの起動コマンドを実行する。

/var/lib/pgsql/data is missing. Use "service postgresql initdb" to initialize the cluster first.   ←まず最初に、クラスタを初期化するために「service postgresql initdb」を実行しなさい、というエラーメッセージが表示される。
[失敗]
[root@test ~]# service postgresql initdb   ←エラーメッセージに従い、「service postgresql initdb」コマンドを実行し、クラスタを初期化する。
データベースを初期化中: [ OK ]
[root@test ~]# /etc/rc.d/init.d/postgresql start   ←postgresqlサービスの起動コマンドを実行する。
postgresql サービスを開始中: [ OK ]
[root@test ~]# /etc/rc.d/init.d/postgresql status   ←postgresqlサービスの起動状況を確認する。
postmaster (pid 11929) を実行中...
[root@test ~]# ps -ef | grep postgres   ←postgresqlサービスのプロセス実行状況を確認する。
postgres 11929 1 0 15:30 ? 00:00:00 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data
postgres 11931 11929 0 15:30 ? 00:00:00 postgres: logger process
postgres 11933 11929 1 15:30 ? 00:00:00 postgres: writer process
postgres 11934 11929 0 15:30 ? 00:00:00 postgres: wal writer process
postgres 11935 11929 0 15:30 ? 00:00:00 postgres: autovacuum launcher process
postgres 11936 11929 0 15:30 ? 00:00:00 postgres: stats collector process
root 11948 11443 0 15:31 pts/1 00:00:00 grep postgres

前へ

Linux(CentOS 6) - FTP接続時のエラー「500 OOPS: cannot change directory」「500 OOPS: priv_sock_get_cmd」の原因と解決方法

次へ

Linux(CentOS 6) - 「Apache HTTP Server Test Page powered by CentOS」ページを削除する方法