Showing posts with label yum. Show all posts
Showing posts with label yum. Show all posts

Thursday, December 29, 2022

Using nmon in linux to collect performance data

Objective:  Let us nmon to collect performance data from linux using the frequency as we need.

Step 1 - nmon installation in linux:

Search for nmon in repo:
[root@localhost ~]# yum search nmon
Loaded plugins: auto-update-debuginfo, fastestmirror
Loading mirror speeds from cached hostfile
 * base: anorien.csc.warwick.ac.uk
 * epel: mirrors.xtom.de
 * epel-debuginfo: mirrors.xtom.de
 * extras: uk.mirrors.clouvider.net
 * updates: mirrors.coreix.net
============================================== N/S matched: nmon ==============================================
nmon-debuginfo.x86_64 : Debug information for package nmon
xfce4-genmon-plugin-debuginfo.x86_64 : Debug information for package xfce4-genmon-plugin
conmon.x86_64 : OCI container runtime monitor
nmon.x86_64 : Nigel's performance Monitor for Linux                         <<<<<<<<< this is what we need
xfce4-genmon-plugin.x86_64 : Generic monitor plugin for the Xfce panel
  Name and summary matches only, use "search all" for everything.
[root@localhost ~]#
Installing nmon:
[root@localhost ~]# yum install nmon.x86_64
Loaded plugins: auto-update-debuginfo, fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                    |  26 kB  00:00:00
epel-debuginfo/x86_64/metalink                                                          |  26 kB  00:00:00
 * base: anorien.csc.warwick.ac.uk
 * epel: mirrors.xtom.de
 * epel-debuginfo: mirrors.xtom.de
 * extras: mirror.freethought-internet.co.uk
 * updates: mirror.bytemark.co.uk
base                                                                                    | 3.6 kB  00:00:00
base-debuginfo                                                                          | 2.5 kB  00:00:00
epel                                                                                    | 4.7 kB  00:00:00
epel-debuginfo                                                                          | 3.0 kB  00:00:00
extras                                                                                  | 2.9 kB  00:00:00
pgdg-common/7/x86_64/signature                                                          |  198 B  00:00:00
...
updates                                                                                 | 2.9 kB  00:00:00
(1/4): epel/x86_64/group_gz                                                             |  99 kB  00:00:00
(2/4): epel/x86_64/updateinfo                                                           | 1.0 MB  00:00:00
(3/4): epel/x86_64/primary_db                                                           | 7.0 MB  00:00:00
(4/4): epel-debuginfo/x86_64/primary_db                                                 | 901 kB  00:00:05
Resolving Dependencies
--> Running transaction check
---> Package nmon.x86_64 0:16g-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================
 Package                 Arch                      Version                       Repository               Size
===============================================================================================================
Installing:
 nmon                    x86_64                    16g-3.el7                     epel                     70 k
Transaction Summary
===============================================================================================================
Install  1 Package
Total download size: 70 k
Installed size: 156 k
Is this ok [y/d/N]: y
Downloading packages:
nmon-16g-3.el7.x86_64.rpm                                                               |  70 kB  00:00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : nmon-16g-3.el7.x86_64                                                                       1/1
  Verifying  : nmon-16g-3.el7.x86_64                                                                       1/1
Installed:
  nmon.x86_64 0:16g-3.el7
Complete!
[root@localhost ~]#


Launch nmon:

Test launch of nmon


