This exercise demonstrates the installation and configuration of Postgres database on Linux environment using source tar file.
Step 1 – Download Postgres tar file
Step 2 – Create /database/data directory
Step 3 – untar downloaded file to /database/data
- tar xvfz postgresql-10.0.5.tar.gz

Step 4 – Build Postgres with MAKE command
- $ ./configure –prefix=/database/data


Step 5 – Run Make INSTALL
- MAKE -C configure install

Step 6 – Create new sub directory /database/data/db
Step 7 – Initialize Postgres database
- initdb – D /database/data/db

Step 8 – Verify /database/data/db content

Step 9 – Change the listener address and database port on postgresql.conf configuration file

Step 10 – Verify Postgres database Service Status
- $ ps -ef | grep -i postgres

Step 11 – Customize Postgres database file location
- log to postgres and run SHOW data_directory to identify current location

Step 12 – Change Postgres database files
- Stop postgres service : $ systemctl stop postgres-10
- Change /database/data directory owner with CHMOD
- Change /database/data directory permission to 700 with CHOWN
- Run Synch : sudo rsync -av /var/lib/pgsql/10/data /database/data

Step 13 – Change Postgres configuration file for data location
- sudo nano /var/lib/pgsql/10/data/postgresql.conf

Step 14 – Rename default data folder to backup & archive
- mv /var/lib/pgsql/10/data /var/lib/pgsql/10/10.bak


Step 15 – Change initdb.log file
- /usr/pgsql -10/bin/pg-ctl -D /database/data/data -l logfile
