PostgreSQL のインストール(覚書)

UbuntuにPostgreSQL(以降ポスグレ)の古いバージョン8.3.6をインストール。

まずはポスグレ用のユーザを作成。

※sudo は省略。

$ groupadd postgres
$ useradd -g postgres -m postgres
$ passwd postgres

Readline, Ncurses, zlib が必要のことで、

ここ(http://debianj.com/debian/postgresql/install)を参考にインストール。

$ apt-get install libreadline5-dev libncurses5-dev zlib1g-dev

PostgreSQLのインストール。

$ wget -P /usr/local/src ftp://ftp.jp.postgresql.org/source/v8.1.5/postgresql-8.3.6.tar.gz
$ mkdir /usr/local/postgresql-8.3.6
$ chown postgres:postgres /usr/local/postgresql-8.3.6
$ cd /usr/local/src
$ tar xzf postgresql-8.3.6.tar.gz
$ chown -R postgres:postgres /usr/local/src/postgresql-8.3.6
$ su - postgres
$ cd /usr/local/src/postgresql-8.1.5
$ ./configure --prefix=/usr/local/postgresql-8.3.6

おっと、ここでエラー。

ここでlibreadのエラー・・・ちゃんとインストールされてなかったのか?

$ sudo apt-get install libreadline6 libreadline6-dev

で無事インストール完了。

再度試すも、今度はzlibでエラー。

$ wget -P /usr/local/src http://www.zlib.net/zlib-1.2.8.tar.gz
$ cd /usr/local/src
$ tar xzf zlib-1.2.8.tar.gz
$ cd zlib-1.2.8
$ ./configure --prefix=/usr/local
$ make
$ make install

でインストール完了。

改めてpostgureのユーザにログインして、

$ cd /usr/local/src/postgresql-8.3.6
$ ./configure --prefix=/usr/local/postgresql-8.3.6
$ make
$ make install

posgresからexitし、シンボリックリンクの作成。

$ ln -sfn /usr/local/postgresql-8.3.6 /usr/local/pgsql

再びpostgresになり、

環境変数の追加で~/.profileの末尾に下記を追加し、

PGHOME=/usr/local/pgsql
PGDATA=$PGHOME/data
PGLIB=$PGHOME/lib
PATH=$PATH:$HOME/bin:$PGHOME/bin
export PGHOME PGDATA PGLIB PATH
$ source ~/.profile

PostgreSQLの初期化。

$ initdb --no-locale

エラー発生!

initializing pg_authid ... FATAL:  wrong number of index expressions
STATEMENT:  CREATE TRIGGER pg_sync_pg_database   AFTER INSERT OR UPDATE OR DELETE ON pg_database   FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger();

調べてみるとgccを古くする必要があると・・・。

$ apt-get install gcc-4.7

でひとつ前のgccをインストールし、リンク替え。

$ ln -sfn /usr/bin/gcc-4.7 /usr/bin/gcc

改めてpostgresに変わって、再度make install。

そして、initdb を・・・でできた!!

postgresからexitし、ld.so.confを開く。

vi /etc/ld.so.conf

下記を追加。

include /usr/local/pgsql/lib

設定ファイルを更新。

sudo ldconfig -v

起動ファイルの設定。

$ cp /usr/local/src/postgresql-8.3.6/contrib/start-scripts/linux /etc/init.d/postgresql
$ chmod 755 /etc/init.d/postgresql
$ update-rc.d postgresql start 90 2 3 4 5 . stop 10 0 1 6 .

ポスグレを起動。

$ /etc/init.d/postgresql start

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です