PostgreSQL DBA - 9.6 Server Installation
PostgreSQL DBA - 9.6 Server Installation
Install PostgreSQL:
# ls -lrth /usr/lib/systemd/system/postgresql-9.6.service
# ls -lrth /lib/systemd/system/postgresql-9.6.service
# mkdir -p /opt/postgresql/9.6
# chown postgres:postgres /opt/postgresql/9.6
4. Update the postgres service file with the required PGDATA location
# vi /lib/systemd/system/postgresql-9.6.service
firewall-cmd --list-ports
firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --reload
firewall-cmd --list-ports
6. Switch to postgres user and perform initdb (it creates the postgres cluster)
Before you can do anything, you must initialize a database storage area on disk. We call this a database
cluster. (The SQL standard uses the term catalog cluster.) A database cluster is a collection of databases
that is managed by a single instance of a running database server.
In file system terms, a database cluster is a single directory under which all data will be stored. We call
this the data directory or data area. It is completely up to you where you choose to store your data.
There is no default, although locations such as /usr/local/pgsql/data or /var/lib/pgsql/data are
$ /usr/pgsql-9.6/bin/initdb -D /opt/postgresql/9.6/data
Tip: As an alternative to the -D option, you can set the environment variable PGDATA.
Alternatively, you can run initdb via the pg_ctl program like so:
initdb will refuse to run if the data directory exists and already contains files; this is to prevent
accidentally overwriting an existing installation.
Because the data directory contains all the data stored in the database, it is essential that it be secured
from unauthorized access. initdb therefore revokes access permissions from everyone but the
PostgreSQL user.
# su - postgres
$ export PGDATA=/opt/postgresql/9.6/data
$ echo $PGDATA
$ /usr/pgsql-9.6/bin/initdb -D /opt/postgresql/9.6/data
Now we can see the server process and utility process as shown below