RPM Packages Installation
RPM is a package format that was first developed and distributed by Red Hat and widely used in Red Hat Linux distributions and their derivatives, such as CentOS Linux, Oracle Linux. Redrock Postgres provides packages in RPM format that you can download and install on Red Hat and CentOS.
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:
# rpm -qa | grep postgresql
Download the RPM Packages for Linux, and run the following commands to install:
# tar xf redrock-<version>.linux.x86_64-rpm.tar.gz
# cd redrock-<version>.linux.x86_64-rpm
# rpm -ivh redrock-libs-<version>.x86_64.rpm
# rpm -ivh redrock-client-<version>.x86_64.rpm
# rpm -ivh redrock-server-<version>.x86_64.rpm
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.
Table 1. Redrock Postgres RPM 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 |
A standard installation of Redrock Postgres using the RPM 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.
After installing the packages, a database needs to be initialized and configured.
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
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
The first command (only needed once) is to initialize the database in PGDATA
.
# /usr/pgsql-12/bin/postgresql-setup initdb
If you want PostgreSQL to start automatically when the OS starts, do the following:
# systemctl enable postgresql.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
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.