Red hat linux postgresql

How to install PostgreSQL 15 on RedHat Linux 8|Fedora 36

In this article, we are going to learn how to install and get PostgreSQL 15 up and running on a RedHat Linux 8 and Fedora 36 server. PostgreSQL is a powerful, open-source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.

Notable Features introduced for PostgreSQL 15.

  • It removes both the long deprecated exclusive backup and support from Python 2 from PL/Python.
  • It revokes the CREATE permission from all users except for the database owner from the default.
  • It adds the new built-in extension, the pg_walinspect, that lets users inspect the contents of write-ahead log files directly from an SQL interface.
  • Server-level statistics are now collected in shared memory, eliminating the statistics collector process and periodically writing this data to disk.
  • It makes it possible to make an ICU Collation the default collation for a cluster or an individual database.
  • It introduces the new logging format jsonlog which outputs log data using a defined json structure and allows PostgreSQL logs to be processed in structured logging systems. This gives database administrators more flexibility on how users can manage PostgreSQL configurations.
  • It provides more flexibility for managing logical replication. It introduces row filtering and column lists for publishers, letting users choose to replicate a subset of data from a table.
  • It added a feature to simplify conflict management, including the ability to skip replaying a conflicting transaction and to automatically disable a subscription if an error is detected.

1. Update your system packages

Let’s begin by refreshing our system’s local index files using the following command.

First check the default version of Apstream for PostgreSQL with the following command:

$ sudo dnf module list postgresql Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) 14 kB/s | 4.5 kB 00:00 Red Hat Enterprise Linux 8 for x86_64 - BaseOS from RHUI (RPMs) 95 kB/s | 4.1 kB 00:00 Red Hat Ansible Engine 2 for RHEL 8 (RPMs) from RHUI 97 kB/s | 4.0 kB 00:00 RHUI Client Configuration Server 8 46 kB/s | 2.0 kB 00:00 Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module postgresql 10 [d] client, server [d] PostgreSQL server and client module postgresql 12 client, server [d] PostgreSQL server and client module postgresql 13 client, server [d] PostgreSQL server and client module 

2. Install PostgreSQL 15 on RedHat Linux 8

In order to run PostgreSQL 15 on RedHat Linux 8, we are supposed to create the file repository configuration so that PostgreSQL will be available for installation.

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

Next, we need to disable the default PostgreSQL 10 from the system so that it can allow you to install the newer version.

$ sudo dnf -qy module disable postgresql #output Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project [email protected]>" Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project [email protected]>" Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project [email protected]>" Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project [email protected]>" Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project [email protected]>" Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project [email protected]>" Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project [email protected]>" Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG

Now we can install PostgreSQL

sudo yum install -y postgresql15-server

You should be in a position to see the output below.

Package Architecture Versio Repository Size Installing: postgresql15-server x86_64 15.0-1PGDG.rhel8 pgdg15 5.8 M Installing dependencies: libicu x86_64 60.3-2.el8_1 rhel-8-baseos-rhui-rpms 8.8 M lz4 x86_64 1.8.3-3.el8_4 rhel-8-baseos-rhui-rpms 104 k postgresql15 x86_64 15.0-1PGDG.rhel8 pgdg15 1.6 M postgresql15-libs x86_64 15.0-1PGDG.rhel8 pgdg15 287 k

3. Configure PostgreSQL

Enable PostgreSQL 15 service and initialize the database

Читайте также:  Get domain name linux

We can initialize our database first with this command:

$ sudo /usr/pgsql-15/bin/postgresql-15-setup initdb

To enable PostgreSQL to use the following command.

sudo systemctl enable postgresql-15

We need to start PostgreSQL after we have enabled it.

sudo systemctl start postgresql-15

Lastly, let’s check the status of PostgreSQL

sudo systemctl status postgresql-15

You should be in a position to see the following as the output.

