In this section of installation and configuration, we
are going to see how to set up PostgreSQL DB on Linux and after installation of
it. We will set OS-level variables using user bash-profile which helps us to
access the PostgreSQL cluster easily. Below are the details of the infrastructure
details which we use to configure the PostgreSQL environment.
Deployment Diagram:
HOST NAME: PG_V16.example.com |
|
Linux Version |
Red Hat Enterprise Linux release 8.6 (Ootpa) |
PG Version |
PostgreSQL 16.1 |
In this
QuickStart, we learn how to:
·
Prerequisite
Steps
·
Installation
of PostgreSQL v16 using Yum
·
Validation
Step-1 Prerequisite Steps
-
Go to the PostgreSQL installation page, read it
carefully select the correct option as per your current infrastructure copy the
installation script, and execute step by step on your Linux machine
https://www.postgresql.org/download/linux/redhat/
Step-2 Installation
of PostgreSQL v16 using Yum
Execute the below command one-by-one
#sudo
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
#sudo
dnf -qy module disable postgresql
#sudo dnf install -y postgresql16-server
#sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
#sudo systemctl enable postgresql-16
#sudo
systemctl start postgresql-16
Step-3 Validation
-
Connect the Postgres user once it is present
then reset its password to your future convenience
[root@PG-V16
~]# su - postgres
[postgres@PG-V16
~]$
[postgres@PG-V16
~]$
[postgres@PG-V16
~]$ exit
logout
[root@PG-V16
~]# passwd postgres
Changing
password for user postgres.
New
password:
BAD
PASSWORD: The password is shorter than 8 characters
Retype
new password:
passwd:
all authentication tokens updated successfully.
[root@PG-V16
~]#
-
Set the Bash_profile
[root@PG-V16 ~]# su
- postgres
[postgres@PG-V16 ~]$
cat .bash_profile
[ -f /etc/profile ]
&& source /etc/profile
PGDATA=/var/lib/pgsql/16/data
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
[postgres@PG-V16 ~]$
INFORMATION:
instead of changing bash_profile lets change the .pgsql_profile file
[postgres@PG-V16 ~]$ cat
.bash_profile
[ -f /etc/profile ] &&
source /etc/profile
PGDATA=/var/lib/pgsql/16/data
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
[postgres@PG-V16 ~]$ cat
/var/lib/pgsql/.pgsql_profile
export
PGDATA=/var/lib/pgsql/16/data
export PGPORT=5432
export
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/pgsql-16/bin
[postgres@PG-V16 ~]$ env | grep
PG
HOSTNAME=PG-V16.example.com
PGDATA=/var/lib/pgsql/16/data
PGPORT=5432
[postgres@PG-V16 ~]$
-
Connect to psql and check the PostgreSQL Version
[postgres@PG-V16
~]$ psql
psql
(16.1)
Type
"help" for help.
postgres=#
select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 16.1 on x86_64-pc-linux-gnu,
compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20), 64-bit
(1
row)
postgres=#
[postgres@PG-V16
~]$ psql --version
psql
(PostgreSQL) 16.1
[postgres@PG-V16
~]$
No comments:
Post a Comment