Showing posts with label Installations. Show all posts
Showing posts with label Installations. Show all posts

Sunday, 11 August 2024

PostgreSQL 13 installation on Linux 8

 
[root@rac10-p ~]#
[root@rac10-p ~]#
[root@rac10-p ~]# cd /etc/yum.repos.d

[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]# ls -lrt
total 12
-rw-r--r--. 1 root root  243 May 16  2023 virt-ol8.repo
-rw-r--r--. 1 root root  941 Jul  8 11:46 uek-ol8.repo
-rw-r--r--. 1 root root 3662 Jul 16 19:07 oracle-linux-ol8.repo
[root@rac10-p yum.repos.d]#

Step 1. Download PostgreSql repository: 
Use OS command dnf to download PostgreSQL repository, 
Please note yum command require Internet Connection on Server. You can use yum repolist command to verify PostgreSQL repository created in Server.


[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]# dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Oracle Linux 8 BaseOS Latest (x86_64)                                                                                                         18 kB/s | 4.3 kB     00:00
Oracle Linux 8 BaseOS Latest (x86_64)                                                                                                        7.0 MB/s |  79 MB     00:11
Oracle Linux 8 Application Stream (x86_64)                                                                                                    52 kB/s | 4.5 kB     00:00
Oracle Linux 8 Application Stream (x86_64)                                                                                                   5.5 MB/s |  62 MB     00:11
Oracle Linux 8 CodeReady Builder (x86_64) - Unsupported                                                                                      9.7 kB/s | 3.8 kB     00:00
Oracle Linux 8 CodeReady Builder (x86_64) - Unsupported                                                                                      5.0 MB/s |  11 MB     00:02
Latest Unbreakable Enterprise Kernel Release 7 for Oracle Linux 8 (x86_64)                                                                   1.9 kB/s | 3.5 kB     00:01
Last metadata expiration check: 0:00:01 ago on Sat 10 Aug 2024 11:43:22 PM IST.
pgdg-redhat-repo-latest.noarch.rpm                                                                                                            18 kB/s |  15 kB     00:00
Dependencies resolved.
=============================================================================================================================================================================
 Package                                       Architecture                        Version                                   Repository                                 Size
=============================================================================================================================================================================
Installing:
 pgdg-redhat-repo                              noarch                              42.0-43PGDG                               @commandline                               15 k
Transaction Summary
=============================================================================================================================================================================
Install  1 Package
Total size: 15 k
Installed size: 15 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                     1/1
  Installing       : pgdg-redhat-repo-42.0-43PGDG.noarch                                                                                                                 1/1
  Verifying        : pgdg-redhat-repo-42.0-43PGDG.noarch                                                                                                                 1/1
Installed:
  pgdg-redhat-repo-42.0-43PGDG.noarch
Complete!



[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]# ls -lrt
total 28
-rw-r--r--. 1 root root   243 May 16  2023 virt-ol8.repo
-rw-r--r--. 1 root root 13280 Apr 10 12:30 pgdg-redhat-all.repo
-rw-r--r--. 1 root root   941 Jul  8 11:46 uek-ol8.repo
-rw-r--r--. 1 root root  3662 Jul 16 19:07 oracle-linux-ol8.repo
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#



[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]# dnf repolist
repo id                                                     repo name
ol8_UEKR7                                                   Latest Unbreakable Enterprise Kernel Release 7 for Oracle Linux 8 (x86_64)
ol8_appstream                                               Oracle Linux 8 Application Stream (x86_64)
ol8_baseos_latest                                           Oracle Linux 8 BaseOS Latest (x86_64)
ol8_codeready_builder                                       Oracle Linux 8 CodeReady Builder (x86_64) - Unsupported
pgdg-common                                                 PostgreSQL common RPMs for RHEL / Rocky / AlmaLinux 8 - x86_64
pgdg12                                                      PostgreSQL 12 for RHEL / Rocky / AlmaLinux 8 - x86_64
pgdg13                                                      PostgreSQL 13 for RHEL / Rocky / AlmaLinux 8 - x86_64
pgdg14                                                      PostgreSQL 14 for RHEL / Rocky / AlmaLinux 8 - x86_64
pgdg15                                                      PostgreSQL 15 for RHEL / Rocky / AlmaLinux 8 - x86_64
pgdg16                                                      PostgreSQL 16 for RHEL / Rocky / AlmaLinux 8 - x86_64
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#



[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]# dnf module disable postgresql
PostgreSQL common RPMs for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                               457  B/s | 659  B     00:01
PostgreSQL common RPMs for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                               2.4 MB/s | 2.4 kB     00:00
Importing GPG key 0x08B40D20:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
Is this ok [y/N]: y
PostgreSQL common RPMs for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                               143 kB/s | 467 kB     00:03
PostgreSQL 16 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        268  B/s | 659  B     00:02
PostgreSQL 16 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        2.4 MB/s | 2.4 kB     00:00
Importing GPG key 0x08B40D20:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
Is this ok [y/N]: y
PostgreSQL 16 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        131 kB/s | 418 kB     00:03
PostgreSQL 15 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        544  B/s | 659  B     00:01
PostgreSQL 15 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        2.4 MB/s | 2.4 kB     00:00
Importing GPG key 0x08B40D20:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
Is this ok [y/N]: y
PostgreSQL 15 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        260 kB/s | 676 kB     00:02
PostgreSQL 14 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        585  B/s | 659  B     00:01
PostgreSQL 14 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        2.4 MB/s | 2.4 kB     00:00
Importing GPG key 0x08B40D20:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
Is this ok [y/N]: y
PostgreSQL 14 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        155 kB/s | 1.0 MB     00:06
PostgreSQL 13 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        470  B/s | 659  B     00:01
PostgreSQL 13 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        2.4 MB/s | 2.4 kB     00:00
Importing GPG key 0x08B40D20:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
Is this ok [y/N]: y
PostgreSQL 13 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        428 kB/s | 1.2 MB     00:02
PostgreSQL 12 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        412  B/s | 659  B     00:01
PostgreSQL 12 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        2.4 MB/s | 2.4 kB     00:00
Importing GPG key 0x08B40D20:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
Is this ok [y/N]: y
PostgreSQL 12 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        491 kB/s | 1.3 MB     00:02
Dependencies resolved.
=============================================================================================================================================================================
 Package                                  Architecture                            Version                                     Repository                                Size
