Redrock Postgres Documentation
Home Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

DEB Packages Installation

DEB is a package format that was first developed and distributed by Debian Linux and widely used in Debian Linux distributions and their derivatives, such as Ubuntu Linux. Redrock Postgres provides packages in DEB format that you can download and install on Debian and Ubuntu.

Install Packages

Prerequisite

Log in to the host with your root account, and run the following commands to query installed packages, make sure none postgresql related packages already installed:

# dpkg-query -l | grep postgresql
# dpkg-query -l | grep libpq5

Install Redrock Postgres

Download the DEB Packages for Linux, and run the following commands to install:

# tar xf redrock-<version>.linux.x86_64-deb.tar.gz
# cd redrock-<version>.linux.amd64-deb
# dpkg -i redrock-libs_<version>_amd64.deb
# dpkg -i redrock-client_<version>_amd64.deb
# dpkg -i redrock-server_<version>_amd64.deb

In the commands above, the value of version represents the version of Redrock Postgres, e.g., 2.2-1

Other packages can be installed according to your needs.

DEB Packages

Table 1. Redrock Postgres DEB Packages

Package Name Summary
redrock-client Key clients and libraries, and documentation
redrock-server Server executables and data files
redrock-libs Client shared libraries
redrock-docs Extra documentation, such as the tutorial files
redrock-contrib The contrib source tree, as well as selected binaries
redrock-plscheme PL/Scheme procedural language

Installation Layout

A standard installation of Redrock Postgres using the DEB packages result in files and resources created under the system directories, shown in the following table.

Table 2. Redrock Postgres Installation Layout

Files or Resources Location
Executables /usr/pgsql-12/bin
Libraries /usr/pgsql-12/lib
Server and contrib documentation /usr/pgsql-12/doc
Data /var/lib/pgsql/12/data
Templates and other shared data /usr/pgsql-12/share

The installation also creates a user named postgres and a group named postgres on the system.

Post-installation commands

After installing the packages, a database needs to be initialized and configured.

Data Directory

The PostgreSQL data directory contains all of the data files for the database. The variable PGDATA is used to reference this directory.

The default data directory is /var/lib/pgsql/12/data

Change Data Directory

If you do not want to use the default data directory, you can go to a custom mount point (eg: /u01) and create a folder pgdata with postgres permissions:

# cd /u01
# mkdir pgdata
# chown postgres:postgres pgdata

Then, edit the postgresql service:

# systemctl edit postgresql.service

Go to the custom mount point that has the majority of the disk space, copy and paste the following into that file:

[Service]
Environment=PGDATA=/u01/pgdata

Initialize

The first command (only needed once) is to initialize the database in PGDATA.

# /usr/pgsql-12/bin/postgresql-setup initdb

Startup

If you want PostgreSQL to start automatically when the OS starts, do the following:

# systemctl enable postgresql.service

Control service

To control the database service, use:

# systemctl <command> postgresql.service

where command can be:

  • enable : enable automatical start
  • start : start the database
  • stop : stop the database
  • restart : stop/start the database; used to read changes to core configuration files
  • reload : reload configuration files while keeping database running

E.g. to start database service, use:

# systemctl start postgresql.service

After installation

Modify the pg_hba.conf file in data directory to define what authentication policy should be used from all networks to the PostgreSQL server and modify the IPv4 network access control policy (change from localhost to accept all incoming requests). Find the lines below:

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

And change it to:

# IPv4 local connections:
host    all             all             0.0.0.0/0            md5

Modify the postgresql.conf file in data directory to allow connections from all hosts by uncommenting the following line and adding an * instead of localhost:

listen_addresses = '*'

Restart the database service to reload configurations:

# systemctl restart postgresql.service

In a production environment, you should also set up TLS-secured communication, and you should consider setting up data replication or snapshot-based backups. Consult the PostgreSQL online manual for these settings.