雑なメモ(無保証)

postgresql-7.0.3-patchedインストール


Rev.1を表示中。最新版はこちら

●postgresql-7.0.3-patchedインストール
※postgresql7.0.3は開発が途中で止まっただけでなく、インストールすらまともにできな状態のモノ。どうしてもこのバージョンでなければならない場合以外は避けるべき。というか最新安定版を入れるべきだと思います(アプリ側の修正が大変でも)。

1)postgresユーザの作成・パスワード設定
useradd postgres
passwd postgres
Changing password for user postgres.
New UNIX password:  ← パスワードを入力
Retype new UNIX password: ← もう一度入力
passwd: all authentication tokens updated successfully.


2) インストールディレクトリを作成しておく
mkdir /usr/local/pgsql
chown postgres:postgres /usr/local/pgsql


3)postgresqlインストール
※configureオプションはお好みで。
cd /usr/local/src/postgresql
tar zxvf postgresql-7.0.3-patched.tar.gz
cd postgresql-7.0.3/src


4)configure実行時のgccバージョンエラー対処
gccバージョン3.xだとバージョンチェックでエラーになる。
(バージョンが合わないのではなくて、 -v の戻り値が複数行になっていてpostgresql側が処理できない)

4-1)configure実行時に生成されるconftestファイルを取り出す為の修正を行い、configureを実行する

vi configure
※8445行目付近
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
ac_file=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_cmds # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=""
while $ac_more_lines; do
  if test $ac_beg -gt 1; then
    sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
  else
    sed "${ac_end}q" conftest.subs > conftest.s$ac_file
  fi

######## ここから追加
cp conftest.s$ac_file /home/postgres/tmp.s$ac_file

#if test $ac_file = 1; then
#  cp /home/postgres/tmp.s1 ./conftest.s1
#fi
######## ここまで追加

  if test ! -s conftest.s$ac_file; then
    ac_more_lines=false
    rm -f conftest.s$ac_file
  else
    if test -z "$ac_sed_cmds"; then
      ac_sed_cmds="sed -f conftest.s$ac_file"
    else
      ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
    fi
    ac_file=`expr $ac_file + 1`
    ac_beg=$ac_end
    ac_end=`expr $ac_end + $ac_max_sed_cmds`
  fi
 
done


4-2)configureを実行し、tmp.s1 〜 tmp.s3 を出力させる。
./configure --enable-multibyte=EUC_JP


4-3)取り出したファイルtmp.s1の35行目、gccのバージョン表示を一行にする
vi /home/postgres/tmp.s1

---修正前
s%@CC_VERSION@%gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-20)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.%g


---修正後
s%@CC_VERSION@%gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-20)%g


4-4)configureファイルで修正したファイルを読み込むようにする
vi configure

######## ここから追加
#cp conftest.s$ac_file /home/postgres/tmp.s$ac_file

if test $ac_file = 1; then
  cp /home/postgres/tmp.s1 ./conftest.s1
fi
######## ここまで追加


4-5)configureを実行する
./configure --enable-multibyte=EUC_JP


5)make時のエラー対処
vi ./backend/commands/command.c
※26行目に追加
#include <errno.h>

vi ./backend/commands/copy.c
※17行目に追加
#include <errno.h>

vi ./backend/libpq/pqformat.c
※47行目に追加
#include <errno.h>

vi ./backend/utils/init/postinit.c
※16行目に追加
#include <errno.h>

vi ./src/bin/psql/tab-complete.c
※44、46行目のifdefを無効化
/*#ifdef USE_ASSERT_CHECKING*/
#include <assert.h>
/*#endif*/

※53、56行目のifdefを無効化
/*#if defined(HAVE_FILENAME_COMPLETION_FUNCTION) && !defined(HAVE_FILENAME_・・・・・・*/
char *filename_completion_function(char *, int);
/*#endif*/


6) make実行
gmake


7)インストール
su - postgres
cd /usr/local/src/postgresql/postgresql-7.0.3/src
gmake install
cd ../doc
gmake install


8)initdbコマンドエラー対処
※/usr/local/pgsql/lib/global1.bki.sourceとlocal1_template1.bki.source内の記述ミスを修正

cd /usr/local/pgsql/lib/
chmod +w global1.bki.source
cp global1.bki.source global1.orig
sed -e "s:= ame:= name:" global1.orig > global1.bki.source
chmod -w global1.bki.source

chmod +w local1_template1.bki.source
cp local1_template1.bki.source local1_template1.bki.orig
sed -e "s:= ame:= name:" local1_template1.bki.orig > local1_template1.bki.source
chmod -w local1_template1.bki.source


9)環境変数設定
vi /home/postgres/.bash_profile
export POSTGRES_HOME=/usr/local/pgsql ← 追加
export PGLIB=$POSTGRES_HOME/lib ← 追加
export PGDATA=$POSTGRES_HOME/data ← 追加
export PATH=$PATH:$HOME/bin:$POSTGRES_HOME/bin ← 追加

※反映
source /home/postgres/.bash_profile


10)共有ライブラリ設定
※環境変数に設定してもよい( export LD_LIBRARY_PATH=$POSTGRES_HOME/lib )
vi /etc/ld.so.conf
/usr/local/pgsql/lib ← 追加

※反映
ldconfig


11) DB初期化
initdb


12)postgresql起動
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start

 


最終更新 2011/05/21 21:19:35 - llinfo_arp
(2011/05/21 21:19:35 作成)


Amazon