=============================================================================================================================================================================
Disabling modules:
 postgresql
Transaction Summary
=============================================================================================================================================================================
Is this ok [y/N]: y
Complete!





[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]# dnf list "postgresql*-server"
Last metadata expiration check: 0:01:22 ago on Sat 10 Aug 2024 11:48:44 PM IST.
Available Packages
postgresql12-server.x86_64                                                              12.20-2PGDG.rhel8                                                              pgdg12
postgresql13-server.x86_64                                                              13.16-2PGDG.rhel8                                                              pgdg13
postgresql14-server.x86_64                                                              14.13-2PGDG.rhel8                                                              pgdg14
postgresql15-server.x86_64                                                              15.8-1PGDG.rhel8                                                               pgdg15
postgresql16-server.x86_64                                                              16.4-1PGDG.rhel8                                                               pgdg16

**************************************************************************************************************
Step 2.  Install  PostgreSQL Server: Use OS command “dnf” to  install  PostgreSQL Version 13.
**************************************************************************************************************
[root@rac10-p yum.repos.d]# dnf install postgresql13-server postgresql13
Last metadata expiration check: 0:03:12 ago on Sat 10 Aug 2024 11:54:13 PM IST.
Dependencies resolved.
=============================================================================================================================================================================
 Package                                         Architecture                       Version                                         Repository                          Size
=============================================================================================================================================================================
Installing:
 postgresql13                                    x86_64                             13.16-2PGDG.rhel8                               pgdg13                             1.5 M
 postgresql13-server                             x86_64                             13.16-2PGDG.rhel8                               pgdg13                             5.5 M
Installing dependencies:
 postgresql13-libs                               x86_64                             13.16-2PGDG.rhel8                               pgdg13                             420 k
Transaction Summary
=============================================================================================================================================================================
Install  3 Packages
Total download size: 7.4 M
Installed size: 31 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): postgresql13-13.16-2PGDG.rhel8.x86_64.rpm                                                                                             563 kB/s | 1.5 MB     00:02
(2/3): postgresql13-server-13.16-2PGDG.rhel8.x86_64.rpm                                                                                      1.5 MB/s | 5.5 MB     00:03
(3/3): postgresql13-libs-13.16-2PGDG.rhel8.x86_64.rpm                                                                                        102 kB/s | 420 kB     00:04
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                        1.8 MB/s | 7.4 MB     00:04
PostgreSQL 13 for RHEL / Rocky / AlmaLinux 8 - x86_64                                                                                        2.4 MB/s | 2.4 kB     00:00
Importing GPG key 0x08B40D20:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                     1/1
  Installing       : postgresql13-libs-13.16-2PGDG.rhel8.x86_64                                                                                                          1/3
  Running scriptlet: postgresql13-libs-13.16-2PGDG.rhel8.x86_64                                                                                                          1/3
  Installing       : postgresql13-13.16-2PGDG.rhel8.x86_64                                                                                                               2/3
  Running scriptlet: postgresql13-13.16-2PGDG.rhel8.x86_64                                                                                                               2/3
  Running scriptlet: postgresql13-server-13.16-2PGDG.rhel8.x86_64                                                                                                        3/3
  Installing       : postgresql13-server-13.16-2PGDG.rhel8.x86_64                                                                                                        3/3
  Running scriptlet: postgresql13-server-13.16-2PGDG.rhel8.x86_64                                                                                                        3/3
  Verifying        : postgresql13-13.16-2PGDG.rhel8.x86_64                                                                                                               1/3
  Verifying        : postgresql13-libs-13.16-2PGDG.rhel8.x86_64                                                                                                          2/3
  Verifying        : postgresql13-server-13.16-2PGDG.rhel8.x86_64                                                                                                        3/3
Installed:
  postgresql13-13.16-2PGDG.rhel8.x86_64                postgresql13-libs-13.16-2PGDG.rhel8.x86_64                postgresql13-server-13.16-2PGDG.rhel8.x86_64
Complete!
[root@rac10-p yum.repos.d]#
[root@rac10-p yum.repos.d]#

Go to /usr/pgsql-13/bin

