%general-entities; ]> $LastChangedBy$ $Date$ PostgreSQL-&postgresql-version; PostgreSQL Introduction to PostgreSQL PostgreSQL is an advanced object-relational database management system (ORDBMS), derived from the Berkeley Postgres database management system. &lfs84_checked; Package Information Download (HTTP): Download (FTP): Download MD5 sum: &postgresql-md5sum; Download size: &postgresql-size; Estimated disk space required: &postgresql-buildsize; Estimated build time: &postgresql-time; PostgreSQL Dependencies Optional , , , , , , and Bonjour Optional (To Regenerate Documentation) , , , , , and User Notes: Installation of PostgreSQL For enhanced security, it is better to have a dedicated group and user for running the PostgreSQL server. First, issue as the root user: groupadd -g 41 postgres && useradd -c "PostgreSQL Server" -g postgres -d /srv/pgsql/data \ -u 41 postgres There are several configuration items that add additional functionality with optional packages to PostgreSQL. Use ./configure --help to see a list. Install PostgreSQL with the following commands: 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-&postgresql-version; && 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. Now, as the root user: 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. Initialize a database cluster with the following commands issued by the root user: install -v -dm700 /srv/pgsql/data && install -v -dm755 /run/postgresql && chown -Rv postgres:postgres /srv/pgsql /run/postgresql Now, initialize the database as the root user: su - postgres -c '/usr/bin/initdb -D /srv/pgsql/data' Command Explanations sed -i ...: This sed changes server socket location from /tmp to /run/postgresql. --docdir=/usr/share/doc/postgresql-&postgresql-version;: This switch puts the documentation in a versioned directory. --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. : builds the package with support for OpenSSL encrypted connections. : builds the PL/Perl server-side language. : builds the PL/Python server-side language. Add PYTHON=/usr/bin/python2 for Python2 support, otherwise Python3 is used by default. : builds the PL/Tcl server-side language. Configuring PostgreSQL Config Files $PGDATA/pg_ident.con, $PGDATA/pg_hba.conf and $PGDATA/postgresql.conf $PGDATA/pg_indent.con $PGDATA/pg_hba_conf $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 . <phrase revision="sysv">Boot Script</phrase> <phrase revision="systemd">Systemd Unit</phrase> Install the /etc/rc.d/init.d/postgresql init script postgresql.service unit included in the package. postgresql make install-postgresql Starting the PostgreSQL Server and Creating a Sample Database The database server can be manually started with the following command (as the root user): su - postgres -c '/usr/bin/postgres -D /srv/pgsql/data > \ /srv/pgsql/data/logfile 2>&1 &' If you are scripting this part, you should wait for the server to start before going on, by adding for example sleep 2 after the above command. The instructions below show how to 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. Still as user root, issue: 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') When you are done with testing, you can shut down the server, by issuing as root: su - postgres -c "/usr/bin/pg_ctl stop -D /srv/pgsql/data" Contents Installed Programs Installed Libraries Installed Directories clusterdb, createdb, createuser, dropdb, dropuser, ecpg, initdb, pg_archivecleanup, pg_basebackup, pg_config, pg_controldata, pg_ctl, pg_dump, pg_dumpall, pg_isready, pg_receivewal, pg_recvlogical, pg_resetwval, pg_restore, pg_rewind, pg_test_fsync, pg_test_timing, pg_upgrade, pg_waldump, pgbench, postgres, postmaster (deprecated), psql, reindexdb, vacuumdb, optionally, if Tcl support has been built, pltcl_delmod, pltcl_listmod, pltcl_loadmod, 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-&postgresql-version;,postgresql}, and /srv/pgsql Short Descriptions clusterdb is a utility for reclustering tables in a PostgreSQL database. clusterdb createdb creates a new PostgreSQL database. createdb createuser defines a new PostgreSQL user account. createuser dropdb removes a PostgreSQL database. dropdb dropuser removes a PostgreSQL user account. dropuser ecpg is the embedded SQL preprocessor. ecpg initdb creates a new database cluster. initdb oid2name resolves OIDs (Object IDs) and file nodes in a PostgreSQL data directory. oid2name pg_archivecleanup cleans up PostgreSQL WAL (write-ahead log) archive files. pg_archivecleanup pg_basebackup takes base backups of a running PostgreSQL cluster. pg_basebackup pg_config retrieves PostgreSQL version information. pg_config pg_controldata returns information initialized during initdb, such as the catalog version and server locale. pg_controldata pg_ctl controls stopping and starting the database server. pg_ctl pg_dump dumps database data and metadata into scripts which are used to recreate the database. pg_dump pg_dumpall recursively calls pg_dump for each database in a cluster. pg_dumpall pg_isready check the connection status of a PostgreSQL server. pg_isready pg_receivewal is used to stream write-ahead logs from a PostgreSQL server. pg_receivewal pg_recvlogical controls PostgreSQL logical decoding streams. pg_recvlogical pg_resetwal resets the write-ahead log and other control information of a PostgreSQL database cluseter. pg_resetwal pg_restore creates databases from dump files created by pg_dump. pg_restore pg_rewind synchronizes a PostgreSQL data directory with another data directory that was forked from the first one. pg_rewind pg_standby supports the creation of a PostgreSQL warm standby server. pg_standby pg_test_fsync determine fastest wal_sync method for PostgreSQL. pg_test_fsync pg_test_timing measure timing overhead. pg_test_timing pg_upgrade upgrade a PostgreSQL server instance. pg_upgrade pg_waldump display a human-readable rendering of the write-ahead log of a PostgreSQL database cluster. pg_waldump pgbench run a benchmark test on PostgreSQL. pgbench 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_delmod 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_listmod 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. pltcl_loadmod postgres is the PostgreSQL database server. postgres postmaster (deprecated, a symlink to postgres) is a multi-user database daemon. postmaster psql is a console based database shell. psql reindexdb is a utility for rebuilding indexes in a database. reindexdb vacuumdb compacts databases and generates statistics for the query analyzer. vacuumdb vacuumlo remove orphaned large objects from a PostgreSQL database. vacuumlo libecpg.{so,a} contains functions to support embedded SQL in C programs. libecpg.{so,a} libecpg_compat.{so,a} is the ecpg compatibility library. libecpg_compat.{so,a} libgport.a is the port-specific subsystem of the Postgres backend. libgport.a libpgtypes.{so,a} contains functions for dealing with Postgres data types. libpgtypes.{so,a} libpq.{so,a} is the C programmer's API to Postgres. libpq.{so,a}