Disclaimer

Tuesday 27 October 2020

PostgreSQL-11 Text Mode/RUN file Installation

 

PostgreSQL-11 Text Mode/RUN file Installation

To specify that the installer should run in text mode, include the –mode text command line option when invoking the installer. Text-mode installations are useful if you need to install on a remote server using ssh tunneling (and have access to a minimal amount of bandwidth), or if you do not have access to a graphical interface.

In text mode, the installer uses a series of command line questions to establish the configuration parameters. Text-mode installations are valid only on Linux or Mac systems.

You must assume superuser privileges before performing a text-mode installation. At any point during the installation process, you can press Ctrl-C to abort the installation. 

To perform a text-mode installation on a Linux system, navigate to the directory that contains the installation binary file and enter:

Go to the location of PostgreSQL 11 installer(PostgreSQL-11.7-1-linux-x64-installer.run) and run the installer in text mode as below

[root@rac7 PostgreSQL]# ./PostgreSQL-11.7-1-linux-x64-installer.run --mode text

Language Selection
 
Please select the installation language
[1] English - English
[2] French - Français
[3] German - Deutsch
[4] Italian - Italiano
[5] Spanish - Español
Please choose an option [1] : 1
---------------------------------------------------------------------------
Welcome to the PostgreSQL Setup Wizard.
 
---------------------------------------------------------------------------
Please specify the directory where PostgreSQL will be installed.

 

Note: Provide the base directory for installation We have provided “/u02/PostgreSQL/11”

 

Installation Directory [/opt/2ndQuadrant/PostgreSQL]: /u02/PostgreSQL/11

 

----------------------------------------------------------------------------

Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.
 
PostgreSQL 11 : Y (Cannot be edited)
 
OmniDB [y/N] : y
 
pl-languages [y/N] : y
 
Is the selection above correct? [Y/n]: Y
 
---------------------------------------------------------------------------
Data Directory
 
Installer will initialize the PostgreSQL database in this directory. If it
already exists, this directory must be empty.

Note: Provide the data directory location We have  provided /u02/PostgreSQL/11/data

 

PostgreSQL Data Directory [/u02/PostgreSQL/11/11/data]: /u02/PostgreSQL/11/data

 

----------------------------------------------------------------------------

PostgreSQL Port

Note: provide the port number
Specify a listener port for the service. When prompted, enter the Port that the PostgreSQL service will monitor for connections. By default, PostgreSQL chooses the first available port 


The installer will initialize the PostgreSQL database server with this port
(leave as-is if you are unsure what to enter)
 
PostgreSQL Server Port [5433]:
 
---------------------------------------------------------------------------
Postgres User Password

Note: You must provide a password for the database superuser . The specified password must conform to any security policies (minimum length, use of special characters, and so on) in place on the host. After entering a password in the Password field, confirm the password and press Enter to continue.

Please enter the postgres user password :
Re-enter password :
---------------------------------------------------------------------------
Password for Database Superuser
 
Password :
Re-enter password :
---------------------------------------------------------------------------
Installation Summary
 
You are about to install PostgreSQL.
 
Please review the below information:
 

Installation Directory: /u02/PostgreSQL/11

PostgreSQL Data Directory: /u02/PostgreSQL/11/data

PostgreSQL Port: 5433

 

Click next if the information is correct

 

 

 

Press [Enter] to continue:

 

----------------------------------------------------------------------------

Please wait while Setup installs PostgreSQL on your computer.

 

 Installing

 0% ______________ 50% ______________ 100%

 #########################################

 

----------------------------------------------------------------------------

Setup has finished installing PostgreSQL on your computer.

 

Show readme file [Y/n]: Y

 

Readme
Welcome to Postgres Installer by 2ndQuadrant
============================================
 
Postgres Installer is a GUI based, user-friendly installer for PostgreSQL that
is digitally signed and certified by 2ndQuadrant. The installer is currently
available for PostgreSQL versions 9.5, 9.6, 10, 11 and 12. Postgres Installer
has the ability to run in graphical, command line, or quiet installation modes
for  Windows, macOS and Linux.
 
 
Features
========
 