[root@rac10-p]# cd /usr/pgsql-13/bin
[root@rac10-p bin]# pwd
/usr/pgsql-13/bin
[root@rac10-p bin]#
[root@rac10-p bin]#
[root@rac10-p bin]# ls -rlt
total 11264
lrwxrwxrwx. 1 root root       8 Aug  9 03:25 postmaster -> postgres
-rwxr-xr-x. 1 root root    9622 Aug  9 03:25 postgresql-13-setup
-rwxr-xr-x. 1 root root    2170 Aug  9 03:25 postgresql-13-check-db-dir
-rwxr-xr-x. 1 root root   81920 Aug  9 03:26 vacuumdb
-rwxr-xr-x. 1 root root   81744 Aug  9 03:26 reindexdb
-rwxr-xr-x. 1 root root  678648 Aug  9 03:26 psql
-rwxr-xr-x. 1 root root 7914808 Aug  9 03:26 postgres
-rwxr-xr-x. 1 root root  102248 Aug  9 03:26 pg_waldump
-rwxr-xr-x. 1 root root   94112 Aug  9 03:26 pg_verifybackup
-rwxr-xr-x. 1 root root  156824 Aug  9 03:26 pg_upgrade
-rwxr-xr-x. 1 root root   38824 Aug  9 03:26 pg_test_timing
-rwxr-xr-x. 1 root root   47336 Aug  9 03:26 pg_test_fsync
-rwxr-xr-x. 1 root root  132048 Aug  9 03:26 pg_rewind
-rwxr-xr-x. 1 root root  187632 Aug  9 03:26 pg_restore
-rwxr-xr-x. 1 root root   68376 Aug  9 03:26 pg_resetwal
-rwxr-xr-x. 1 root root   86088 Aug  9 03:26 pg_receivewal
-rwxr-xr-x. 1 root root   68824 Aug  9 03:26 pg_isready
-rwxr-xr-x. 1 root root  111328 Aug  9 03:26 pg_dumpall
-rwxr-xr-x. 1 root root  431608 Aug  9 03:26 pg_dump
-rwxr-xr-x. 1 root root   72632 Aug  9 03:26 pg_ctl
-rwxr-xr-x. 1 root root   59608 Aug  9 03:26 pg_controldata
-rwxr-xr-x. 1 root root   46992 Aug  9 03:26 pg_config
-rwxr-xr-x. 1 root root   64208 Aug  9 03:26 pg_checksums
-rwxr-xr-x. 1 root root  161456 Aug  9 03:26 pgbench
-rwxr-xr-x. 1 root root  128464 Aug  9 03:26 pg_basebackup
-rwxr-xr-x. 1 root root   43008 Aug  9 03:26 pg_archivecleanup
-rwxr-xr-x. 1 root root  136248 Aug  9 03:26 initdb
-rwxr-xr-x. 1 root root   68816 Aug  9 03:26 dropuser
-rwxr-xr-x. 1 root root   68888 Aug  9 03:26 dropdb
-rwxr-xr-x. 1 root root   77696 Aug  9 03:26 createuser
-rwxr-xr-x. 1 root root   77352 Aug  9 03:26 createdb
-rwxr-xr-x. 1 root root   73200 Aug  9 03:26 clusterdb
[root@rac10-p bin]#