● postgresql-15.service - PostgreSQL 15 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-10-14 09:49:11 UTC; 1min 2s ago Docs: https://www.postgresql.org/docs/15/static/ Process: 56300 ExecStartPre=/usr/pgsql-15/bin/postgresql-15-check-db-dir $ (code=exited, status=0/SUCCESS) Main PID: 56306 (postmaster) Tasks: 7 (limit: 4700) Memory: 21.3M CGroup: /system.slice/postgresql-15.service ├─56306 /usr/pgsql-15/bin/postmaster -D /var/lib/pgsql/15/data/ ├─56307 postgres: logger ├─56308 postgres: checkpointer ├─56309 postgres: background writer ├─56311 postgres: walwriter ├─56312 postgres: autovacuum launcher └─56313 postgres: logical replication launcher Oct 14 09:49:11 ip-172-31-92-33.ec2.internal systemd[1]: Starting PostgreSQL 15 database server. Oct 14 09:49:11 ip-172-31-92-33.ec2.internal postmaster[56306]: 2022-10-14 09:49:11.188 UTC [56306] LOG: redirecting log output to logging co> Oct 14 09:49:11 ip-172-31-92-33.ec2.internal postmaster[56306]: 2022-10-14 09:49:11.188 UTC [56306] HINT: Future log output will appear in di> Oct 14 09:49:11 ip-172-31-92-33.ec2.internal systemd[1]: Started PostgreSQL 15 database server.

To use PostgreSQL we use the following command.

$ sudo -u postgres psql could not change directory to "/home/ec2-user": Permission denied psql (15.0) Type "help" for help. postgres=# show server_version; server_version ---------------- 15.0 (1 row) postgres=# 

4. Uninstall PostgreSQL

Whenever you want to remove PostgreSQL from your system for any reason known to you, uninstall using the following procedure.

First, you need to list the PostgreSQL packages to enable you to determine what you need to remove.

$ rpm -qa | grep postgres postgresql15-libs-15.0-1PGDG.rhel8.x86_64 postgresql15-15.0-1PGDG.rhel8.x86_64 postgresql15-server-15.0-1PGDG.rhel8.x86_64

To remove all packages related to PostgreSQL, we use the wildcard operator like this

Читайте также:  Making windows look like linux

Conclusion

Congratulations! You have installed PostgreSQL 15 on RedHat Linux 8, and you have also learned why PostgreSQL is important to large data sets. For more information always consult the PostgreSQL documentation.

Источник

Linux downloads (Red Hat family)

PostgreSQL is available on these platforms by default. However, each version of the platform normally «snapshots» a specific version of PostgreSQL that is then supported throughout the lifetime of this platform. Since this can often mean a different version than preferred, the PostgreSQL project provides a repository of packages of all supported versions for the most common distributions.

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
  • CentOS (7 and 6 only)
  • Oracle Linux
  • Fedora *

* Note: due to the shorter support cycle on Fedora, all supported versions of PostgreSQL are not available on this platform. We do not recommend using Fedora for server deployments.

To use the PostgreSQL Yum Repository, follow these steps:

  1. Select version:
  2. Select platform:
  3. Select architecture:
  4. Copy, paste and run the relevant parts of the setup script:

Included in Distribution

These distributions all include PostgreSQL by default. To install PostgreSQL from these repositories, use the yum command on RHEL 6 and 7:

yum install postgresql-server

or dnf command on RHEL 8 and Fedora:

dnf install postgresql-server

Which version of PostgreSQL you get will depend on the version of the distribution:

Distribution Version
RHEL / Rocky Linux 9 13
RHEL / Rocky Linux / OL 8 13, 12, 10 and 9.6 via modules
RHEL / CentOS / SL / OL 7 9.2 (also supplies package rh-postgresql10, rh-postgresql96, rh-postgresql95 and rh-postgresql94 via SCL)
RHEL / CentOS / SL / OL 6 8.4 (also supplies package rh-postgresql96, via SCL)
Fedora 37 14
Fedora 36 14

Other Red Hat family distributions may ship a different version of PostgreSQL by default, check with your distribution vendor to be sure.

The repository contains many different packages including third party addons. The most common and important packages are (substitute the version number as required):

postgresql-client libraries and client binaries
postgresql-server core database server
postgresql-contrib additional supplied modules
postgresql-devel libraries and headers for C language development

Post-installation

Due to policies for Red Hat family distributions, the PostgreSQL installation will not be enabled for automatic start or have the database initialized automatically. To make your database installation complete, you need to perform the following steps, based on your distribution:

For RHEL / Rocky Linux / CentOS / SL / OL 7, 8, 9 or Fedora 36 and later derived distributions:

postgresql-setup --initdb systemctl enable postgresql.service systemctl start postgresql.service

For RHEL / CentOS / SL / OL 6

service postgresql initdb chkconfig postgresql on

Direct RPM download

If you cannot, or do not want to, use the yum based installation method, all the RPMs that are in the yum repository are available for direct download and manual installation as well.

Copyright © 1996-2023 The PostgreSQL Global Development Group

Источник

Оцените статью
Adblock
detector