Postgres Installer comes with features listed below. In addition to these, many
are in pipeline and will be available in upcoming releases.
 
. OmniDB
. PostGIS
. OpenSSL
. Python3
. Zlib
. LDAP
. Kerberos
Press [Enter] to continue:
. ICU
. Perl
. Tcl
. LLVM
 
For more details please visit.
https://www.2ndquadrant.com/en/resources/postgresql-installer-2ndquadrant/
 
 
Controlling PostgreSQL service
==============================
 
Once installer has completed installation successfully, following information
should hold true for your platform.
 
. Service name: postgresql-2ndQ-11
 
Open terminal and type following commands
 
. Status: sudo service "postgresql-2ndQ-11" status
. Start:  sudo service "postgresql-2ndQ-11" start
. Stop:   sudo service "postgresql-2ndQ-11" stop
 
Press [Enter] to continue:
 
Connect to PostgreSQL via psql
==============================
 
. Open terminal
. Change directory: cd  /u02/PostgreSQL/11/11/bin
. Connect with PostgreSQL by via psql client: ./psql -U postgres -d postgres -p
5433
 
Type in your 'postgres' superuser password. This should be the same as supplied
during installation on Database Superuser Password screen
Once connected, you can key in SQL queries as you like. Please refer to psql
documentation for help on using psql client.
 
https://www.postgresql.org/docs/9.4/static/app-psql.html
 
 
Connect to PostgreSQL via OmniDB
================================
 
OmniDB is an interactive and powerful, yet lightweight, browser-based database
management tool. OmniDB allows users to manage multiple databases in a unified
workspace with a user-friendly and fast-performing interface.  Despite its light
Press [Enter] to continue:
design, OmniDB is a reliable and comprehensive web tool with many facilitating
characteristics to easily add, edit and manage multiple databases
 
Usage instructions
==================
 
Open terminal and follow these steps
 
. Change directory: cd /u02/PostgreSQL/11/OmniDB
. Start OmniDB server: ./omnidb-server
. Port number will be shown inside the terminal once server is started
. Open your favorite browser and type in following URL to connect with OmniDB:
http://localhost:Port_Number --default OmniDB port is 8000
. Once you can see the OmniDB login screen please enter following credentials
  User name = admin
  Password =  admin
 
For detailed instructions on usage please visit:
https://omnidb.org/en/documentation-en/
 
For more OmniDB details and features please visit
. https://www.2ndquadrant.com/en/resources/omnidb/
. https://www.omnidb.org/en/
Press [Enter] to continue:
 
 
Getting started with PostGIS
============================
 
PostGIS is a spatial database extender for PostgreSQL object-relational
database. It add support for geographic objects allowing location queries to be
run in SQL.
 
NOTE: PostGIS is not supported for PostgreSQL 12 yet
 
Some of the extensions required for PostGIS.
 
. CREATE EXTENSION postgis;
. CREATE EXTENSION fuzzystrmatch; -- needed for postgis_tiger_geocoder
                                  -- optional used by postgis_tiger_geocoder,
                                  -- or can be used standalone
. CREATE EXTENSION postgis_tiger_geocoder;
. CREATE EXTENSION postgis_topology;
 
NOTE: GDAL DATA will need to be configured manually based on where you have
placed it. Path to default GDAL DATA directory is listed below:
 
Press [Enter] to continue:
. /u02/PostgreSQL/11/11/gdal
 
Set PostGIS DATA directory path by running following command inside PSQL.
 
. set postgis.gdal_datapath = '/u02/PostgreSQL/11/11/gdal';
 
