ドルヲタ系インフラエンジニア じーふーの備忘録

クラウドをメインに扱うインフラエンジニアが書くメモやら雑感、たまにドルヲタ的活動記録残します。最近の推しはAzureのData Factory(V2)です。

【postgrsql】 ソースからのインストール & configureオプションメモ

環境

postgresql 9.3.5 CentOS 6.5(64bit)

メモ

インストールの流れ確認

./postgresql-9.3.5/INSTALLファイルを確認。

./configure
gmake
su
gmake 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
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test

必要パッケージ

./configure 実行時に下記パッケージがインストールされていないとエラーになります。
対処方法を列挙します。

readline-devel

zlib-devel

  • zlib-devel インストール
    sudo yum -y install zlib-devel
  • --without-zlib オプションを付けて ./configure 実行

    Zlibライブラリの使用を抑制します。 これは、pg_dumpとpg_restoreにおける圧縮アーカイブのサポートを無効にします。 このオプションは、このライブラリが利用できないごく少数のシステム向けだけのものです。
    引用元: https://www.postgresql.jp/document/9.3/html/install-procedure.html

openssl-devel

--with-opensslオプション指定でconfigure実行時、このパッケージが求められます。

checking for CRYPTO_new_ex_data in -lcrypto... no
configure: error: library 'crypto' is required for OpenSSL
  • openssl-devel インストール sudo yum -y install zlib-devel

    SSL(暗号化)接続のサポートを有効にして構築します。 これには、OpenSSLパッケージがインストールされていなければなりません。 configureは、処理を進める前にOpenSSLのインストールを確認するために、必要なヘッダファイルとライブラリを検査します。 引用元: https://www.postgresql.jp/document/9.3/html/install-procedure.html

PostgreSQLデバッグするには

--enable-debugオプションを付けて./configure 実行。

参考:

PostgreSQL の構造とソースツリー(3) — Let's Postgres

configureオプション

詳細は./postgresql-9.3.5/INSTALLファイルを確認した方がいいと思いますが、各オプションの簡易的な説明確認のため、./configure --help出力結果を記載しておきます。

