PostgreSQL-9.6.4

PostgreSQL の概要

PostgreSQL は先進的なオブジェクトリレーショナルデータベース管理システム (object-relational database management system; ORDBMS) です。 これは Berkeley Postgres データベース管理システムからの派生です。

本パッケージは LFS-8.0 において正しくビルドでき動作することが確認されています。

パッケージ情報

PostgreSQL の依存パッケージ

任意

Python-2.7.13, Tcl-8.6.7, OpenSSL-1.1.0f, libxml2-2.9.4, libxslt-1.1.29, OpenLDAP-2.4.45, Linux-PAM-1.3.0, MIT Kerberos V5-1.15.1, Bonjour

任意 (ドキュメント再生成時)

docbook-4.5, docbook-dsssl-1.79, OpenJade-1.3.2, SGMLSpm-1.1

ユーザー情報: http://wiki.linuxfromscratch.org/blfs/wiki/postgresql

PostgreSQL のインストール

PostgreSQL をビルドします。

sed -i '/DEFAULT_PGSOCKET_DIR/s@/tmp@/run/postgresql@' src/include/pg_config_manual.h &&

./configure --prefix=/usr          \
            --enable-thread-safety \
            --docdir=/usr/share/doc/postgresql-9.6.4 &&
make

There are a number of programs in the contrib/ directory. If you are going to run this installation as a server and wish to build some of them, enter make -C contrib or make -C contrib/<SUBDIR-NAME> for each subdirectory.

Tests must be run as an unprivileged user because they need to start a temporary server and this is prevented as the root user. For the same reason, you need to stop all PostgreSQL servers if any are running. If a previous version of PostgreSQL is installed, it may be necessary to use --disable-rpath with configure to avoid failures, but installing the binaries created using this switch is not recommended. To test the results, issue: make check.

root ユーザーになって以下を実行します。

make install      &&
make install-docs

If you made any of the contrib/ programs, as the root user:

make -C contrib/<SUBDIR-NAME> install

If you only intend to use PostgreSQL as a client to connect to a server on another machine, your installation is complete and you should not run the remaining commands.

root ユーザーとなり、以下のコマンドを実行してデータベースクラスターを初期化します。

install -v -dm700 /srv/pgsql/data &&
install -v -dm755 /run/postgresql &&

groupadd -g 41 postgres &&
useradd -c "PostgreSQL Server" -g postgres -d /srv/pgsql/data \
        -u 41 postgres &&

chown -Rv postgres:postgres /srv/pgsql /run/postgresql

Now, initialize the database at the root user:

su - postgres -c '/usr/bin/initdb -D /srv/pgsql/data'

再度 root ユーザーとなり、以下のコマンドを実行してデータベースサーバーを起動します。

su - postgres -c '/usr/bin/postgres -D /srv/pgsql/data > \
                  /srv/pgsql/data/logfile 2>&1 &'

root ユーザーのまま、データベースを生成しインストール結果をチェックします。

su - postgres -c '/usr/bin/createdb test' &&
echo "create table t1 ( name varchar(20), state_province varchar(20) );" \
    | (su - postgres -c '/usr/bin/psql test ') &&
echo "insert into t1 values ('Billy', 'NewYork');" \
    | (su - postgres -c '/usr/bin/psql test ') &&
echo "insert into t1 values ('Evanidus', 'Quebec');" \
    | (su - postgres -c '/usr/bin/psql test ') &&
echo "insert into t1 values ('Jesse', 'Ontario');" \
    | (su - postgres -c '/usr/bin/psql test ') &&
echo "select * from t1;" | (su - postgres -c '/usr/bin/psql test')

To shut down the server, as root:

su - postgres -c "/usr/bin/pg_ctl stop -D /srv/pgsql/data"

コマンド説明

sed -i ...: This sed changes server socket location from /tmp to /run/postgresql.

--docdir=/usr/share/doc/postgresql-9.6.4: 本スイッチは、ドキュメントをバージョン番号つきディレクトリにインストールします。

--enable-thread-safety: This switch makes the client libraries thread-safe by allowing concurrent threads in libpq and ECPG programs to safely control their private connection handles.

--with-openssl: builds the package with support for OpenSSL encrypted connections.

--with-perl: builds the PL/Perl server-side language.

--with-python: builds the PL/Python server-side language.

--with-tcl: builds the PL/Tcl server-side language.

groupadd ...; useradd ...: These commands add an unprivileged user and group to run the database server.

createdb test; create table t1; insert into t1 values...; select * from t1: Create a database, add a table to it, insert some rows into the table and select them to verify that the installation is working properly.

PostgreSQL の設定

設定ファイル

$PGDATA/pg_ident.con, $PGDATA/pg_hba.conf and $PGDATA/postgresql.conf