Step 3. Initialize  DB and Enable Auto Restart: Follow the below steps.
==============================================================================
[root@rac10-p ~]#
[root@rac10-p ~]# /usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK
[root@rac10-p ~]#
[root@rac10-p ~]#
[root@rac10-p ~]#
[root@rac10-p ~]# systemctl enable postgresql-13
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-13.service → /usr/lib/systemd/system/postgresql-13.service.
[root@rac10-p ~]#
[root@ra
[root@rac10-p ~]#
[root@rac10-p ~]# systemctl start postgresql-13
[root@rac10-p ~]#
[root@rac10-p ~]#
[root@rac10-p ~]#

[root@rac10-p ~]#
[root@rac10-p ~]# ps -ef| grep postgres
postgres    7707       1  0 00:12 ?        00:00:00 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
postgres    7709    7707  0 00:12 ?        00:00:00 postgres: logger
postgres    7711    7707  0 00:12 ?        00:00:00 postgres: checkpointer
postgres    7712    7707  0 00:12 ?        00:00:00 postgres: background writer
postgres    7713    7707  0 00:12 ?        00:00:00 postgres: walwriter
postgres    7714    7707  0 00:12 ?        00:00:00 postgres: autovacuum launcher
postgres    7715    7707  0 00:12 ?        00:00:00 postgres: stats collector
postgres    7716    7707  0 00:12 ?        00:00:00 postgres: logical replication launcher
root        7730    4893  0 00:12 pts/0    00:00:00 grep --color=auto postgres
[root@rac10-p ~]#
[root@rac10-p ~]#
[root@rac10-p ~]#


Step 4. Login to psql: Yum command will take care of all prerequisites and once all above steps are done you will notice OS user:  

****************************************************************************************************************************************
postgres and Binary Location: /usr/pgsql-13/bin/ 
and 
Data Directory Location: /var/lib/pgsql/13/data/ created. 
Perform switch user to  postgres and type psql (terminal-based front-end to PostgreSQL). 
When you enter psql you will be connected to psql terminal with database: 
postgres and user: postgres (Here postgres=# is DBName). Use command \conninfo to get connection details.

Binary Location : 
--------------------------

cd /usr/pgsql-13/bin/
[root@rac10-p ~]# cd /usr/pgsql-13/bin/
[root@rac10-p bin]#
[root@rac10-p bin]#
[root@rac10-p bin]# ls -lrt
total 11264
lrwxrwxrwx. 1 root root       8 Aug  9 03:25 postmaster -> postgres
-rwxr-xr-x. 1 root root    9622 Aug  9 03:25 postgresql-13-setup
-rwxr-xr-x. 1 root root    2170 Aug  9 03:25 postgresql-13-check-db-dir
-rwxr-xr-x. 1 root root   81920 Aug  9 03:26 vacuumdb
-rwxr-xr-x. 1 root root   81744 Aug  9 03:26 reindexdb
-rwxr-xr-x. 1 root root  678648 Aug  9 03:26 psql
-rwxr-xr-x. 1 root root 7914808 Aug  9 03:26 postgres
-rwxr-xr-x. 1 root root  102248 Aug  9 03:26 pg_waldump
-rwxr-xr-x. 1 root root   94112 Aug  9 03:26 pg_verifybackup
-rwxr-xr-x. 1 root root  156824 Aug  9 03:26 pg_upgrade
-rwxr-xr-x. 1 root root   38824 Aug  9 03:26 pg_test_timing
-rwxr-xr-x. 1 root root   47336 Aug  9 03:26 pg_test_fsync
-rwxr-xr-x. 1 root root  132048 Aug  9 03:26 pg_rewind
-rwxr-xr-x. 1 root root  187632 Aug  9 03:26 pg_restore
-rwxr-xr-x. 1 root root   68376 Aug  9 03:26 pg_resetwal
-rwxr-xr-x. 1 root root   86088 Aug  9 03:26 pg_receivewal
-rwxr-xr-x. 1 root root   68824 Aug  9 03:26 pg_isready
-rwxr-xr-x. 1 root root  111328 Aug  9 03:26 pg_dumpall
-rwxr-xr-x. 1 root root  431608 Aug  9 03:26 pg_dump
-rwxr-xr-x. 1 root root   72632 Aug  9 03:26 pg_ctl
-rwxr-xr-x. 1 root root   59608 Aug  9 03:26 pg_controldata
-rwxr-xr-x. 1 root root   46992 Aug  9 03:26 pg_config
-rwxr-xr-x. 1 root root   64208 Aug  9 03:26 pg_checksums
-rwxr-xr-x. 1 root root  161456 Aug  9 03:26 pgbench
-rwxr-xr-x. 1 root root  128464 Aug  9 03:26 pg_basebackup
-rwxr-xr-x. 1 root root   43008 Aug  9 03:26 pg_archivecleanup
-rwxr-xr-x. 1 root root  136248 Aug  9 03:26 initdb
-rwxr-xr-x. 1 root root   68816 Aug  9 03:26 dropuser
-rwxr-xr-x. 1 root root   68888 Aug  9 03:26 dropdb
-rwxr-xr-x. 1 root root   77696 Aug  9 03:26 createuser
-rwxr-xr-x. 1 root root   77352 Aug  9 03:26 createdb
-rwxr-xr-x. 1 root root   73200 Aug  9 03:26 clusterdb
[root@rac10-p bin]#


Data Directory Location : 
--------------------------

[root@rac10-p bin]# cd /var/lib/pgsql/13/data/
[root@rac10-p data]#
[root@rac10-p data]# ls -lrt
total 132
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_twophase
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_snapshots
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_serial
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_notify
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_dynshmem
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_commit_ts
-rw-------. 1 postgres postgres     3 Aug 11 00:11 PG_VERSION
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_tblspc
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_stat
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_replslot
drwx------. 4 postgres postgres  4096 Aug 11 00:11 pg_multixact
-rw-------. 1 postgres postgres 28086 Aug 11 00:11 postgresql.conf
-rw-------. 1 postgres postgres    88 Aug 11 00:11 postgresql.auto.conf
-rw-------. 1 postgres postgres  1636 Aug 11 00:11 pg_ident.conf
-rw-------. 1 postgres postgres  4548 Aug 11 00:11 pg_hba.conf
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_xact
drwx------. 3 postgres postgres  4096 Aug 11 00:11 pg_wal
drwx------. 2 postgres postgres  4096 Aug 11 00:11 pg_subtrans
drwx------. 2 postgres postgres  4096 Aug 11 00:11 global
drwx------. 5 postgres postgres  4096 Aug 11 00:11 base
drwx------. 4 postgres postgres  4096 Aug 11 00:11 pg_logical
drwx------. 2 postgres postgres  4096 Aug 11 00:12 log
-rw-------. 1 postgres postgres    30 Aug 11 00:12 current_logfiles
-rw-------. 1 postgres postgres    58 Aug 11 00:12 postmaster.opts
-rw-------. 1 postgres postgres    99 Aug 11 00:12 postmaster.pid
drwx------. 2 postgres postgres  4096 Aug 11 00:16 pg_stat_tmp
[root@rac10-p data]#



[root@rac10-p bin]# id postgres
uid=26(postgres) gid=26(postgres) groups=26(postgres)
[root@rac10-p bin]#
[root@rac10-p bin]#

Switch to the postgres - user

[root@rac10-p data]#
[root@rac10-p data]# su - postgres
[postgres@rac10-p ~]$
[postgres@rac10-p ~]$
[postgres@rac10-p ~]$
[postgres@rac10-p ~]$ psql
psql (13.16)
Type "help" for help.
postgres=#
postgres=#
postgres=#
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/run/postgresql" at port "5432".
postgres=#
postgres=#



Step 5. Verify  PostgreSql Version: Use command SELECT version() or SHOW server_version.



postgres=# SELECT version();
                                                 version
----------------------------------------------------------------------------------------------------------
 PostgreSQL 13.16 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22), 64-bit
(1 row)

postgres=# SHOW server_version;
 server_version
----------------
 13.16
(1 row)








Sunday, 21 January 2024

PostgreSQL 15 Installation

I have installed the PostgreSQL-15 on my Linux machine 

Kindly use below link for the installation 

https://www.postgresql.org/download/linux/redhat/



PostgreSQL Yum Repository

The PostgreSQL Yum Repository will integrate with your normal systems and patch management, and provide automatic updates for all supported versions of PostgreSQL throughout the support lifetime of PostgreSQL.

The PostgreSQL Yum Repository currently supports:

  • Red Hat Enterprise Linux
  • Rocky Linux
  • AlmaLinux
  • CentOS (7 and 6 only)
  • Oracle Linux
  • Fedora*


4. Copy, paste and run the relevant parts of the setup script


  1. sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    
    # Install PostgreSQL:
    sudo yum install -y postgresql15-server
    
    # Optionally initialize the database and enable automatic start:
    sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
    sudo systemctl enable postgresql-15
    sudo systemctl start postgresql-15

I followed the above steps marked in blue.


[root@rac7 ~]# 
[root@rac7 ~]# sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Loaded plugins: langpacks, ulninfo
pgdg-redhat-repo-latest.noarch.rpm                                                                                   |  10 kB  00:00:00     
Examining /var/tmp/yum-root-cf0rnV/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-38PGDG.noarch
Marking /var/tmp/yum-root-cf0rnV/pgdg-redhat-repo-latest.noarch.rpm as an update to pgdg-redhat-repo-42.0-8.noarch
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-8 will be updated
---> Package pgdg-redhat-repo.noarch 0:42.0-38PGDG will be an update
--> Finished Dependency Resolution
ol7_UEKR5/x86_64                                                                                                     | 3.0 kB  00:00:00     
ol7_UEKR5/x86_64/updateinfo                                                                                          | 429 kB  00:00:00     
ol7_UEKR5/x86_64/primary_db                                                                                          |  75 MB  00:00:20     
ol7_latest/x86_64                                                                                                    | 3.6 kB  00:00:00     
ol7_latest/x86_64/updateinfo                                                                                         | 3.6 MB  00:00:00     
ol7_latest/x86_64/primary_db                                                                                         |  49 MB  00:00:11     
https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
pgdg12/7Server/x86_64                                                                                                | 3.6 kB  00:00:00     
pgdg12/7Server/x86_64/group_gz                                                                                       |  246 B  00:00:00     
pgdg12/7Server/x86_64/primary_db                                                                                     | 408 kB  00:00:00     
https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7Server-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
Dependencies Resolved
============================================================================================================================================
 Package                          Arch                   Version                      Repository                                       Size
============================================================================================================================================
Updating:
 pgdg-redhat-repo                 noarch                 42.0-38PGDG                  /pgdg-redhat-repo-latest.noarch                  12 k
Transaction Summary
============================================================================================================================================
Upgrade  1 Package
Total size: 12 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 19 pre-existing rpmdb problem(s), 'yum check' output follows:
compat-gcc-44-c++-4.4.7-8.el7.x86_64 has missing requires of compat-gcc-44 = ('0', '4.4.7', '8.el7')
1:compat-glibc-headers-2.12-4.el7.x86_64 has missing requires of compat-glibc = ('1', '2.12', '4.el7')
gcc-4.8.5-36.0.1.el7.x86_64 has missing requires of cpp = ('0', '4.8.5', '36.0.1.el7')
gcc-c++-4.8.5-36.0.1.el7.x86_64 has missing requires of libstdc++-devel = ('0', '4.8.5', '36.0.1.el7')
gcc-gfortran-4.8.5-36.0.1.el7.x86_64 has missing requires of libgfortran = ('0', '4.8.5', '36.0.1.el7')
gcc-gfortran-4.8.5-36.0.1.el7.x86_64 has missing requires of libgfortran.so.3()(64bit)
gcc-gfortran-4.8.5-36.0.1.el7.x86_64 has missing requires of libquadmath = ('0', '4.8.5', '36.0.1.el7')
gcc-gfortran-4.8.5-36.0.1.el7.x86_64 has missing requires of libquadmath-devel = ('0', '4.8.5', '36.0.1.el7')
gcc-gnat-4.8.5-36.0.1.el7.x86_64 has missing requires of libgnat = ('0', '4.8.5', '36.0.1.el7')
gcc-gnat-4.8.5-36.0.1.el7.x86_64 has missing requires of libgnat-devel = ('0', '4.8.5', '36.0.1.el7')
gcc-objc-4.8.5-36.0.1.el7.x86_64 has missing requires of libobjc = ('0', '4.8.5', '36.0.1.el7')
gcc-objc-4.8.5-36.0.1.el7.x86_64 has missing requires of libobjc.so.4()(64bit)
glib2-2.56.1-2.el7.x86_64 is a duplicate with glib2-2.46.2-4.el7.x86_64
glibc-2.17-260.0.9.el7.x86_64 is a duplicate with glibc-2.17-157.el7.x86_64
glibc-common-2.17-260.0.9.el7.x86_64 is a duplicate with glibc-common-2.17-157.el7.x86_64
glibc-devel-2.17-157.el7.x86_64 has missing requires of glibc-headers = ('0', '2.17', '157.el7')
libstdc++-4.8.5-36.0.1.el7.x86_64 is a duplicate with libstdc++-4.8.5-11.el7.x86_64
libstdc++-devel-4.8.5-11.el7.i686 has missing requires of libstdc++(x86-32) = ('0', '4.8.5', '11.el7')
libstdc++-devel-4.8.5-11.el7.i686 has missing requires of libstdc++.so.6
  Updating   : pgdg-redhat-repo-42.0-38PGDG.noarch                                                                                      1/2 
  Cleanup    : pgdg-redhat-repo-42.0-8.noarch                                                                                           2/2 
  Verifying  : pgdg-redhat-repo-42.0-38PGDG.noarch                                                                                      1/2 
  Verifying  : pgdg-redhat-repo-42.0-8.noarch                                                                                           2/2 
Updated:
  pgdg-redhat-repo.noarch 0:42.0-38PGDG                                                                                                     
Complete!
[root@rac7 ~]# 


=========================================================================
[root@rac7 ~]# 
[root@rac7 ~]# sudo yum install -y postgresql15-server
Loaded plugins: langpacks, ulninfo
pgdg-common/7Server/x86_64/signature                                                                                 |  665 B  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Importing GPG key 0x73E3B907:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: f245 f0bf 96ac 1827 44ca ff2e 64fa ce11 73e3 b907
 Package    : pgdg-redhat-repo-42.0-38PGDG.noarch (installed)
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
pgdg-common/7Server/x86_64/signature                                                                                 | 2.9 kB  00:00:00 !!! 
pgdg13/7Server/x86_64/signature                                                                                      |  665 B  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Importing GPG key 0x73E3B907:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: f245 f0bf 96ac 1827 44ca ff2e 64fa ce11 73e3 b907
 Package    : pgdg-redhat-repo-42.0-38PGDG.noarch (installed)
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
pgdg13/7Server/x86_64/signature                                                                                      | 3.6 kB  00:00:00 !!! 
pgdg14/7Server/x86_64/signature                                                                                      |  665 B  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Importing GPG key 0x73E3B907:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: f245 f0bf 96ac 1827 44ca ff2e 64fa ce11 73e3 b907
 Package    : pgdg-redhat-repo-42.0-38PGDG.noarch (installed)
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
pgdg14/7Server/x86_64/signature                                                                                      | 3.6 kB  00:00:00 !!! 
pgdg15/7Server/x86_64/signature                                                                                      |  665 B  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Importing GPG key 0x73E3B907:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: f245 f0bf 96ac 1827 44ca ff2e 64fa ce11 73e3 b907
 Package    : pgdg-redhat-repo-42.0-38PGDG.noarch (installed)
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
pgdg15/7Server/x86_64/signature                                                                                      | 3.6 kB  00:00:00 !!! 
(1/7): pgdg14/7Server/x86_64/group_gz                                                                                |  245 B  00:00:00     
(2/7): pgdg15/7Server/x86_64/group_gz                                                                                |  247 B  00:00:00     
(3/7): pgdg13/7Server/x86_64/group_gz                                                                                |  246 B  00:00:01     
(4/7): pgdg15/7Server/x86_64/primary_db                                                                              | 156 kB  00:00:00     
(5/7): pgdg13/7Server/x86_64/primary_db                                                                              | 333 kB  00:00:02     
(6/7): pgdg14/7Server/x86_64/primary_db                                                                              | 250 kB  00:00:02     
(7/7): pgdg-common/7Server/x86_64/primary_db                                                                         | 202 kB  00:00:03     
Resolving Dependencies
--> Running transaction check
---> Package postgresql15-server.x86_64 0:15.5-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql15-libs(x86-64) = 15.5-1PGDG.rhel7 for package: postgresql15-server-15.5-1PGDG.rhel7.x86_64
--> Processing Dependency: postgresql15(x86-64) = 15.5-1PGDG.rhel7 for package: postgresql15-server-15.5-1PGDG.rhel7.x86_64
--> Processing Dependency: libzstd.so.1()(64bit) for package: postgresql15-server-15.5-1PGDG.rhel7.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql15-server-15.5-1PGDG.rhel7.x86_64
--> Running transaction check
---> Package libzstd.x86_64 0:1.4.4-1.el7 will be installed
---> Package postgresql15.x86_64 0:15.5-1PGDG.rhel7 will be installed
---> Package postgresql15-libs.x86_64 0:15.5-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================
 Package                                Arch                      Version                                Repository                    Size
============================================================================================================================================
Installing:
 postgresql15-server                    x86_64                    15.5-1PGDG.rhel7                       pgdg15                       5.8 M
Installing for dependencies:
 libzstd                                x86_64                    1.4.4-1.el7                            ol7_UEKR5                    259 k
 postgresql15                           x86_64                    15.5-1PGDG.rhel7                       pgdg15                       1.6 M
 postgresql15-libs                      x86_64                    15.5-1PGDG.rhel7                       pgdg15                       285 k
Transaction Summary
============================================================================================================================================
Install  1 Package (+3 Dependent packages)
Total download size: 7.9 M
Installed size: 34 M
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/ol7_UEKR5/packages/libzstd-1.4.4-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Public key for libzstd-1.4.4-1.el7.x86_64.rpm is not installed
(1/4): libzstd-1.4.4-1.el7.x86_64.rpm                                                                                | 259 kB  00:00:00     
warning: /var/cache/yum/x86_64/7Server/pgdg15/packages/postgresql15-libs-15.5-1PGDG.rhel7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 73e3b907: NOKEY
Public key for postgresql15-libs-15.5-1PGDG.rhel7.x86_64.rpm is not installed
(2/4): postgresql15-libs-15.5-1PGDG.rhel7.x86_64.rpm                                                                 | 285 kB  00:00:01     
(3/4): postgresql15-15.5-1PGDG.rhel7.x86_64.rpm                                                                      | 1.6 MB  00:00:02     
(4/4): postgresql15-server-15.5-1PGDG.rhel7.x86_64.rpm                                                               | 5.8 MB  00:00:12     
--------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                       587 kB/s | 7.9 MB  00:00:13     
Retrieving key from file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Importing GPG key 0x73E3B907:
 Userid     : "PostgreSQL RPM Repository <pgsql-pkg-yum@lists.postgresql.org>"
 Fingerprint: f245 f0bf 96ac 1827 44ca ff2e 64fa ce11 73e3 b907
 Package    : pgdg-redhat-repo-42.0-38PGDG.noarch (installed)
 From       : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Importing GPG key 0xEC551F03:
 Userid     : "Oracle OSS group (Open Source Software group) <build@oss.oracle.com>"
 Fingerprint: 4214 4123 fecf c55b 9086 313d 72f9 7b74 ec55 1f03
 Package    : 7:oraclelinux-release-7.6-1.0.15.el7.x86_64 (@anaconda/7.6)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libzstd-1.4.4-1.el7.x86_64                                                                                               1/4 
  Installing : postgresql15-libs-15.5-1PGDG.rhel7.x86_64                                                                                2/4 
  Installing : postgresql15-15.5-1PGDG.rhel7.x86_64                                                                                     3/4 
  Installing : postgresql15-server-15.5-1PGDG.rhel7.x86_64                                                                              4/4 
  Verifying  : postgresql15-15.5-1PGDG.rhel7.x86_64                                                                                     1/4 
  Verifying  : postgresql15-server-15.5-1PGDG.rhel7.x86_64                                                                              2/4 
  Verifying  : postgresql15-libs-15.5-1PGDG.rhel7.x86_64                                                                                3/4 
  Verifying  : libzstd-1.4.4-1.el7.x86_64                                                                                               4/4 
Installed:
  postgresql15-server.x86_64 0:15.5-1PGDG.rhel7                                                                                             
Dependency Installed:
  libzstd.x86_64 0:1.4.4-1.el7          postgresql15.x86_64 0:15.5-1PGDG.rhel7          postgresql15-libs.x86_64 0:15.5-1PGDG.rhel7         
Complete!
[root@rac7 ~]# 
[root@rac7 ~]# 


[root@rac7]# id postgres
uid=26(postgres) gid=26(postgres) groups=26(postgres)

Note:- Once installation is done, postgres OS level user is already created by installation process.





B
elow directories structures are created :-

$]  cd /usr/pgsql-15






