ちょっと古いFedoraでPostgreSQL9.1.3

昨日の続き。いまのところPythonからPostgreSQLへアタッチするのは、いままで使っていた各種ライブラリでも問題ありません。
こんどはレプリカ環境をテストするために、また別のサーバへPostgreSQL9.1.3をインストール。使った機械はPenIIIのちょっと古い機械にFedoraCoreの7だか8だかが入っているサーバ。

リンク時にエラーが

通常通りconfiure,makeするとこんなエラー。なにかシンボルがみつからないとか。

make[4]: Leaving directory `/home/hoge/postgres/postgresql-9.1.3/src/port'
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard pg_dump.o common.o pg_dump_sort.o keywords.o kwlookup.o pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o pg_backup_files.o pg_backup_null.o pg_backup_tar.o pg_backup_directory.o dumputils.o compress_io.o  -L../../../src/port -lpgport -L../../../src/interfaces/libpq -lpq -L../../../src/port  -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags  -lpgport -lz -lreadline -ltermcap -lcrypt -ldl -lm  -o pg_dump
pg_backup_archiver.o(.text+0x15fb): In function `SetOutput':
: undefined reference to `gzopen64'
pg_backup_files.o(.text+0x19d): In function `_StartBlob':
: undefined reference to `gzopen64'
pg_backup_files.o(.text+0x280): In function `_StartData':
: undefined reference to `gzopen64'
pg_backup_files.o(.text+0x566): In function `_PrintFileData':
: undefined reference to `gzopen64'
compress_io.o(.text+0x848): In function `cfopen':
: undefined reference to `gzopen64'
collect2: ld returned 1 exit status
make[3]: *** [pg_dump] Error 1

どうも-lzで参照しているlibz.soとかそのあたりが怪しい。探ってみると、当該シンボルは/usr/lib/libz*にはなく、以前に手動でインストールした/usr/local/lib/libz*にあることがわかりました。
故にLDFLAGSを定義して再configure,make。

$ export LDFLAGS=-L/usr/local/lib
$ make distclean
$ ./configure
$ make
# make install

initdbが途中でとまる。

DBを初期化しようとすると、なにやら途中で止まってしまいます。

$ /usr/local/pgsql/bin/initdb --no-locale --encoding=UTF8The 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 C.
The default text search configuration will be set to "english".

creating directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 24MB
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 collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... child process exited with exit code 139
initdb: removing data directory "/usr/local/pgsql/data"

なんだか途中でプロセスが死んでる。segvecでcore dumpですね。
ぐぐると、PostgreSQLが9になったときから同様の障害が出ていることがわかりました。さらに探ると、この記事を発見。
要約すると、

return posix_fadvise(fd, offset, amount, POSIX_FADV_DONTNEED);

で落ちてる。posix_fadvise()があるけど、使うとコアダンプするような妙なバージョンのLinuxを使ってるとそうなるよ。
src/include/pg_config_manual.hの

#define USE_POSIX_FADVISE

コメントアウトすると幸せになれるかも

とのこと。やってみると、ちゃんと初期化できました。ありがたい。