Please refer to PostGIS documentation here
(https://postgis.net/docs/postgis_gdal_datapath.html) on how you can configure
GDAL DATA directory for your platform.
 
Please visit PostGIS official website for more details about PostGIS.
https://postgis.net/
 
 
Introduction to ICU
===================
ICU stands for International Components for Unicode. It provide the ability to
handle postgres database and run queries on your local language i,e.
 
. English
. French
. German
. Italian
Press [Enter] to continue:
 
And many more of course. You can run query below to see which languages are
supported
 
NOTE: Database encoding needs to be set before using ICU.
 
. create database db_name ENCODING 'UTF-8';
. select * from pg_collation;
 
NOTE: ICU is not supported on PostgreSQL 9.5 and 9.6
 
Introduction to Perl
====================
PL/Perl (Procedural Language/Perl) is a procedural language supported by the
PostgreSQL RDBMS.
PL/Perl, as an imperative programming language, allows more control than the
relational algebra of SQL. Programs created in the PL/Perl language are called
functions and can use most of the features that the Perl programming language
provides,
 
Setting up Perl
===============
. Open terminal
Press [Enter] to continue:
. Connect to 'psql'
. Run query 'CREATE LANGUAGE plperl;'
 
And you are done now you can create any function that you want
 
 
Introduction to Tcl
===================
PL/Tcl is a loadable procedural language for the PostgreSQL database system that
enables the Tcl language to be used to write functions and trigger procedures.
 
Setting up Tcl
==============
. Open terminal
. Connect to 'psql'
. Run query 'CREATE LANGUAGE pltcl;'
 
 
LLVM
====
Just-in-Time (JIT) compilation is the process of turning some form of
interpreted program evaluation into a native program, LLVM has support for
optimizing generated code. Some of the optimizations are cheap enough to be
Press [Enter] to continue:
performed whenever JIT is used, while others are only beneficial for
longer-running queries. long running queries that are CPU bound will benefit
from JIT compilation
 
NOTE: LLVM is only avialable in PostgreSQL-11 and above
 
. create table t1 (id serial);
. insert INTO t1 (id) select * from generate_series(1, 10000000);
. set jit = 'on'; set jit_above_cost = 10; set jit_inline_above_cost = 10; set
jit_optimize_above_cost = 10;
. explain analyze select count(*) from t1; -- See JIT section for results
. explain (analyze, verbose, buffers) select count(*) from t1; -- See JIT
section for results
 
 
Bug Reports and Feedback
========================
For bug reports and  feedback, please contact via pginstaller@2ndquadrant.com or
use our contact form on our Postgres Installer page:
https://www.2ndquadrant.com/en/resources/postgresql-installer-2ndquadrant/
 
 
Contact Us
Press [Enter] to continue:
Press [Enter] to continue:
==========
 
2ndQuadrant Ltd
 
7200 The Quorum
Oxford Business Park North
Oxford, OX4 2JZ
United Kingdom
 
Phone:   +44 870 766 7756
Fax:     +44 870 838 1077
Email:   info@2ndQuadrant.com
 
For detailed queries please visit our website: https://2ndQuadrant.com
 
 
 
Press [Enter] to continue:
[root@rac7 PostgreSQL]#

[root@rac7 PostgreSQL]#

[root@rac7 PostgreSQL]#

[root@rac7 PostgreSQL]#

 

After the installation, you need to set environment variables. There is a pg_env.sh file in which all environment variables are exported in /u02/PostgreSQL/11 (which base installation directory). You can run that file to set env settings Or you can set it in .bash_profile where every postgres user login env file gets run.

Open the bash file $vi .bash_profile   and Enter the below line:


source /u02/PostgreSQL/11/pg_env.sh

 

=========================================================================
Another Example:-
=========================================================================

[root@rac5 ~]# adduser postgres
[root@rac5 ~]#
[root@rac5 ~]# passwd postgres
Changing password for user postgres.
New password:
BAD PASSWORD: The password contains the user name in some form
Retype new password:
passwd: all authentication tokens updated successfully.

[root@rac5 ~]# cd /u01
[root@rac5 u01]# mkdir PostgreSQL
[root@rac5 u01]# cd PostgreSQL/
[root@rac5 PostgreSQL]# pwd
/u01/PostgreSQL
[root@rac5 PostgreSQL]#
[root@rac5 PostgreSQL]# chown -R postgres:postgres /u01/PostgreSQL



[root@rac5 Desktop]# ./PostgreSQL-10.9-1-linux-x64-installer.run --mode text
Language Selection

Please select the installation language
[1] English - English
[2] French - Français
[3] German - Deutsch
[4] Italian - Italiano
[5] Spanish - Español
Please choose an u01ion [1] : 1
----------------------------------------------------------------------------
Welcome to the PostgreSQL Setup Wizard.

----------------------------------------------------------------------------
Please specify the directory where PostgreSQL will be installed.

Installation Directory [/u01/2ndQuadrant/PostgreSQL]: /u01/PostgreSQL

----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.

PostgreSQL 10 : Y (Cannot be edited)

OmniDB [y/N] : N

pl-languages [y/N] : y

Is the selection above correct? [Y/n]: Y

----------------------------------------------------------------------------
Data Directory

Installer will initialize the PostgreSQL database in this directory. If it
already exists, this directory must be empty.

PostgreSQL Data Directory [/u01/PostgreSQL/10/data]:

----------------------------------------------------------------------------
PostgreSQL Port

The installer will initialize the PostgreSQL database server with this port
(leave as-is if you are unsure what to enter)

PostgreSQL Server Port [5432]:

----------------------------------------------------------------------------
Postgres User Password

Please enter the postgres user password :
Re-enter password :
----------------------------------------------------------------------------
Password for Database Superuser

Password :
Re-enter password :
----------------------------------------------------------------------------
Installation Summary

You are about to install PostgreSQL.

Please review the below information:

Installation Directory: /u01/PostgreSQL
PostgreSQL Data Directory: /u01/PostgreSQL/10/data
PostgreSQL Port: 5432

Click next if the information is correct



Press [Enter] to continue:

----------------------------------------------------------------------------
Please wait while Setup installs PostgreSQL on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing PostgreSQL on your computer.


Now check the postgres service 

[root@rac5 Desktop]# ps -ef | grep postgres
postgres  24319      1  0 00:33 ?        00:00:00 /u01/PostgreSQL/10/bin/postgres -D /u01/PostgreSQL/10/data -p 5432
postgres  24321  24319  0 00:33 ?        00:00:00 postgres: checkpointer process
postgres  24322  24319  0 00:33 ?        00:00:00 postgres: writer process
postgres  24323  24319  0 00:33 ?        00:00:00 postgres: wal writer process
postgres  24324  24319  0 00:33 ?        00:00:00 postgres: autovacuum launcher process
postgres  24325  24319  0 00:33 ?        00:00:00 postgres: stats collector process
postgres  24326  24319  0 00:33 ?        00:00:00 postgres: bgworker: logical replication launcher
root      24374  17286  0 00:34 pts/0    00:00:00 grep --color=auto postgres
[root@rac5 Desktop]#




==============SETTING HOME PATH & ENV PATH=====================

[root@postgres Desktop]# vi /etc/passwd

postgres:x:26:26:PostgreSQL Server:/u01/PostgreSQL/10:/bin/bash

:wq


[root@postgres Desktop]# cd /u01/PostgreSQL/10/

[root@postgres 10]# cp /root/.bash_profile .

[root@postgres 10]# cat pg_env.sh 
#!/bin/sh
# The script sets environment variables helpful for PostgreSQL

export PATH=/u01/PostgreSQL/10/bin:$PATH
export PGDATA=/u01/PostgreSQL/10/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=/u01/PostgreSQL/10/share/locale
export MANPATH=$MANPATH:/u01/PostgreSQL/10/share/man



# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
export PATH=/u01/PostgreSQL/10/bin:$PATH
export PGDATA=/u01/PostgreSQL/10/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=/u01/PostgreSQL/10/share/locale
export MANPATH=$MANPATH:/u01/PostgreSQL/10/share/man

:wq



psql -p 5432 -U postgres -d postgres



***********************************************************************************



[root@rac5 ~]# mkdir -p /data1/samik_postgres
[root@rac5 ~]#
[root@rac5 ~]# chown -R postgres:postgres /data1/samik_postgres
[root@rac5 ~]#
[root@rac5 ~]#
[root@rac5 ~]# su - postgres
Last login: Wed Aug  7 23:15:40 IST 2019 on pts/2
-bash-4.2$
-bash-4.2$
-bash-4.2$ initdb -D /data1/samik_postgres ---------------------------------------------------------to start the service
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /data1/samik_postgres ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default timezone ... Asia/Kolkata
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the u01ion -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /data1/samik_postgres -l logfile start






Monday 26 October 2020

PostgreSQL-13 RPM Installation on Linux 7

 

PostgreSQL-13 RPM Installation on Linux 7

 In this tutorial, we will show you how to install PostgreSQL-13 by using RPM on your local system for learning and practicing PostgreSQL.

PostgreSQL was developed for UNIX-like platforms, however, it was designed to be portable. It means that PostgreSQL can also run on other platforms such as Mac OS X, Solaris, and Windows.

Since version 8.0, PostgreSQL offers an installer for Windows systems that makes the installation process easier and faster. For development purpose, we will install PostgreSQL version 13  on Linux.

 

Postgres database installation 3 types, they are

1. GRAPHICAL Installation (./ postgresql.run)
2. BINARY INSTALLATION ( RPM )
3. SOURCE CODE INSTALLATION (./configure)

Note: We are doing POSTGRES BINARY INSTALLATION (RPM):
     =================================================

 

Select version : 13

Select platform: Oracle Linux 7

Select architecture: x86_64

 

Download PostgreSQL 13 for Linux 7:



Step 1. As root user install the below packages 



Note:- Sequence of rpm installation as below otherwise you will get an error of Failed dependencies

1) postgresql13-libs-13.0-1PGDG.rhel7.x86_64.rpm