bin, lib and share folders are created ....

Let us see what are the files inside BIN location






Files inside lib location :-








[root@rac7 ~]# 
[root@rac7 ~]# sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
Initializing database ... OK
[root@rac7 ~]# 
[root@rac7 ~]# 
[root@rac7 ~]# sudo systemctl enable postgresql-15
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-15.service to /usr/lib/systemd/system/postgresql-15.service.
[root@rac7 ~]# 
[root@rac7 ~]# 
[root@rac7 ~]# sudo systemctl start postgresql-15
Job for postgresql-15.service failed because the control process exited with error code. See "systemctl status postgresql-15.service" and "journalctl -xe" for details.
[root@rac7 ~]# 
[root@rac7 ~]# 




[root@rac7]# id postgres
uid=26(postgres) gid=26(postgres) groups=26(postgres)

Note:Once installation is done, postgres OS level user is already created by installation process.


[root@rac7 ~]# mkdir -p /u02/PostgreSQL/15
[root@rac7 ~]#
[root@rac7 ~]#
[root@rac7 ~]# chown -R postgres:postgres /u02/PostgreSQL/15
[root@rac7 ~]#
[root@rac7 ~]# chmod 700 -R /u02/PostgreSQL/15
[root@rac7 ~]#


Switch to postgres - user ---->>>>>


