PostgreSQLインストール

仕事でBTS実験機(軌道にのったらそのままBTSサーバ)を作ることが決定。
担当が私になる。趣味が高じたわけだ。

なのでいろいろ履歴メモを残す。

# ll postgres*
-rw-r--r--    1 ****      ****       1663552  3月 22  2004 postgresql-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****        343818  3月 22  2004 postgresql-contrib-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****       1490831  3月 22  2004 postgresql-devel-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****       4676917  3月 22  2004 postgresql-docs-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****        461311  3月 22  2004 postgresql-jdbc-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****         88744  3月 22  2004 postgresql-libs-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****        381027  3月 22  2004 postgresql-pl-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****         40918  3月 22  2004 postgresql-python-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****       2690029  3月 22  2004 postgresql-server-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****         24112  3月 22  2004 postgresql-tcl-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****       1038927  3月 22  2004 postgresql-test-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****         34526  3月 22  2004 postgresql72-libs-1-4.rhl9.i386.rpm

こんなに関連パッケージがある。
最低限必要なのは、

-rw-r--r--    1 ****      ****       1663552  3月 22  2004 postgresql-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****         88744  3月 22  2004 postgresql-libs-7.3.4-3.rhl9.i386.rpm
-rw-r--r--    1 ****      ****       2690029  3月 22  2004 postgresql-server-7.3.4-3.rhl9.i386.rpm

の三つ。

どうやら依存関係を考えると、postgresql-libs-7.3.4-3.rhl9.i386.rpmを最初に入れるとよさげ。

さて次。
どうやらこのrpmパッケージでインストールすると、postgresユーザが自動的に作成されている。
ので、

# su - postgres

する。

・・・・。postgresユーザのホームディレクトリがYoooooo。
/var/lib/pgsql/になってる 笑
そして各種プログラムは/usr/bin配下にぶちまけられてる。

しゃ、しゃーない。データベースの初期化を行う。

$ /usr/bin/initdb -D /var/lib/pgsql/data/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale ja_JP.eucJP.
This locale setting will prevent the use of indexes for pattern matching
operations.  If that is a concern, rerun initdb with the collation order
set to "C".  For more information see the Administrator's Guide.

Fixing permissions on existing directory /var/lib/pgsql/data/... ok
creating directory /var/lib/pgsql/data//base... ok
creating directory /var/lib/pgsql/data//global... ok
creating directory /var/lib/pgsql/data//pg_xlog... ok
creating directory /var/lib/pgsql/data//pg_clog... ok
creating template1 database in /var/lib/pgsql/data//base/1... ok
creating configuration files... ok
initializing pg_shadow... ok
enabling unlimited row size for system tables... ok
initializing pg_depend... ok
creating system views... ok
loading pg_description... ok
creating conversions... ok
setting privileges on built-in objects... ok
vacuuming database template1... ok
copying template1 to template0... ok

Success. You can now start the database server using:

    /usr/bin/postmaster -D /var/lib/pgsql/data/
or
    /usr/bin/pg_ctl -D /var/lib/pgsql/data/ -l logfile start

よし、問題なし。
テスト起動

$ pg_ctl -o "-S -i" start
postmaster successfully started

問題なし。
今回の起動モードはデーモン状態で(-S)、tcp/ip通信可能な(-i)状態で起動、と言う意味。

一旦終了

$ pg_ctl -w stop

終了操作完了まで、ちっと待っといてくれモードで終了。

これにて完了。
いや後はpg_hba.confで通信設定をしないといけないけど、それはまた。