2) postgresql13-13.0-1PGDG.rhel7.x86_64.rpm

3) postgresql13-server-13.0-1PGDG.rhel7.x86_64.rpm

4) postgresql13-contrib-13.0-1PGDG.rhel7.x86_64.rpm


[root@rac5 Desktop]# rpm -ivh postgresql13-libs-13.0-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-libs-13.0-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:postgresql13-libs-13.0-1PGDG.rhel################################# [100%]
[root@rac5 Desktop]#
[root@rac5 Desktop]# rpm -ivh postgresql13-contrib-13.0-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-contrib-13.0-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
error: Failed dependencies:
        postgresql13(x86-64) = 13.0-1PGDG.rhel7 is needed by postgresql13-contrib-13.0-1PGDG.rhel7.x86_64
        postgresql13-server(x86-64) = 13.0-1PGDG.rhel7 is needed by postgresql13-contrib-13.0-1PGDG.rhel7.x86_64
[root@rac5 Desktop]#
[root@rac5 Desktop]# rpm -ivh postgresql13-13.0-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-13.0-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:postgresql13-13.0-1PGDG.rhel7    ################################# [100%]
[root@rac5 Desktop]#
[root@rac5 Desktop]#
[root@rac5 Desktop]#
[root@rac5 Desktop]#
[root@rac5 Desktop]# rpm -ivh postgresql13-contrib-13.0-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-contrib-13.0-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
error: Failed dependencies:
        postgresql13-server(x86-64) = 13.0-1PGDG.rhel7 is needed by postgresql13-contrib-13.0-1PGDG.rhel7.x86_64