[root@rac7]#  su - postgres


Default directory created --> /var/lib/pgsql -- 


[root@rac201 ~]# su - postgres
[postgres@rac201 ~]$
[postgres@rac201 ~]$ pwd
/var/lib/pgsql


[postgres@rac7 ~]$
[postgres@rac7~]$ ps -ef| grep postgres

postgres    6087       1  0 19:09 ?        00:00:00 /usr/pgsql-15/bin/postmaster -D /var/lib/pgsql/15/data/
postgres    6089    6087  0 19:09 ?        00:00:00 postgres: logger
postgres    6090    6087  0 19:09 ?        00:00:00 postgres: checkpointer
postgres    6091    6087  0 19:09 ?        00:00:00 postgres: background writer
postgres    6093    6087  0 19:09 ?        00:00:00 postgres: walwriter
postgres    6094    6087  0 19:09 ?        00:00:00 postgres: autovacuum launcher
postgres    6095    6087  0 19:09 ?        00:00:00 postgres: logical replication launcher
root        6518    5476  0 19:19 pts/2    00:00:00 su - postgres
postgres    6519    6518  0 19:19 pts/2    00:00:00 -bash
root        7188    6847  0 19:32 pts/2    00:00:00 su - postgres
postgres    7189    7188  0 19:32 pts/2    00:00:00 -bash
postgres    7280    7189  0 19:33 pts/2    00:00:00 ps -ef
postgres    7281    7189  0 19:33 pts/2    00:00:00 grep --color=auto postgres



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



