ツムラ_メモ

大失敗を繰り返す。

Ubuntu 9.04へのPostgresql 8.04のインストール

パッケージに入っているのが少し古いPostgresqlだったので、ソースからインストール。
PostgreSQL 8.4.0 ― NPO法人 日本PostgreSQLユーザ会 http://www.postgresql.jp/postgresql/8_4/8_4_0
ダウンロードした.tar.gzを解凍。
以下ターミナルでの作業。

$ ./configure

checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking if gcc supports -Wdeclaration-after-statement... yes
checking if gcc supports -Wendif-labels... yes
checking if gcc supports -fno-strict-aliasing... yes
checking if gcc supports -fwrapv... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking allow thread-safe client libraries... no
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with Kerberos 5 support... no
checking whether to build with PAM support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for tar... /bin/tar
checking whether ln -s works... yes
checking for gawk... gawk
checking for bison... no
configure: WARNING:

Without Bison you will not be able to build PostgreSQL from CVS nor
change any of the parser definition files. You can obtain Bison from
a GNU mirror site. (If you are using the official distribution of
PostgreSQL then you do not need to worry about this, because the Bison
output is pre-generated.)

checking for flex... no
configure: WARNING:

Without Flex you will not be able to build PostgreSQL from CVS or
change any of the scanner definition files. You can obtain Flex from
a GNU mirror site. (If you are using the official distribution of
PostgreSQL then you do not need to worry about this because the Flex
output is pre-generated.)

checking for perl... /usr/bin/perl
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing fdatasync... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for -lreadline... no
checking for -ledit... no
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 libraryがないよって言われたので、検索してみる。
$ apt-cache search readline

libreadline5 - GNU readline および history ライブラリ - ランタイムライブラリ
libreadline5-dbg - GNU readline and history libraries, debugging libraries
libreadline5-dev - GNU readline and history libraries, development files

多分 libreadline5だろう。
libreadline5は初期状態から導入されている?っぽいが、どうやらlibreadline5-devが必要なご様子。

# apt-get install libreadline5-dev
$ make
$ su
# make install
# adduser postgres
# mkdir /usr/local/pgsql/data
# chown postgres /usr/local/pgsql/data
# su - postgres
$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale ja_JP.UTF-8.
The default database encoding has accordingly been set to UTF8.
initdb: could not find suitable text search configuration for locale ja_JP.UTF-8
The default text search configuration will be set to "simple".

fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 28MB
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
or
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

$ /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data/ >logfile 2>&1 &

[1] 16562

$ /usr/local/pgsql/bin/createdb test
$ /usr/local/pgsql/bin/psql test

testDBを作成して完了。
とりあえずPosgreの使い方忘れた!