lnmonq16gqqqqqqqqqqqqqqqqqqqqqHostname=localhostqqqqRefresh= 2secs qqq06:46.18qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x                                                                                                             x
x   ------------------------------                                                                            x
x    _ __  _ __ ___   ___  _ __          For help type H or ...                                               x
x   | '_ \| '_ ` _ \ / _ \| '_ \          nmon -?  - hint                                                     x
x   | | | | | | | | | (_) | | | |         nmon -h  - full details                                             x
x   |_| |_|_| |_| |_|\___/|_| |_|                                                                             x
x                                        To stop nmon type q to Quit                                          x
x   ------------------------------                                                                            x
x                                                                                                             x
x   CentOS Linux release 7.9.2009 (Core) VERSION="7 (Core)"                                                   x
x   Vendor=GenuineIntel Model=11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz                                  x
x   MHz=1382.406 bogomips=2764.81          lscpu:CPU=1 Little Endian                                          x
x   ProcessorChips=1 PhyscalCores=1              Sockets=1 Cores=1 Thrds=1                                    x
x                    VirtualCPUs =1              MHz=1382 max=0 min=0                                         x
x                                                                                                             x
x   Use these keys to toggle statistics on/off:                                                               x
x     c = CPU         l = CPU Long-term     - = Faster screen updates                                         x
x     C = " WideView  U = Utilisation       + = Slower screen updates                                         x
x     m = Memory      V = Virtual memory    j = File Systems                                                  x
x     d = Disks       n = Network           . = only busy disks/procs                                         x
x     r = Resource    N = NFS               h = more options                                                  x
x     k = Kernel      t = Top-processes     q = Quit                                                          x
xqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx
x                                                                                                             x
x                                                                                                             x
x                                                                                                             x
x                                                                                                             x
x                                                                                                             x
x                                                                                                             x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
Check Cpu usage:
lnmonq16gqqqqqqqqqqqqqqqqqqqqqHostname=localhostqqqqRefresh= 2secs qqq06:47.01qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x CPU Utilisation qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx
x---------------------------+-------------------------------------------------+                               x
xCPU User%  Sys% Wait%  Idle|0          |25         |50          |75       100|                               x
x  1   0.0   0.0   0.0 100.0|>                                                |                               x
x---------------------------+-------------------------------------------------+                               x
xqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx
x
Cpu and network togather:
lnmonq16gqqqqqq[H for help]qqqHostname=localhostqqqqRefresh= 2secs qqq06:47.10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x CPU Utilisation qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx
x---------------------------+-------------------------------------------------+                               x
xCPU User%  Sys% Wait%  Idle|0          |25         |50          |75       100|                               x
x  1   0.0   1.0   0.0  99.0|>                                                |                               x
x---------------------------+-------------------------------------------------+                               x
x Network I/O qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx
xI/F Name Recv=KB/s Trans=KB/s packin packout insize outsize Peak->Recv Trans                                 x
x  enp0s3      0.2       4.4       2.0    3.5    98.5 1284.6        1.0     13.9                              x
x      lo      0.0       0.0       0.0    0.0     0.0    0.0        0.0      0.0                              x
x Network Error Counters qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx
xI/F Name iErrors iDrop iOverrun iFrame oErrors   oDrop oOverrun oCarrier oColls                              x
x  enp0s3       0       0       0       0       0       0       0       0       0                             x
x      lo       0       0       0       0       0       0       0       0       0                             x
xqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqx
x


Now let us schedule nmon in cron to collect data every 10 secs for 360 times, which means 1hr:


59 * * * * cd /pgBACKUP/nmondata && nmon -f -tT -s10 -c360 1>/dev/null 2>&1


Resultant files are:
-rw-r--r--. 1 root     root     112123 Dec 29 18:13 localhost_221229_1759.nmon
-rw-r--r--. 1 root     root     335301 Dec 29 18:13 localhost_221229_1659.nmon
[root@localhost nmondata]# head localhost_221229_1759.nmon
AAA,progname,nmon
AAA,command,nmon -f -tT -s10 -c360
AAA,version,16g
AAA,disks_per_line,150
AAA,max_disks,256,set by -d option
AAA,disks,14,
AAA,host,localhost
AAA,user,root
AAA,OS,Linux,3.10.0-1160.6.1.el7.x86_64,#1 SMP Tue Nov 17 13:59:11 UTC 2020,x86_64
AAA,runname,localhost
[root@localhost nmondata]#


Also notice the next nmon sampler is running from cron... there is one nmon at any time; as per our setup. After 1hr the existing nmon will die and the next nmon will kick off.


[root@localhost nmondata]# ps -ef|grep -i nmon
root      6276     1  0 17:59 ?        00:00:01 nmon -f -tT -s10 -c360
root      7710  1770  0 18:22 pts/0    00:00:00 grep --color=auto -i nmon
[root@localhost nmondata]#


Now let us look how we can host this as a webpage...


Directory structure:
Nmon data loc: /pgBACKUP/nmondata
nmonchart bin: /pgBACKUP/nmonchartbin/nmonchart
nmonchart dest: /pgBACKUP/nmondata/nmonchartop

So we need to use nmonchart to push the output charts over to the dest location...
Prereqs: You need ksh


[root@localhost nmondata]# ksh
# pwd
/pgBACKUP/nmondata
#

/pgBACKUP/nmonchartbin/nmonchart localhost_221229_1659.nmon ./nmonchartop/localhost_221229_1659.html
Actual:
# /pgBACKUP/nmonchartbin/nmonchart localhost_221229_1659.nmon ./nmonchartop/localhost_221229_1659.html
#
[root@localhost nmondata]# cd nmonchartop/
[root@localhost nmonchartop]# ls -altr
total 448
drwxr-xr-x. 3 root root    193 Dec 29 18:13 ..
drwxr-xr-x. 2 root root     40 Dec 29 18:26 .
-rw-r--r--. 1 root root 457432 Dec 29 18:26 localhost_221229_1659.html
[root@localhost nmonchartop]# pwd
/pgBACKUP/nmondata/nmonchartop
[root@localhost nmonchartop]#

So the html output is available here. We just need to host it.
Let us try to use simple solution like python.
>>>next blog>>>

Monday, October 17, 2022

Yum or rpm based postgresql version 15 setup

Objective:

In this blog, we will see how we setup postgresql 15 using yum or rpm.

>>> Ensure the repository configuration file is updated to exclude the postgresql package from base and updates section to avoid later package incorrect resolutions

[root@10 ~]# ls -altr /etc/yum.repos.d/
total 56
-rw-r--r--.  1 root root  616 Nov 23  2020 CentOS-x86_64-kernel.repo
-rw-r--r--.  1 root root 8515 Nov 23  2020 CentOS-Vault.repo
-rw-r--r--.  1 root root 1331 Nov 23  2020 CentOS-Sources.repo
-rw-r--r--.  1 root root  630 Nov 23  2020 CentOS-Media.repo
-rw-r--r--.  1 root root  314 Nov 23  2020 CentOS-fasttrack.repo
-rw-r--r--.  1 root root  649 Nov 23  2020 CentOS-Debuginfo.repo
-rw-r--r--.  1 root root 1309 Nov 23  2020 CentOS-CR.repo
-rw-r--r--.  1 root root 1664 Nov 23  2020 CentOS-Base.repo
-rw-r--r--.  1 root root 1664 Oct 16 16:08 CentOS-Base.repo_bkp_16oct2022
drwxr-xr-x.  2 root root  258 Oct 16 16:08 .
drwxr-xr-x. 74 root root 8192 Oct 16 21:29 ..
[root@10 ~]# 

>>> Edit the CentOS-Base.repo

vi /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
exclude=postgresql*
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
exclude=postgresql*

>>> Goto url
https://www.postgresql.org/download/linux/redhat/
Choose relevant options for the install. Copy the scripts supplied...... [Remember postgresql readme says the binary of the postgresql isnt owned by the postgres user as like oracle, where oracle owns the oracle rdbms binary]

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql15-server
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15


Command: yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Installed file:
-rw-r--r--.  1 root root 10693 Sep 29 19:52 pgdg-redhat-all.repo

I removed sudo, since I ran the commands as root user. Right now I dont have postgres user either, since the postgres user is needed only to own and manage postgres data not its binary

Command: yum install -y postgresql15-server
Failed due to 
...
Error: Package: postgresql15-15.0-1PGDG.rhel7.x86_64 (pgdg15)
           Requires: libzstd >= 1.4.0
Error: Package: postgresql15-server-15.0-1PGDG.rhel7.x86_64 (pgdg15)
           Requires: libzstd.so.1()(64bit)
Error: Package: postgresql15-15.0-1PGDG.rhel7.x86_64 (pgdg15)
           Requires: libzstd.so.1()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest


We need epel for this action:
yum -y install epel-release [which has the package libzstd]

yum install libzstd-devel

Install output:


[root@10 yum.repos.d]# yum install libzstd-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.nxtgen.com
 * epel: download.nus.edu.sg
 * extras: mirrors.nxtgen.com
 * updates: mirrors.nxtgen.com
Resolving Dependencies
--> Running transaction check
---> Package libzstd-devel.x86_64 0:1.5.2-1.el7 will be installed
--> Processing Dependency: libzstd(x86-64) = 1.5.2-1.el7 for package: libzstd-devel-1.5.2-1.el7.x86_64
--> Processing Dependency: libzstd.so.1()(64bit) for package: libzstd-devel-1.5.2-1.el7.x86_64
--> Running transaction check
---> Package libzstd.x86_64 0:1.5.2-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================
 Package                          Arch                      Version                         Repository               Size
==========================================================================================================================
Installing:
 libzstd-devel                    x86_64                    1.5.2-1.el7                     epel                     47 k
Installing for dependencies:
 libzstd                          x86_64                    1.5.2-1.el7                     epel                    282 k
Transaction Summary
==========================================================================================================================
Install  1 Package (+1 Dependent package)
Total download size: 330 k
Installed size: 918 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/libzstd-devel-1.5.2-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for libzstd-devel-1.5.2-1.el7.x86_64.rpm is not installed
(1/2): libzstd-devel-1.5.2-1.el7.x86_64.rpm                                                        |  47 kB  00:00:06
(2/2): libzstd-1.5.2-1.el7.x86_64.rpm                                                              | 282 kB  00:00:08
--------------------------------------------------------------------------------------------------------------------------
Total                                                                                      37 kB/s | 330 kB  00:00:08
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-11.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libzstd-1.5.2-1.el7.x86_64                                                                             1/2
  Installing : libzstd-devel-1.5.2-1.el7.x86_64                                                                       2/2
  Verifying  : libzstd-1.5.2-1.el7.x86_64                                                                             1/2
  Verifying  : libzstd-devel-1.5.2-1.el7.x86_64                                                                       2/2
Installed:
  libzstd-devel.x86_64 0:1.5.2-1.el7
Dependency Installed:
  libzstd.x86_64 0:1.5.2-1.el7
Complete!


[root@10 yum.repos.d]# ls -altr
total 80
-rw-r--r--.  1 root root  1050 Oct  2  2017 epel-testing.repo
-rw-r--r--.  1 root root   951 Oct  2  2017 epel.repo
-rw-r--r--.  1 root root   616 Nov 23  2020 CentOS-x86_64-kernel.repo
-rw-r--r--.  1 root root  8515 Nov 23  2020 CentOS-Vault.repo
-rw-r--r--.  1 root root  1331 Nov 23  2020 CentOS-Sources.repo
-rw-r--r--.  1 root root   630 Nov 23  2020 CentOS-Media.repo
-rw-r--r--.  1 root root   314 Nov 23  2020 CentOS-fasttrack.repo
-rw-r--r--.  1 root root   649 Nov 23  2020 CentOS-Debuginfo.repo
-rw-r--r--.  1 root root  1309 Nov 23  2020 CentOS-CR.repo
-rw-r--r--.  1 root root 10693 Sep 29 19:52 pgdg-redhat-all.repo-new
-rw-r--r--.  1 root root  1664 Oct 16 16:08 CentOS-Base.repo_bkp_16oct2022
-rw-r--r--.  1 root root  1706 Oct 16 22:35 CentOS-Base.repo
drwxr-xr-x.  2 root root  4096 Oct 16 22:35 .
drwxr-xr-x. 74 root root  8192 Oct 16 22:39 ..

[root@10 yum.repos.d]# mv pgdg-redhat-all.repo-new pgdg-redhat-all.repo

postgresql 15 install:

[root@10 yum.repos.d]# yum install -y postgresql15-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: download.nus.edu.sg
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package postgresql15-server.x86_64 0:15.0-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql15-libs(x86-64) = 15.0-1PGDG.rhel7 for package: postgresql15-server-15.0-1PGDG.rhel7.x86_64
--> Processing Dependency: postgresql15(x86-64) = 15.0-1PGDG.rhel7 for package: postgresql15-server-15.0-1PGDG.rhel7.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql15-server-15.0-1PGDG.rhel7.x86_64
--> Processing Dependency: libicuuc.so.50()(64bit) for package: postgresql15-server-15.0-1PGDG.rhel7.x86_64
--> Processing Dependency: libicui18n.so.50()(64bit) for package: postgresql15-server-15.0-1PGDG.rhel7.x86_64
--> Running transaction check
---> Package libicu.x86_64 0:50.2-4.el7_7 will be installed
---> Package postgresql15.x86_64 0:15.0-1PGDG.rhel7 will be installed
---> Package postgresql15-libs.x86_64 0:15.0-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================
 Package                             Arch                   Version                          Repository              Size
==========================================================================================================================
Installing:
 postgresql15-server                 x86_64                 15.0-1PGDG.rhel7                 pgdg15                 5.6 M
Installing for dependencies:
 libicu                              x86_64                 50.2-4.el7_7                     base                   6.9 M
 postgresql15                        x86_64                 15.0-1PGDG.rhel7                 pgdg15                 1.5 M
 postgresql15-libs                   x86_64                 15.0-1PGDG.rhel7                 pgdg15                 277 k
Transaction Summary
==========================================================================================================================
Install  1 Package (+3 Dependent packages)
Total download size: 14 M
Installed size: 55 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/pgdg15/packages/postgresql15-libs-15.0-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Public key for postgresql15-libs-15.0-1PGDG.rhel7.x86_64.rpm is not installed
(1/4): postgresql15-libs-15.0-1PGDG.rhel7.x86_64.rpm                                               | 277 kB  00:00:10
(2/4): libicu-50.2-4.el7_7.x86_64.rpm                                                              | 6.9 MB  00:00:27
(3/4): postgresql15-15.0-1PGDG.rhel7.x86_64.rpm                                                    | 1.5 MB  00:00:29
(4/4): postgresql15-server-15.0-1PGDG.rhel7.x86_64.rpm                                             | 5.6 MB  00:00:40
--------------------------------------------------------------------------------------------------------------------------
Total                                                                                     286 kB/s |  14 MB  00:00:51
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 Package    : pgdg-redhat-repo-42.0-27.noarch (@/pgdg-redhat-repo-latest.noarch)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : postgresql15-libs-15.0-1PGDG.rhel7.x86_64                                                              1/4
  Installing : libicu-50.2-4.el7_7.x86_64                                                                             2/4
  Installing : postgresql15-15.0-1PGDG.rhel7.x86_64                                                                   3/4
  Installing : postgresql15-server-15.0-1PGDG.rhel7.x86_64                                                            4/4
  Verifying  : postgresql15-server-15.0-1PGDG.rhel7.x86_64                                                            1/4
  Verifying  : libicu-50.2-4.el7_7.x86_64                                                                             2/4
  Verifying  : postgresql15-libs-15.0-1PGDG.rhel7.x86_64                                                              3/4
  Verifying  : postgresql15-15.0-1PGDG.rhel7.x86_64                                                                   4/4
Installed:
  postgresql15-server.x86_64 0:15.0-1PGDG.rhel7
Dependency Installed:
  libicu.x86_64 0:50.2-4.el7_7    postgresql15.x86_64 0:15.0-1PGDG.rhel7    postgresql15-libs.x86_64 0:15.0-1PGDG.rhel7
Complete!
[root@10 yum.repos.d]#

>>> user and group postgres is by default added in the course...

[root@10 yum.repos.d]# groupadd postgres
groupadd: group 'postgres' already exists

[root@10 yum.repos.d]# id postgres
uid=26(postgres) gid=26(postgres) groups=26(postgres)
[root@10 yum.repos.d]#

>>> Initalizing the data directory:

Ex.:
root# mkdir /usr/local/pgsql
root# chown postgres /usr/local/pgsql
root# su postgres
postgres$ initdb -D /usr/local/pgsql/data

Actual: <<< we use the data directory we seperately created.
mkdir /pgDATA/data
[root@10 yum.repos.d]# chown postgres:postgres /pgDATA/data
[root@10 yum.repos.d]# ls -ld /pgDATA/data
drwxr-xr-x. 2 postgres postgres 6 Oct 16 22:59 /pgDATA/data
[root@10 yum.repos.d]#

>>> Update the .bash_profile of postgres user:

-bash-4.2$ cat .bash_profile
[ -f /etc/profile ] && source /etc/profile
PGDATA=/pgDATA/data  << appended
export PGDATA
# If you want to customize your settings,
# Use the file below. This is not overridden
# by the RPMS.
[ -f /var/lib/pgsql/.pgsql_profile ] && source /var/lib/pgsql/.pgsql_profile
export PATH=$PATH:/usr/pgsql-15/bin:/usr/pgsql-15/lib:  <<< appended
-bash-4.2$

>>> logged in as postgres user and initialized the db

initdb -D /pgDATA/data

-bash-4.2$ echo $PGDATA
/pgDATA/data

-bash-4.2$ initdb -D $PGDATA
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 /pgDATA/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Kolkata
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -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 /pgDATA/data -l logfile start

-bash-4.2$

The cluster database is initialized.