[DB::PostgreSQL]インストール
CentOS 64bitにPostgreSQLのインストールしたときのメモ
1. postgresユーザを作成する
# useradd postgres # passwd postgres
2. インストールファイルをダウンロードする
日本PosstgreSQLユーザ会の「ソース版のダウンロード」にダウンロード先のリンクが張ってあるのでコピーする。
リンクを右クリックし「リンクのアドレスをコピー」でダウンロード先のURLをコピーできる。
wgetコマンドでファイルを取得する。
# wget ftp://ftp2.jp.postgresql.org/pub/postgresql/source/v9.0.1/postgresql-9.0.1.tar.gz
3. ダウンロードしたファイルを適当な場所に解凍する
# tar -vzxf postgresql-8.4.2.tar.gz
4. 解凍したディレクトリ(postgresql-9.0.1)に入る
# cd postgresql-9.0.1
5. ./configureを実行する
# ./configure checking for gcc... no checking for cc... no configure: error: no acceptable C compiler found in $PATH
エラーが発生した。gccコンパイラがないらしい。yumコマンドでインストールする。
# yum -y install gcc gcc-c++ configure: error: readline library not found If you have readline already installed, see config.log for details on the failure. It is possible the compiler isn't looking in the proper directory. Use --without-readline to disable readline support.
エラーが発生した。readlineというライブラリがないらしい。rpmコマンドでチェックしてみる。(readline:文字列入力用ライブラリのこと。PostgreSQLの入力プロンプトでタブ補完ができたり、↑や↓で入力ヒストリを参照できるようになる。)
# rpm -q readline readline-5.1-3.el5 readline-5.1-3.el5
readlineは入っている。このような場合、develファイルが入っていないことが多いので、readline-develがあるか確認してみる。(readline-devel:C言語からreadlineを使えるようにするものらしい)
# rpm -q readline-devel
package readline-devel is not installed
readline-develをインストールする
# yum install readline-devel
# yum -y install gcc gcc-c++
6. makeを実行する
# make all
7. make installを実行する
# make install
成功した場合、標準出力の最後に下記が出力される。
PostgreSQL installation complete.
8. インストールされているか確認する
デフォルトでは/usr/local/pgsqlにインストールされている。
# ls /usr/local/ |grep postgres
postgres
9. ディレクトリの所有グループとユーザ名を変更する
# chown postgres.postgres -R /usr/local/pgsql
10.postgresユーザのbashrcにパスを追記する
postgresユーザになる。
# su postgres
bashrcを開く。
$ vi ~/.bash_profile
下記を追記する。
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
export PATH="$PATH":/usr/local/pgsql/bin
export POSTGRES_HOME=/usr/local/pgsql
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export MANPATH="$MANPATH":$POSTGRES_HOME/man
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PGLIB"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
変更を反映する。
$ source ~/.bash_profile
11. インストールファイルを削除する
# rm postgresql-9.0.1.tar.gz # rm -rf postgresql-9.0.1
- 参照したサイト