[root@rac5 Desktop]#
[root@rac5 Desktop]#
[root@rac5 Desktop]# rpm -ivh postgresql13-server-13.0-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-server-13.0-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:postgresql13-server-13.0-1PGDG.rh################################# [100%]
[root@rac5 Desktop]#
[root@rac5 Desktop]#
[root@rac5 Desktop]# rpm -ivh postgresql13-contrib-13.0-1PGDG.rhel7.x86_64.rpm
warning: postgresql13-contrib-13.0-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:postgresql13-contrib-13.0-1PGDG.r################################# [100%]
[root@rac5 Desktop]#

 



Step 2. Crosscheck the PostgreSQL binaries filesin /usr/pgsql-13/bin location

[root@rac5 ~]# cd /usr/

[root@rac5 usr]# ls -lrt

total 216

drwxr-xr-x.   2 root root  4096 Apr 11  2018 games
drwxr-xr-x.   2 root root  4096 Apr 11  2018 etc
drwxr-xr-x.  12 root root  4096 Aug  3  2019 local
lrwxrwxrwx.   1 root root    10 Aug  3  2019 tmp -> ../var/tmp
drwxr-xr-x.   4 root root  4096 Aug  3  2019 src
drwxr-xr-x.   9 root root  4096 Aug  3  2019 include
dr-xr-xr-x.  43 root root  4096 Aug  3  2019 lib
drwxr-xr-x.  46 root root 12288 Aug  3  2019 libexec
drwxr-xr-x. 241 root root 12288 Aug  3  2019 share
dr-xr-xr-x.   2 root root 20480 Aug  3  2019 sbin
dr-xr-xr-x. 144 root root 81920 Aug  3  2019 lib64
drwxr-xr-x.   5 root root  4096 Oct 27 01:51 pgsql-14
dr-xr-xr-x.   2 root root 53248 Oct 27 02:06 bin
drwxr-xr-x.   6 root root  4096 Oct 27 02:06 pgsql-13
[root@rac5 usr]# cd pgsql-13
[root@rac5 pgsql-13]#
[root@rac5 pgsql-13]# ls -lrt
total 16
drwxr-xr-x. 3 root root 4096 Oct 27 02:06 doc
drwxr-xr-x. 8 root root 4096 Oct 27 02:06 share
drwxr-xr-x. 2 root root 4096 Oct 27 02:06 bin
drwxr-xr-x. 3 root root 4096 Oct 27 02:06 lib
[root@rac5 pgsql-13]#
[root@rac5 pgsql-13]#
[root@rac5 pgsql-13]# cd bin
[root@rac5 bin]# ls -lrt
total 11092
-rwxr-xr-x. 1 root root    9622 Sep 23 02:55 postgresql-13-setup
-rwxr-xr-x. 1 root root    2175 Sep 23 02:55 postgresql-13-check-db-dir
-rwxr-xr-x. 1 root root   41696 Sep 23 02:55 vacuumlo
-rwxr-xr-x. 1 root root   80256 Sep 23 02:55 vacuumdb
-rwxr-xr-x. 1 root root   76000 Sep 23 02:55 reindexdb
-rwxr-xr-x. 1 root root  644216 Sep 23 02:55 psql
-rwxr-xr-x. 1 root root 7765904 Sep 23 02:55 postgres
-rwxr-xr-x. 1 root root  100608 Sep 23 02:55 pg_waldump
-rwxr-xr-x. 1 root root   92552 Sep 23 02:55 pg_verifybackup
-rwxr-xr-x. 1 root root  146856 Sep 23 02:55 pg_upgrade
-rwxr-xr-x. 1 root root   37296 Sep 23 02:55 pg_test_timing
-rwxr-xr-x. 1 root root   45816 Sep 23 02:55 pg_test_fsync
-rwxr-xr-x. 1 root root   37104 Sep 23 02:55 pg_standby
-rwxr-xr-x. 1 root root  126160 Sep 23 02:55 pg_rewind
-rwxr-xr-x. 1 root root  180456 Sep 23 02:55 pg_restore
-rwxr-xr-x. 1 root root   66800 Sep 23 02:55 pg_resetwal
-rwxr-xr-x. 1 root root   84584 Sep 23 02:55 pg_recvlogical
-rwxr-xr-x. 1 root root   80368 Sep 23 02:55 pg_receivewal
-rwxr-xr-x. 1 root root   67192 Sep 23 02:55 pg_isready
-rwxr-xr-x. 1 root root  105608 Sep 23 02:55 pg_dumpall
-rwxr-xr-x. 1 root root  413592 Sep 23 02:55 pg_dump
-rwxr-xr-x. 1 root root   71120 Sep 23 02:55 pg_ctl
-rwxr-xr-x. 1 root root   58072 Sep 23 02:55 pg_controldata
-rwxr-xr-x. 1 root root   41264 Sep 23 02:55 pg_config
-rwxr-xr-x. 1 root root   62584 Sep 23 02:55 pg_checksums
-rwxr-xr-x. 1 root root  155808 Sep 23 02:55 pgbench
-rwxr-xr-x. 1 root root  118488 Sep 23 02:55 pg_basebackup
-rwxr-xr-x. 1 root root   41464 Sep 23 02:55 pg_archivecleanup
-rwxr-xr-x. 1 root root   41960 Sep 23 02:55 oid2name
-rwxr-xr-x. 1 root root  130464 Sep 23 02:55 initdb
-rwxr-xr-x. 1 root root   67216 Sep 23 02:55 dropuser
-rwxr-xr-x. 1 root root   67272 Sep 23 02:55 dropdb
-rwxr-xr-x. 1 root root   71936 Sep 23 02:55 createuser
-rwxr-xr-x. 1 root root   75728 Sep 23 02:55 createdb
-rwxr-xr-x. 1 root root   71576 Sep 23 02:55 clusterdb
lrwxrwxrwx. 1 root root       8 Oct 27 02:06 postmaster -> postgres
[root@rac5 bin]# pwd
/usr/pgsql-13/bin

 






