我三流

いろいろ自分なりにやってみたことを書いています

FreeBSD postgresql 9.0 インストール

今日は、VC#開発環境のバックエンドサーバーである
FreeBSD8.1サーバーのPostgreSQLのバージョンを8.4から9.0にしました。

とりあえず、常時稼動していないので

# portsnap fetch
# portsnap extract
# portsnap update

しておく。

いままで、稼動していたpostgresql8.4のバックアップを行っておく
(うちの場合は、お手軽に、pgAdminIIIでおこなう。)
だんぷできたらFTPクライアント等でサーバーに転送しておく。

postgresqlの停止

# /usr/local/etc/rc.d/postgresql stop

で、既存のpostgresql84-serverを削除しておく

# cd /usr/ports/databases/postgresql84-client
# make deinstall
# cd /usr/ports/databases/postgresql84-server
# make deinstall

で、いつもなら

# cd /usr/ports
# portinstall databases/postgresql90-server

としてインストールするところですが、

# portinstall databases/postgresql90-server

エラーもでないが極端に早く終了してしまう。

試しにpostgresqlを起動してみるが

# /usr/local/etc/rc.d/postgresql start
# ps aux | grep postgres

予想通り、何も起動していない。

そこで、今更だが、も一度ググッて情報収集したところ

http://www.freshports.org/databases/postgresql90-server/ によると

To install the port: cd /usr/ports/databases/postgresql90-server/ && make install clean

と、ある。

それならば、ということで

# cd /usr/ports/databases/postgresql90-client
# make install
# cd /usr/ports/databases/postgresql84-server
# make install

これでインストール成功。

/var/db/ports/optionsの内容はこうなっていた。

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for postgresql-client-9.0.0
_OPTIONS_READ=postgresql-client-9.0.0
WITH_NLS=true
WITHOUT_DTRACE=true
WITHOUT_PAM=true
WITHOUT_LDAP=true
WITHOUT_MIT_KRB5=true
WITHOUT_HEIMDAL_KRB5=true
WITHOUT_OPTIMIZED_CFLAGS=true
WITH_XML=true
WITH_TZDATA=true
WITHOUT_DEBUG=true
WITHOUT_ICU=true
WITHOUT_ICU4=true
WITH_INTDATE=true

あとは、
既存の/usr/local/pgsql/dataを空にしておく。

# mv /usr/local/pgsql/data /usr/local/pgsql/data_bak
# mkdir /usr/local/pgsql/data
# chown pgsql /usr/local/pgsql/data

# su pgsql

$ cd /usr/local/pgsql/
$ initdb -D ./data --encoding=utf-8 --lc-collate=C
$ exit

ここで一旦、
/usr/local/pgsql/data ディレクトリ内にある
pg_hba.conf
postgres.conf
を適時編集する。

# su pgsql

$ createdb yu2 -O yu2admin
$ psql yu2 < /usr/home/yu2_bak.sql

で、無事終了。

# /usr/local/etc/rc.d/postgresql start

以下で、確認できます。

# psql -U yu2admin -d yu2
psql (9.0.0)
Type "help" for help.

yu2=# select version();
                                                 version                                
---------------------------------------------------------------------------------------------------------
 PostgreSQL 9.0.0 on i386-portbld-freebsd8.1, compiled by GCC cc (GCC) 4.2.1 20070719  [FreeBSD], 32-bit
(1 row)