[vagrant@vagrant-centos65 postgresql-9.3.5]$ ./configure --help
`configure' configures PostgreSQL 9.3.5 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local/pgsql]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/pgsql/bin', `/usr/local/pgsql/lib' etc.  You can specify
an installation prefix other than `/usr/local/pgsql' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/postgresql]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --disable-integer-datetimes
                          disable 64-bit integer date/time support
  --enable-nls[=LANGUAGES]
                          enable Native Language Support
  --disable-rpath         do not embed shared library search path in
                          executables
  --disable-spinlocks     do not use spinlocks
  --enable-debug          build with debugging symbols (-g)
  --enable-profiling      build with profiling enabled
  --enable-coverage       build with coverage testing instrumentation
  --enable-dtrace         build with DTrace support
  --enable-depend         turn on automatic dependency tracking
  --enable-cassert        enable assertion checks (for debugging)
  --disable-thread-safety disable thread-safety in client libraries
  --disable-largefile     omit support for large files
  --disable-float4-byval  disable float4 passed by value
  --disable-float8-byval  disable float8 passed by value

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-template=NAME    override operating system template
  --with-includes=DIRS    look for additional header files in DIRS
  --with-libraries=DIRS   look for additional libraries in DIRS
  --with-libs=DIRS        alternative spelling of --with-libraries
  --with-pgport=PORTNUM   set default port number [5432]
  --with-blocksize=BLOCKSIZE
                          set table block size in kB [8]
  --with-segsize=SEGSIZE  set table segment size in GB [1]
  --with-wal-blocksize=BLOCKSIZE
                          set WAL block size in kB [8]
  --with-wal-segsize=SEGSIZE
                          set WAL segment size in MB [16]
  --with-CC=CMD           set compiler (deprecated)
  --with-tcl              build Tcl modules (PL/Tcl)
  --with-tclconfig=DIR    tclConfig.sh is in DIR
  --with-perl             build Perl modules (PL/Perl)
  --with-python           build Python modules (PL/Python)
  --with-gssapi           build with GSSAPI support
  --with-krb5             build with Kerberos 5 support
  --with-krb-srvnam=NAME  default service principal name in Kerberos
                          [postgres]
  --with-pam              build with PAM support
  --with-ldap             build with LDAP support
  --with-bonjour          build with Bonjour support
  --with-openssl          build with OpenSSL support
  --with-selinux          build with SELinux support
  --without-readline      do not use GNU Readline nor BSD Libedit for editing
  --with-libedit-preferred
                          prefer BSD Libedit over GNU Readline
  --with-ossp-uuid        build contrib/uuid-ossp, requires OSSP UUID library
  --with-libxml           build with XML support
  --with-libxslt          use XSLT support when building contrib/xml2
  --with-system-tzdata=DIR
                          use system time zone data in DIR
  --without-zlib          do not use Zlib
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  LDFLAGS_EX  extra linker flags for linking executables only
  LDFLAGS_SL  extra linker flags for linking shared libraries only
  DOCBOOKSTYLE
              location of DocBook stylesheets

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to <pgsql-bugs@postgresql.org>.
[vagrant@vagrant-centos65 postgresql-9.3.5]$

./configure実行ログからエラー項目抽出

自分の環境でデフォルトで ./configure実行時にログに出力されたエラー項目を抽出してみました。 ヘッダファイルがないよというエラーがいくつかあるのが気になるのですが、詳細不明ですので引き続き調べてみます。

[vagrant@vagrant-centos65 postgresql-9.3.5]$ grep -e "^conftest.c.*error.*" ./config.log
conftest.c:22: error: 'choke' undeclared (first use in this function)
conftest.c:22: error: (Each undeclared identifier is reported only once
conftest.c:22: error: for each function it appears in.)
conftest.c:22: error: expected ';' before 'me'
conftest.c:22: error: 'choke' undeclared (first use in this function)
conftest.c:22: error: (Each undeclared identifier is reported only once
conftest.c:22: error: for each function it appears in.)
conftest.c:22: error: expected ';' before 'me'
conftest.c:17:28: error: ac_nonexistent.h: No such file or directory
conftest.c:17:28: error: ac_nonexistent.h: No such file or directory
conftest.c:67:17: error: dld.h: No such file or directory
conftest.c:34:17: error: dld.h: No such file or directory
conftest.c:67:22: error: fp_class.h: No such file or directory
conftest.c:34:22: error: fp_class.h: No such file or directory
conftest.c:68:20: error: ieeefp.h: No such file or directory
conftest.c:35:20: error: ieeefp.h: No such file or directory
conftest.c:75:23: error: sys/pstat.h: No such file or directory
conftest.c:42:23: error: sys/pstat.h: No such file or directory
conftest.c:80:24: error: sys/sockio.h: No such file or directory
conftest.c:47:24: error: sys/sockio.h: No such file or directory
conftest.c:80:21: error: sys/tas.h: No such file or directory
conftest.c:47:21: error: sys/tas.h: No such file or directory
conftest.c:83:19: error: ucred.h: No such file or directory
conftest.c:50:19: error: ucred.h: No such file or directory
conftest.c:90:23: error: sys/ucred.h: No such file or directory
conftest.c:59: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'a'
conftest.c:65: error: 'not' undeclared (first use in this function)
conftest.c:65: error: (Each undeclared identifier is reported only once
conftest.c:65: error: for each function it appears in.)
conftest.c:65: error: expected ';' before 'big'
conftest.c:76: error: invalid application of 'sizeof' to incomplete type 'union semun'
conftest.c:78: error: expected expression before ')' token
conftest.c:79: error: expected expression before ')' token
conftest.c:82: error: 'struct sockaddr_storage' has no member named '__ss_family'
conftest.c:82: error: 'struct sockaddr_storage' has no member named '__ss_family'
conftest.c:82: error: 'struct sockaddr_storage' has no member named 'ss_len'
conftest.c:82: error: 'struct sockaddr_storage' has no member named 'ss_len'
conftest.c:82: error: 'struct sockaddr_storage' has no member named '__ss_len'
conftest.c:82: error: 'struct sockaddr_storage' has no member named '__ss_len'
conftest.c:82: error: 'struct sockaddr' has no member named 'sa_len'
conftest.c:82: error: 'struct sockaddr' has no member named 'sa_len'
conftest.c:80: error: expected expression before ')' token
conftest.c:109: error: expected expression before ')' token
conftest.c:110: error: expected expression before ')' token
conftest.c:86: error: invalid application of 'sizeof' to incomplete type 'struct cmsgcred'
conftest.c:84: error: expected expression before ')' token
conftest.c:83: error: expected expression before ')' token
conftest.c:86: error: conflicting types for 'accept'
conftest.c:86: error: conflicting types for 'accept'
conftest.c:142: error: 'strlcat' undeclared (first use in this function)
conftest.c:142: error: (Each undeclared identifier is reported only once
conftest.c:142: error: for each function it appears in.)
conftest.c:143: error: 'strlcpy' undeclared (first use in this function)
conftest.c:143: error: (Each undeclared identifier is reported only once
conftest.c:143: error: for each function it appears in.)
conftest.c:113: error: 'F_FULLFSYNC' undeclared (first use in this function)
conftest.c:113: error: (Each undeclared identifier is reported only once
conftest.c:113: error: for each function it appears in.)
conftest.c:146: error: expected expression before ')' token
conftest.c:109:29: error: machine/vmparam.h: No such file or directory
conftest.c:110:22: error: sys/exec.h: No such file or directory
conftest.c:115: error: 'PS_STRINGS' undeclared (first use in this function)
conftest.c:115: error: (Each undeclared identifier is reported only once
conftest.c:115: error: for each function it appears in.)
conftest.c:147: error: conflicting types for 'strerror_r'
conftest.c:163: error: 'int8' undeclared (first use in this function)
conftest.c:163: error: (Each undeclared identifier is reported only once
conftest.c:163: error: for each function it appears in.)
conftest.c:163: error: 'uint8' undeclared (first use in this function)
conftest.c:163: error: (Each undeclared identifier is reported only once
conftest.c:163: error: for each function it appears in.)
conftest.c:163: error: 'int64' undeclared (first use in this function)
conftest.c:163: error: (Each undeclared identifier is reported only once
conftest.c:163: error: for each function it appears in.)
conftest.c:163: error: 'uint64' undeclared (first use in this function)
conftest.c:163: error: (Each undeclared identifier is reported only once
conftest.c:163: error: for each function it appears in.)
conftest.c:163: error: expected expression before ')' token
[vagrant@vagrant-centos65 postgresql-9.3.5]$