Step 3. Now create a Linux OS user to access the postgres database  and create  data directory for initializing database cluster. Owner of this data directory should be postgres user and permissions should be 700 and also set path for postgresql binaries for our ease.


 

# useradd postgres
# passwd postgres
# mkdir -p /u01/data_13
# chown -R postgres. /u01/data_13

 

Step 4. Initialize the postgres cluster as user postgres.

-bash-4.2$ id

uid=26(postgres) gid=26(postgres) groups=26(postgres) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

-bash-4.2$

-bash-4.2$

-bash-4.2$ /usr/pgsql-13/bin/initdb -D /u01/data_13




Step 5. Startup the new cluster as user postgres


-bash-4.2$ /usr/pgsql-13/bin/pg_ctl -D /u01/data_13 -l logfile start

waiting for server to start.... done

server started

 



Step 6. Crosscheck at OS level PostgreSQL running or not

-bash-4.2$ ps -ef | grep postgres


root      23334  22771  0 02:08 pts/1    00:00:00 su - postgres
postgres  23335  23334  0 02:08 pts/1    00:00:00 -bash
postgres  23507      1  0 02:13 ?        00:00:00 /usr/pgsql-13/bin/postgres -D /u01/data_13
postgres  23508  23507  0 02:13 ?        00:00:00 postgres: logger
postgres  23510  23507  0 02:13 ?        00:00:00 postgres: checkpointer
postgres  23511  23507  0 02:13 ?        00:00:00 postgres: background writer
postgres  23512  23507  0 02:13 ?        00:00:00 postgres: walwriter
postgres  23513  23507  0 02:13 ?        00:00:00 postgres: autovacuum launcher
postgres  23514  23507  0 02:13 ?        00:00:00 postgres: stats collector
postgres  23515  23507  0 02:13 ?        00:00:00 postgres: logical replication launcher
postgres  23516  23335  0 02:13 pts/1    00:00:00 ps -ef
postgres  23517  23335  0 02:13 pts/1    00:00:00 grep --color=auto postgres
 

 

Step 7. Connect to PostgreSQL DB

 

-bash-4.2$ psql

psql (13.0)

Type "help" for help.

 

postgres=#
postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)


100 Oracle DBA Interview Questions and Answers

  Here are 100 tricky interview questions tailored for a Senior Oracle DBA role. These questions span a wide range of topics, including perf...