Let's initdb the New postgresql:-


-bash-4.2$ 

-bash-4.2$ /usr/pgsql-15/bin/initdb -D /u02/PostgreSQL/15

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 /u02/PostgreSQL/15 ... 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:


    /usr/pgsql-15/bin/pg_ctl -D /u02/PostgreSQL/15 -l logfile start


-bash-4.2$ 

-bash-4.2$ /usr/pgsql-15/bin/pg_ctl -D /u02/PostgreSQL/15 -l logfile start

waiting for server to start.... stopped waiting

pg_ctl: could not start server

Examine the log output.




-bash-4.2$ 

-bash-4.2$ ls -lrt

total 132

-rw------- 1 postgres postgres     3 Jan 21 01:16 PG_VERSION

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_twophase

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_tblspc

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_stat_tmp

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_snapshots

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_serial

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_replslot

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_notify

drwx------ 4 postgres postgres  4096 Jan 21 01:16 pg_multixact

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_dynshmem

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_commit_ts

-rw------- 1 postgres postgres 29458 Jan 21 01:16 postgresql.conf

-rw------- 1 postgres postgres    88 Jan 21 01:16 postgresql.auto.conf

-rw------- 1 postgres postgres  1636 Jan 21 01:16 pg_ident.conf

-rw------- 1 postgres postgres  4789 Jan 21 01:16 pg_hba.conf

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_xact

