Marlock Homes Diary

備忘録。忘れないように書きます。

PostgreSQLインストールメモ(バージョン 9.2)

PostgreSQLをインストールした際のメモ

環境        バージョン
CentOS     6.4
PostgreSQL     9.2.4

 

1.環境準備

1.1.make

バージョンが3.8以上であることを確認

# gmake --version

GNU Make 3.81

 

1.2.gcc

インストールされていることを確認

# gcc -v

 

1.3. Readline

Readlineライブラリをインストール

# yum install readline

# yum install readline-devel

 

2.PostgreSQLインストール

2.1.postgresユーザ作成

# useradd postgres

 

2.2.ソースの入手と解答

# su - postgres

$ cd /usr/local/src/
$ wget http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.gz
$ tar xvzf postgresql-9.2.4.tar.gz

 

2.3.コンパイル

$ cd postgresql-9.2.4/

$ ./configure

$ gmake world

(省略)

PostgreSQL, contrib, and documentation successfully made. Ready to install.

※ドキュメント(HTMLやman)や追加モジュール(contrib)を含め、構築可能なもの全てを構築したい場合、上記の様に実施します

 

2.4.リグレーションテスト

$ gmake check

(省略)

=======================
 All 131 tests passed.
=======================

(省略)

 

2.5.インストール

$ su
# gmake install-world
(省略)

PostgreSQL, contrib, and documentation installation complete.

 

2.6.インストールディレクトリの所有者変更

# cd /usr/local/

# chown -R postgres:postgres pgsql/

 

2.7.postgresユーザの環境変数設定

# su - postgres
$ vi .bash_profile (下記を設定)

# PostgreSQL PATH
export POSTGRES_HOME=/usr/local/pgsql
export PGDATA=/home/postgres/data
export PATH=$PATH:$POSTGRES_HOME/bin
export PGLIB=/usr/local/pgsql/lib
export MANPATH="$MANPATH":$POSTGRES_HOME/man
export

2.7.postgresユーザの環境変数設定読み込み

$ source .bash_profile

 

2.8.データベースクラスタの作成

$ initdb -E UTF8 --no-locale

 

2.9.PostgreSQL起動

$ initdb -E UTF8 --no-locale

 

以上