The PGDATA environment variable is used to distinguish database clusters from one another by setting it to the value of the directory which contains the cluster desired. The three configuration files exist in every PGDATA/ directory. Details on the format of the files and the options that can be set in each can be found in file:///usr/share/doc/postgresql-9.6.4/html/index.html.

ブートスクリプト

blfs-bootscripts-20170731 パッケージに含まれる 初期化スクリプト /etc/rc.d/init.d/postgresql をインストールします。

make install-postgresql

パッケージ構成

インストールプログラム: clusterdb, createdb, createlang, createuser, dropdb, droplang, dropuser, ecpg, initdb, pg_archivecleanup, pg_basebackup, pg_config, pg_controldata, pg_ctl, pg_dump, pg_dumpall, pg_isready, pg_receivexlog, pg_recvlogical, pg_resetxlog, pg_restore, pg_rewind, pg_test_fsync, pg_test_timing, pg_upgrade, pg_xlogdump, pgbench, pltcl_delmod, pltcl_listmod, pltcl_loadmod, postgres, postmaster (deprecated), psql, reindexdb, vacuumdb, and optionally (in contrib/) oid2name, pg_standby, vacuumlo, and many others
インストールライブラリ: libecpg.{so,a}, libecpg_compat.{so,a}, libpgcommon.a, libpgport.a, libpgtypes.{so,a}, libpq.{so,a}, various charset modules, and optionally programming language modules under /usr/lib/postgresql
インストールディレクトリ: /usr/include/{libpq,postgresql}, /usr/lib/postgresql, /usr/share/{doc/postgresql-9.6.4,postgresql}, /srv/pgsql

概略説明

clusterdb

is a utility for reclustering tables in a PostgreSQL database.

createdb

creates a new PostgreSQL database.

createlang

defines a new PostgreSQL procedural language.

createuser

defines a new PostgreSQL user account.

dropdb

removes a PostgreSQL database.

droplang

removes a PostgreSQL procedural language.

dropuser

removes a PostgreSQL user account.

ecpg

is the embedded SQL preprocessor.

initdb

creates a new database cluster.

oid2name

resolves OIDs (Object IDs) and file nodes in a PostgreSQL data directory.

pg_archivecleanup

cleans up PostgreSQL WAL (write-ahead log) archive files.

pg_basebackup

takes base backups of a running PostgreSQL cluster.

pg_config

retrieves PostgreSQL version information.

pg_controldata

returns information initialized during initdb, such as the catalog version and server locale.

pg_ctl

controls stopping and starting the database server.

pg_dump

dumps database data and metadata into scripts which are used to recreate the database.

pg_dumpall

recursively calls pg_dump for each database in a cluster.

pg_isready

check the connection status of a PostgreSQL server.

pg_receivexlog

is used to stream transaction log from a running PostgreSQL cluster.

pg_recvlogical

controls PostgreSQL logical decoding streams.

pg_resetxlog

clears the write-ahead log and optionally resets some fields in the pg_control file.

pg_restore

creates databases from dump files created by pg_dump.

pg_rewind

synchronizes a PostgreSQL data directory with another data directory that was forked from the first one.

pg_standby

supports the creation of a PostgreSQL warm standby server.

pg_test_fsync

determine fastest wal_sync method for PostgreSQL.

pg_test_timing

measure timing overhead.

pg_upgrade

upgrade a PostgreSQL server instance.

pg_xlogdump

display a human-readable rendering of the write-ahead log of a PostgreSQL database cluster.

pgbench

run a benchmark test on PostgreSQL.

pltcl_delmod

is a support script used to delete a module from a PL/Tcl table. The command requires the Pgtcl package to be installed also.

pltcl_listmod

is a support script used to list the modules in a PL/Tcl table. The command requires the Pgtcl package to be installed also.

pltcl_loadmod

is a support script used to load a module into a PL/Tcl table. The command requires the Pgtcl package to be installed also.

postgres

is the PostgreSQL database server.

postmaster

(deprecated, a symlink to postgres) is a multi-user database daemon.

psql

is a console based database shell.

reindexdb

is a utility for rebuilding indexes in a database.

vacuumdb

compacts databases and generates statistics for the query analyzer.

vacuumlo

remove orphaned large objects from a PostgreSQL database.

libecpg.{so,a}

contains functions to support embedded SQL in C programs.

libecpg_compat.{so,a}

is the ecpg compatibility library.

libgport.a

is the port-specific subsystem of the Postgres backend.

libpgtypes.{so,a}

contains functions for dealing with Postgres data types.

libpq.{so,a}

is the C programmer's API to Postgres.

最終更新日: 2017-08-17 05:38:22 +0900