drwx------ 3 postgres postgres  4096 Jan 21 01:16 pg_wal

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_subtrans

drwx------ 2 postgres postgres  4096 Jan 21 01:16 global

drwx------ 5 postgres postgres  4096 Jan 21 01:16 base

drwx------ 4 postgres postgres  4096 Jan 21 01:16 pg_logical

drwx------ 2 postgres postgres  4096 Jan 21 01:16 pg_stat

drwx------ 2 postgres postgres  4096 Jan 21 01:16 log

-rw------- 1 postgres postgres   187 Jan 21 01:16 logfile

-rw------- 1 postgres postgres    30 Jan 21 01:16 current_logfiles

-bash-4.2$ pwd

/u02/PostgreSQL/15

-bash-4.2$ cat logfile

2024-01-21 01:16:40.567 IST [30062] LOG:  redirecting log output to logging collector process

2024-01-21 01:16:40.567 IST [30062] HINT:  Future log output will appear in directory "log".

-bash-4.2$ 

-bash-4.2$ cat current_logfiles

stderr log/postgresql-Sun.log

-bash-4.2$ 

-bash-4.2$ cd log

-bash-4.2$ ls -lrt

total 4

-rw------- 1 postgres postgres 638 Jan 21 01:16 postgresql-Sun.log

-bash-4.2$ 

-bash-4.2$ 

-bash-4.2$ cat postgresql-Sun.log

2024-01-21 01:16:40.567 IST [30062] LOG:  starting PostgreSQL 15.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit

2024-01-21 01:16:40.567 IST [30062] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use

2024-01-21 01:16:40.567 IST [30062] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

2024-01-21 01:16:40.567 IST [30062] WARNING:  could not create listen socket for "localhost"

2024-01-21 01:16:40.567 IST [30062] FATAL:  could not create any TCP/IP sockets

2024-01-21 01:16:40.568 IST [30062] LOG:  database system is shut down

-bash-4.2$ 



-bash-4.2$ vi postgresql.conf ----> Changed the port number in conf file

 port = 5454




-bash-4.2$ 

-bash-4.2$ /usr/pgsql-15/bin/pg_ctl -D /u02/PostgreSQL/15 -l logfile start

waiting for server to start.... done

server started

-bash-4.2$ 




postgres  25085  25061  0 00:43 pts/0    00:00:00 -bash

postgres  30824      1  0 01:22 ?        00:00:00 /usr/pgsql-15/bin/postgres -D /u02/PostgreSQL/15

postgres  30826  30824  0 01:22 ?        00:00:00 postgres: logger 

postgres  30827  30824  0 01:22 ?        00:00:00 postgres: checkpointer 

postgres  30828  30824  0 01:22 ?        00:00:00 postgres: background writer 

postgres  30830  30824  0 01:22 ?        00:00:00 postgres: walwriter 

postgres  30831  30824  0 01:22 ?        00:00:00 postgres: autovacuum launcher 

postgres  30832  30824  0 01:22 ?        00:00:00 postgres: logical replication launcher 

postgres  31062  25085  0 01:24 pts/0    00:00:00 ps -ef

postgres  31063  25085  0 01:24 pts/0    00:00:00 grep --color=auto postgres



-bash-4.2$ 

-bash-4.2$ psql -p 5454

psql (10.9, server 15.5)

WARNING: psql major version 10, server major version 15.

         Some psql features might not work.

Type "help" for help.


postgres=# 

postgres=# 

postgres=# select version();

                                                 version                                                 

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

 PostgreSQL 15.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit

(1 row)


postgres=# 

postgres=# show server_version;

 server_version 

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

 15.5

(1 row)


postgres=# show data_directory;

   data_directory   

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

 /u02/PostgreSQL/15

(1 row)




Master and Slave - Sync check - PostgreSQL

  1) Run the below Query on Primary:- SELECT     pid,     usename,     application_name,     client_addr,     state,     sync_state,     sen...