This Blog is a follow up uf one of my older Blogs and my Article at heise.de:
Blog at dbi-services.com
Article at heise.de
For RHEL 8 at its clones like AlmaLinux, CentOS, Oracle Linux and Rocky Linux i have written a shell script to automated recurring setups.
This is used for a cloud project using own virtual machines.
The script automates the steps i have described at my article at heise.de.
The script has an help opportunity, -h tell how to use it:
$ [[root@rocky ~]$ sh pg_setup.sh -h $ [[root@rocky ~]$ PostgreSQL Installation on AlmaLinux 8 / CentOS 8 / Oracle Linxu 8 / RHEL 8 / Rocky Linux 8 $ [[root@rocky ~]$ $ [[root@rocky ~]$ Usage: $ [[root@rocky ~]$ [OPTION] $ [[root@rocky ~]$ $ [[root@rocky ~]$ Options: $ [[root@rocky ~]$ -v Major Release of Postgresql (required) $ [[root@rocky ~]$ -t If the System is Primary / Single (p) or Secondary (s) in a Cluster (required) $ [[root@rocky ~]$ -h prints this help $ [[root@rocky ~]$
So the script supports any version of PostgreSQL supported by the PostgreSQL Community.
Required is an own volume or folder /pgdata or even per PostgreSQL version /pgdata/Major Releae, so for PostgreSQL 13 /pgdata/13/, if the the folder with the release number is not existing, it will be created.
The code of this script:
$ [[root@rocky ~]$ ############################################################################################ $ [[root@rocky ~]$ # Installing PostgreSQL on AlmaLinux 8 / CentOS 8 / Oracle Linux 8 / RHEL 8 /Rocky Linux 8 # $ [[root@rocky ~]$ # including opening port 5432 # $ [[root@rocky ~]$ # By Karsten Lenz dbi-services sa 2020.06.16 # $ [[root@rocky ~]$ ############################################################################################ $ [[root@rocky ~]$ $ [[root@rocky ~]$ #!/bin/bash $ [[root@rocky ~]$ $ [[root@rocky ~]$ echo "PostgreSQL Installation on AlmaLinux 8 / CentOS 8 / Oracle Linxu 8 / RHEL 8 / Rocky Linux 8" $ [[root@rocky ~]$ echo "" $ [[root@rocky ~]$ $ [[root@rocky ~]$ function printHelp() { $ [[root@rocky ~]$ printf "Usage:\n" $ [[root@rocky ~]$ printf "${progName} [OPTION]\n\n" $ [[root@rocky ~]$ printf "Options:\n" $ [[root@rocky ~]$ printf "\t -v \t\tMajor Release of Postgresql (required)\n" $ [[root@rocky ~]$ printf "\t -t \t\tIf the System is Primary / Single (p) or Secondary (s) in a Cluster (required)\n" $ [[root@rocky ~]$ printf "\t -h \t\t\t\tprints this help\n" $ [[root@rocky ~]$ } $ [[root@rocky ~]$ $ [[root@rocky ~]$ while getopts v:t:h option 2>/dev/null $ [[root@rocky ~]$ do $ [[root@rocky ~]$ case "${option}" $ [[root@rocky ~]$ in $ [[root@rocky ~]$ v) VERSION=${OPTARG};; $ [[root@rocky ~]$ t) TYPE=${OPTARG};; $ [[root@rocky ~]$ h) printHelp; exit 2;; $ [[root@rocky ~]$ *) printf "Unsupported option or parameter value missing '$*'\n"; $ [[root@rocky ~]$ printf "Run ${progName} -h to print help\n"; exit 1;; $ [[root@rocky ~]$ esac $ [[root@rocky ~]$ done $ [[root@rocky ~]$ $ [[root@rocky ~]$ echo "Disabling PostgreSQL Packages provided by the Distros" $ [[root@rocky ~]$ dnf -y module disable postgresql $ [[root@rocky ~]$ $ [[root@rocky ~]$ echo "Adding PostgreSQL Repository" $ [[root@rocky ~]$ dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm $ [[root@rocky ~]$ $ [[root@rocky ~]$ echo "Installing PostgreSQL Packages including barman, repmgr and pg_stat_kcache" $ [[root@rocky ~]$ dnf -y install postgresql$VERSION postgresql$VERSION-libs postgresql$VERSION-server postgresql$VERSION-contrib pg_stat_kcache$VERSION repmgr$VERSION barman $ [[root@rocky ~]$ $ [[root@rocky ~]$ # creating empty override.conf for postgresql service $ [[root@rocky ~]$ mkdir /etc/systemd/system/postgresql-$VERSION.service.d $ [[root@rocky ~]$ $ [[root@rocky ~]$ # define vriable for tee $ [[root@rocky ~]$ OVERRIDE_CONF=/etc/systemd/system/postgresql-$VERSION.service.d/override.conf $ [[root@rocky ~]$ touch $OVERRIDE_CONF $ [[root@rocky ~]$ $ [[root@rocky ~]$ # adding values to override.conf $ [[root@rocky ~]$ echo "[Service]" | tee -a $OVERRIDE_CONF $ [[root@rocky ~]$ echo "Environment=PGDATA=/pgdata/$VERSION/data" | tee -a $OVERRIDE_CONF $ [[root@rocky ~]$ $ [[root@rocky ~]$ $ [[root@rocky ~]$ # different steps for single/primary or standby $ [[root@rocky ~]$ if [ $TYPE == 'p' ] $ [[root@rocky ~]$ then $ [[root@rocky ~]$ echo "Initialyze PostgreSQL $VERSION" $ [[root@rocky ~]$ /usr/pgsql-$VERSION/bin/postgresql-$VERSION-setup initdb $ [[root@rocky ~]$ $ [[root@rocky ~]$ echo "Enable PostgreSQL Service" $ [[root@rocky ~]$ systemctl enable postgresql-$VERSION.service $ [[root@rocky ~]$ $ [[root@rocky ~]$ echo "Start PostgreSQL $VERSION" $ [[root@rocky ~]$ systemctl start postgresql-$VERSION.service $ [[root@rocky ~]$ $ [[root@rocky ~]$ elif [ $TYPE == 's' ] $ [[root@rocky ~]$ then $ [[root@rocky ~]$ echo "Initialyze PostgreSQL $VERSION" $ [[root@rocky ~]$ /usr/pgsql-$VERSION/bin/postgresql-$VERSION-setup initdb $ [[root@rocky ~]$ $ [[root@rocky ~]$ echo "Enable PostgreSQL Service" $ [[root@rocky ~]$ systemctl enable postgresql-$VERSION.service $ [[root@rocky ~]$ fi $ [[root@rocky ~]$ $ [[root@rocky ~]$ # open port 5432 for PostgreSQL $ [[root@rocky ~]$ firewall-cmd --zone=public --permanent --add-port 5432/tcp $ [[root@rocky ~]$ firewall-cmd --reload
OK, lets install PostgreSQL 13 as single server, according to the help information the call is:
$ [[root@rocky ~]$ sh pg_setup.sh -v 13 -t s PostgreSQL Installation on AlmaLinux 8 / CentOS 8 / Oracle Linxu 8 / RHEL 8 / Rocky Linux 8 Disabling PostgreSQL Packages provided by the Distros Last metadata expiration check: 0:12:33 ago on Tue 15 Jun 2021 11:33:01 AM CEST. Dependencies resolved. ========================================================================================================================================================================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================================================================================================================================================================== Disabling modules: postgresql Transaction Summary ========================================================================================================================================================================================================================================================================================== Complete! Adding PostgreSQL Repository Last metadata expiration check: 0:12:34 ago on Tue 15 Jun 2021 11:33:01 AM CEST. pgdg-redhat-repo-latest.noarch.rpm 8.6 kB/s | 12 kB 00:01 Dependencies resolved. ========================================================================================================================================================================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================================================================================================================================================================== Installing: pgdg-redhat-repo noarch 42.0-17 @commandline 12 k Transaction Summary ========================================================================================================================================================================================================================================================================================== Install 1 Package Total size: 12 k Installed size: 11 k 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-17.noarch 1/1 Verifying : pgdg-redhat-repo-42.0-17.noarch 1/1 Installed: pgdg-redhat-repo-42.0-17.noarch Complete! Installing PostgreSQL Packages including barman, repmgr and pg_stat_kcache PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64 103 B/s | 195 B 00:01 PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64 1.6 MB/s | 1.7 kB 00:00 Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project " Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64 152 kB/s | 480 kB 00:03 PostgreSQL 13 for RHEL/CentOS 8 - x86_64 122 B/s | 195 B 00:01 PostgreSQL 13 for RHEL/CentOS 8 - x86_64 1.6 MB/s | 1.7 kB 00:00 Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project " Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG PostgreSQL 13 for RHEL/CentOS 8 - x86_64 130 kB/s | 359 kB 00:02 PostgreSQL 12 for RHEL/CentOS 8 - x86_64 136 B/s | 195 B 00:01 PostgreSQL 12 for RHEL/CentOS 8 - x86_64 1.6 MB/s | 1.7 kB 00:00 Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project " Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG PostgreSQL 12 for RHEL/CentOS 8 - x86_64 166 kB/s | 550 kB 00:03 PostgreSQL 11 for RHEL/CentOS 8 - x86_64 106 B/s | 195 B 00:01 PostgreSQL 11 for RHEL/CentOS 8 - x86_64 1.6 MB/s | 1.7 kB 00:00 Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project " Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG PostgreSQL 11 for RHEL/CentOS 8 - x86_64 212 kB/s | 747 kB 00:03 PostgreSQL 10 for RHEL/CentOS 8 - x86_64 103 B/s | 195 B 00:01 PostgreSQL 10 for RHEL/CentOS 8 - x86_64 1.6 MB/s | 1.7 kB 00:00 Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project " Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG PostgreSQL 10 for RHEL/CentOS 8 - x86_64 143 kB/s | 482 kB 00:03 PostgreSQL 9.6 for RHEL/CentOS 8 - x86_64 121 B/s | 195 B 00:01 PostgreSQL 9.6 for RHEL/CentOS 8 - x86_64 1.6 MB/s | 1.7 kB 00:00 Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project " Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG PostgreSQL 9.6 for RHEL/CentOS 8 - x86_64 174 kB/s | 490 kB 00:02 Dependencies resolved. ========================================================================================================================================================================================================================================================================================== Package Architecture Version Repository Size ========================================================================================================================================================================================================================================================================================== Installing: barman noarch 2.12-1.rhel8 pgdg-common 41 k pg_stat_kcache_13 x86_64 2.2.0-1.rhel8 pgdg13 46 k postgresql13 x86_64 13.3-2PGDG.rhel8 pgdg13 1.5 M postgresql13-contrib x86_64 13.3-2PGDG.rhel8 pgdg13 638 k postgresql13-libs x86_64 13.3-2PGDG.rhel8 pgdg13 413 k postgresql13-server x86_64 13.3-2PGDG.rhel8 pgdg13 5.5 M repmgr_13 x86_64 5.2.1-1.rhel8 pgdg13 293 k Installing dependencies: perl-Carp noarch 1.42-396.el8 baseos 29 k perl-Data-Dumper x86_64 2.167-399.el8 baseos 57 k perl-Digest noarch 1.17-395.el8 appstream 26 k perl-Digest-MD5 x86_64 2.55-396.el8 appstream 36 k perl-Encode x86_64 4:2.97-3.el8 baseos 1.5 M perl-Errno x86_64 1.28-419.el8 baseos 75 k perl-Exporter noarch 5.72-396.el8 baseos 33 k perl-File-Path noarch 2.15-2.el8 baseos 37 k perl-File-Temp noarch 0.230.600-1.el8 baseos 62 k perl-Getopt-Long noarch 1:2.50-4.el8 baseos 62 k perl-HTTP-Tiny noarch 0.074-1.el8 baseos 57 k perl-IO x86_64 1.38-419.el8 baseos 141 k perl-MIME-Base64 x86_64 3.15-396.el8 baseos 30 k perl-Net-SSLeay x86_64 1.88-1.module+el8.4.0+512+d4f0fc54 appstream 378 k perl-PathTools x86_64 3.74-1.el8 baseos 89 k perl-Pod-Escapes noarch 1:1.07-395.el8 baseos 19 k perl-Pod-Perldoc noarch 3.28-396.el8 baseos 85 k perl-Pod-Simple noarch 1:3.35-395.el8 baseos 212 k perl-Pod-Usage noarch 4:1.69-395.el8 baseos 33 k perl-Scalar-List-Utils x86_64 3:1.49-2.el8 baseos 67 k perl-Socket x86_64 4:2.027-3.el8 baseos 58 k perl-Storable x86_64 1:3.11-3.el8 baseos 97 k perl-Term-ANSIColor noarch 4.06-396.el8 baseos 45 k perl-Term-Cap noarch 1.17-395.el8 baseos 22 k perl-Text-ParseWords noarch 3.30-395.el8 baseos 17 k perl-Text-Tabs+Wrap noarch 2013.0523-395.el8 baseos 23 k perl-Time-Local noarch 1:1.280-1.el8 baseos 32 k perl-URI noarch 1.73-3.el8 appstream 115 k perl-Unicode-Normalize x86_64 1.25-396.el8 baseos 81 k perl-constant noarch 1.33-396.el8 baseos 24 k perl-interpreter x86_64 4:5.26.3-419.el8 baseos 6.3 M perl-libnet noarch 3.11-3.el8 appstream 120 k perl-libs x86_64 4:5.26.3-419.el8 baseos 1.6 M perl-macros x86_64 4:5.26.3-419.el8 baseos 71 k perl-parent noarch 1:0.237-1.el8 baseos 19 k perl-podlators noarch 4.11-1.el8 baseos 117 k perl-threads x86_64 1:2.21-2.el8 baseos 60 k perl-threads-shared x86_64 1.58-2.el8 baseos 47 k python3-argcomplete noarch 1.9.3-6.el8 appstream 59 k python3-argh noarch 0.26.1-8.el8 appstream 58 k python3-barman noarch 2.12-1.rhel8 pgdg-common 358 k python3-pip noarch 9.0.3-19.el8 appstream 19 k python3-psycopg2 x86_64 2.8.6-1.rhel8 pgdg-common 178 k python3-setuptools noarch 39.2.0-6.el8 baseos 162 k python36 x86_64 3.6.8-2.module+el8.3.0+120+426d8baf appstream 18 k Installing weak dependencies: perl-IO-Socket-IP noarch 0.39-5.el8 appstream 46 k perl-IO-Socket-SSL noarch 2.066-4.module+el8.4.0+512+d4f0fc54 appstream 297 k perl-Mozilla-CA noarch 20160104-7.module+el8.4.0+529+e3b3e624 appstream 14 k Enabling module streams: perl 5.26 perl-IO-Socket-SSL 2.066 perl-libwww-perl 6.34 python36 3.6 Transaction Summary ========================================================================================================================================================================================================================================================================================== Install 55 Packages Total download size: 21 M Installed size: 73 M Downloading Packages: (1/55): perl-Digest-1.17-395.el8.noarch.rpm 17 kB/s | 26 kB 00:01 (2/55): perl-Digest-MD5-2.55-396.el8.x86_64.rpm 24 kB/s | 36 kB 00:01 (3/55): perl-IO-Socket-IP-0.39-5.el8.noarch.rpm 28 kB/s | 46 kB 00:01 (4/55): perl-Mozilla-CA-20160104-7.module+el8.4.0+529+e3b3e624.noarch.rpm 105 kB/s | 14 kB 00:00 (5/55): perl-URI-1.73-3.el8.noarch.rpm 424 kB/s | 115 kB 00:00 (6/55): perl-libnet-3.11-3.el8.noarch.rpm 851 kB/s | 120 kB 00:00 (7/55): perl-Net-SSLeay-1.88-1.module+el8.4.0+512+d4f0fc54.x86_64.rpm 858 kB/s | 378 kB 00:00 (8/55): perl-IO-Socket-SSL-2.066-4.module+el8.4.0+512+d4f0fc54.noarch.rpm 508 kB/s | 297 kB 00:00 (9/55): python3-argcomplete-1.9.3-6.el8.noarch.rpm 425 kB/s | 59 kB 00:00 (10/55): python3-argh-0.26.1-8.el8.noarch.rpm 403 kB/s | 58 kB 00:00 (11/55): python3-pip-9.0.3-19.el8.noarch.rpm 128 kB/s | 19 kB 00:00 (12/55): python36-3.6.8-2.module+el8.3.0+120+426d8baf.x86_64.rpm 124 kB/s | 18 kB 00:00 (13/55): perl-Data-Dumper-2.167-399.el8.x86_64.rpm 299 kB/s | 57 kB 00:00 (14/55): perl-Carp-1.42-396.el8.noarch.rpm 144 kB/s | 29 kB 00:00 (15/55): perl-Errno-1.28-419.el8.x86_64.rpm 1.0 MB/s | 75 kB 00:00 (16/55): perl-Exporter-5.72-396.el8.noarch.rpm 449 kB/s | 33 kB 00:00 (17/55): perl-File-Path-2.15-2.el8.noarch.rpm 973 kB/s | 37 kB 00:00 (18/55): perl-File-Temp-0.230.600-1.el8.noarch.rpm 820 kB/s | 62 kB 00:00 (19/55): perl-Getopt-Long-2.50-4.el8.noarch.rpm 1.5 MB/s | 62 kB 00:00 (20/55): perl-HTTP-Tiny-0.074-1.el8.noarch.rpm 1.4 MB/s | 57 kB 00:00 (21/55): perl-IO-1.38-419.el8.x86_64.rpm 2.0 MB/s | 141 kB 00:00 (22/55): perl-MIME-Base64-3.15-396.el8.x86_64.rpm 671 kB/s | 30 kB 00:00 (23/55): perl-PathTools-3.74-1.el8.x86_64.rpm 2.9 MB/s | 89 kB 00:00 (24/55): perl-Encode-2.97-3.el8.x86_64.rpm 4.3 MB/s | 1.5 MB 00:00 (25/55): perl-Pod-Escapes-1.07-395.el8.noarch.rpm 555 kB/s | 19 kB 00:00 (26/55): perl-Pod-Perldoc-3.28-396.el8.noarch.rpm 2.2 MB/s | 85 kB 00:00 (27/55): perl-Pod-Simple-3.35-395.el8.noarch.rpm 5.4 MB/s | 212 kB 00:00 (28/55): perl-Pod-Usage-1.69-395.el8.noarch.rpm 900 kB/s | 33 kB 00:00 (29/55): perl-Scalar-List-Utils-1.49-2.el8.x86_64.rpm 1.8 MB/s | 67 kB 00:00 (30/55): perl-Socket-2.027-3.el8.x86_64.rpm 1.6 MB/s | 58 kB 00:00 (31/55): perl-Term-ANSIColor-4.06-396.el8.noarch.rpm 1.2 MB/s | 45 kB 00:00 (32/55): perl-Term-Cap-1.17-395.el8.noarch.rpm 615 kB/s | 22 kB 00:00 (33/55): perl-Storable-3.11-3.el8.x86_64.rpm 1.3 MB/s | 97 kB 00:00 (34/55): perl-Text-ParseWords-3.30-395.el8.noarch.rpm 463 kB/s | 17 kB 00:00 (35/55): perl-Time-Local-1.280-1.el8.noarch.rpm 863 kB/s | 32 kB 00:00 (36/55): perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch.rpm 583 kB/s | 23 kB 00:00 (37/55): perl-Unicode-Normalize-1.25-396.el8.x86_64.rpm 2.1 MB/s | 81 kB 00:00 (38/55): perl-constant-1.33-396.el8.noarch.rpm 601 kB/s | 24 kB 00:00 (39/55): perl-macros-5.26.3-419.el8.x86_64.rpm 1.8 MB/s | 71 kB 00:00 (40/55): perl-parent-0.237-1.el8.noarch.rpm 556 kB/s | 19 kB 00:00 (41/55): perl-podlators-4.11-1.el8.noarch.rpm 2.9 MB/s | 117 kB 00:00 (42/55): perl-threads-2.21-2.el8.x86_64.rpm 1.5 MB/s | 60 kB 00:00 (43/55): perl-threads-shared-1.58-2.el8.x86_64.rpm 1.2 MB/s | 47 kB 00:00 (44/55): python3-setuptools-39.2.0-6.el8.noarch.rpm 4.0 MB/s | 162 kB 00:00 (45/55): perl-libs-5.26.3-419.el8.x86_64.rpm 4.1 MB/s | 1.6 MB 00:00 (46/55): barman-2.12-1.rhel8.noarch.rpm 45 kB/s | 41 kB 00:00 (47/55): python3-psycopg2-2.8.6-1.rhel8.x86_64.rpm 426 kB/s | 178 kB 00:00 (48/55): python3-barman-2.12-1.rhel8.noarch.rpm 285 kB/s | 358 kB 00:01 (49/55): pg_stat_kcache_13-2.2.0-1.rhel8.x86_64.rpm 314 kB/s | 46 kB 00:00 (50/55): perl-interpreter-5.26.3-419.el8.x86_64.rpm 3.0 MB/s | 6.3 MB 00:02 (51/55): postgresql13-contrib-13.3-2PGDG.rhel8.x86_64.rpm 1.5 MB/s | 638 kB 00:00 (52/55): postgresql13-13.3-2PGDG.rhel8.x86_64.rpm 2.6 MB/s | 1.5 MB 00:00 (53/55): repmgr_13-5.2.1-1.rhel8.x86_64.rpm 2.0 MB/s | 293 kB 00:00 (54/55): postgresql13-server-13.3-2PGDG.rhel8.x86_64.rpm 9.1 MB/s | 5.5 MB 00:00 (55/55): postgresql13-libs-13.3-2PGDG.rhel8.x86_64.rpm 264 kB/s | 413 kB 00:01 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 3.0 MB/s | 21 MB 00:06 warning: /var/cache/dnf/pgdg-common-38b6c5045045f841/packages/barman-2.12-1.rhel8.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64 1.6 MB/s | 1.7 kB 00:00 Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project " Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : postgresql13-libs-13.3-2PGDG.rhel8.x86_64 1/55 Running scriptlet: postgresql13-libs-13.3-2PGDG.rhel8.x86_64 1/55 Installing : postgresql13-13.3-2PGDG.rhel8.x86_64 2/55 Running scriptlet: postgresql13-13.3-2PGDG.rhel8.x86_64 2/55 Running scriptlet: postgresql13-server-13.3-2PGDG.rhel8.x86_64 3/55 Installing : postgresql13-server-13.3-2PGDG.rhel8.x86_64 3/55 Running scriptlet: postgresql13-server-13.3-2PGDG.rhel8.x86_64 3/55 Installing : python3-setuptools-39.2.0-6.el8.noarch 4/55 Installing : python36-3.6.8-2.module+el8.3.0+120+426d8baf.x86_64 5/55 Running scriptlet: python36-3.6.8-2.module+el8.3.0+120+426d8baf.x86_64 5/55 Installing : python3-pip-9.0.3-19.el8.noarch 6/55 Installing : python3-psycopg2-2.8.6-1.rhel8.x86_64 7/55 Installing : perl-Digest-1.17-395.el8.noarch 8/55 Installing : perl-Digest-MD5-2.55-396.el8.x86_64 9/55 Installing : perl-Data-Dumper-2.167-399.el8.x86_64 10/55 Installing : perl-libnet-3.11-3.el8.noarch 11/55 Installing : perl-Net-SSLeay-1.88-1.module+el8.4.0+512+d4f0fc54.x86_64 12/55 Installing : perl-URI-1.73-3.el8.noarch 13/55 Installing : perl-Pod-Escapes-1:1.07-395.el8.noarch 14/55 Installing : perl-Mozilla-CA-20160104-7.module+el8.4.0+529+e3b3e624.noarch 15/55 Installing : perl-IO-Socket-IP-0.39-5.el8.noarch 16/55 Installing : perl-Time-Local-1:1.280-1.el8.noarch 17/55 Installing : perl-IO-Socket-SSL-2.066-4.module+el8.4.0+512+d4f0fc54.noarch 18/55 Installing : perl-Term-ANSIColor-4.06-396.el8.noarch 19/55 Installing : perl-Term-Cap-1.17-395.el8.noarch 20/55 Installing : perl-File-Temp-0.230.600-1.el8.noarch 21/55 Installing : perl-Pod-Simple-1:3.35-395.el8.noarch 22/55 Installing : perl-HTTP-Tiny-0.074-1.el8.noarch 23/55 Installing : perl-podlators-4.11-1.el8.noarch 24/55 Installing : perl-Pod-Perldoc-3.28-396.el8.noarch 25/55 Installing : perl-Text-ParseWords-3.30-395.el8.noarch 26/55 Installing : perl-Pod-Usage-4:1.69-395.el8.noarch 27/55 Installing : perl-MIME-Base64-3.15-396.el8.x86_64 28/55 Installing : perl-Storable-1:3.11-3.el8.x86_64 29/55 Installing : perl-Getopt-Long-1:2.50-4.el8.noarch 30/55 Installing : perl-Errno-1.28-419.el8.x86_64 31/55 Installing : perl-Socket-4:2.027-3.el8.x86_64 32/55 Installing : perl-Encode-4:2.97-3.el8.x86_64 33/55 Installing : perl-Carp-1.42-396.el8.noarch 34/55 Installing : perl-Exporter-5.72-396.el8.noarch 35/55 Installing : perl-libs-4:5.26.3-419.el8.x86_64 36/55 Installing : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 37/55 Installing : perl-parent-1:0.237-1.el8.noarch 38/55 Installing : perl-macros-4:5.26.3-419.el8.x86_64 39/55 Installing : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch 40/55 Installing : perl-Unicode-Normalize-1.25-396.el8.x86_64 41/55 Installing : perl-File-Path-2.15-2.el8.noarch 42/55 Installing : perl-IO-1.38-419.el8.x86_64 43/55 Installing : perl-PathTools-3.74-1.el8.x86_64 44/55 Installing : perl-constant-1.33-396.el8.noarch 45/55 Installing : perl-threads-1:2.21-2.el8.x86_64 46/55 Installing : perl-threads-shared-1.58-2.el8.x86_64 47/55 Installing : perl-interpreter-4:5.26.3-419.el8.x86_64 48/55 Installing : python3-argh-0.26.1-8.el8.noarch 49/55 Installing : python3-argcomplete-1.9.3-6.el8.noarch 50/55 Installing : python3-barman-2.12-1.rhel8.noarch 51/55 Running scriptlet: barman-2.12-1.rhel8.noarch 52/55 Installing : barman-2.12-1.rhel8.noarch 52/55 Installing : postgresql13-contrib-13.3-2PGDG.rhel8.x86_64 53/55 Installing : pg_stat_kcache_13-2.2.0-1.rhel8.x86_64 54/55 Running scriptlet: pg_stat_kcache_13-2.2.0-1.rhel8.x86_64 54/55 Running scriptlet: repmgr_13-5.2.1-1.rhel8.x86_64 55/55 Installing : repmgr_13-5.2.1-1.rhel8.x86_64 55/55 Running scriptlet: repmgr_13-5.2.1-1.rhel8.x86_64 55/55 Verifying : perl-Digest-1.17-395.el8.noarch 1/55 Verifying : perl-Digest-MD5-2.55-396.el8.x86_64 2/55 Verifying : perl-IO-Socket-IP-0.39-5.el8.noarch 3/55 Verifying : perl-IO-Socket-SSL-2.066-4.module+el8.4.0+512+d4f0fc54.noarch 4/55 Verifying : perl-Mozilla-CA-20160104-7.module+el8.4.0+529+e3b3e624.noarch 5/55 Verifying : perl-Net-SSLeay-1.88-1.module+el8.4.0+512+d4f0fc54.x86_64 6/55 Verifying : perl-URI-1.73-3.el8.noarch 7/55 Verifying : perl-libnet-3.11-3.el8.noarch 8/55 Verifying : python3-argcomplete-1.9.3-6.el8.noarch 9/55 Verifying : python3-argh-0.26.1-8.el8.noarch 10/55 Verifying : python3-pip-9.0.3-19.el8.noarch 11/55 Verifying : python36-3.6.8-2.module+el8.3.0+120+426d8baf.x86_64 12/55 Verifying : perl-Carp-1.42-396.el8.noarch 13/55 Verifying : perl-Data-Dumper-2.167-399.el8.x86_64 14/55 Verifying : perl-Encode-4:2.97-3.el8.x86_64 15/55 Verifying : perl-Errno-1.28-419.el8.x86_64 16/55 Verifying : perl-Exporter-5.72-396.el8.noarch 17/55 Verifying : perl-File-Path-2.15-2.el8.noarch 18/55 Verifying : perl-File-Temp-0.230.600-1.el8.noarch 19/55 Verifying : perl-Getopt-Long-1:2.50-4.el8.noarch 20/55 Verifying : perl-HTTP-Tiny-0.074-1.el8.noarch 21/55 Verifying : perl-IO-1.38-419.el8.x86_64 22/55 Verifying : perl-MIME-Base64-3.15-396.el8.x86_64 23/55 Verifying : perl-PathTools-3.74-1.el8.x86_64 24/55 Verifying : perl-Pod-Escapes-1:1.07-395.el8.noarch 25/55 Verifying : perl-Pod-Perldoc-3.28-396.el8.noarch 26/55 Verifying : perl-Pod-Simple-1:3.35-395.el8.noarch 27/55 Verifying : perl-Pod-Usage-4:1.69-395.el8.noarch 28/55 Verifying : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 29/55 Verifying : perl-Socket-4:2.027-3.el8.x86_64 30/55 Verifying : perl-Storable-1:3.11-3.el8.x86_64 31/55 Verifying : perl-Term-ANSIColor-4.06-396.el8.noarch 32/55 Verifying : perl-Term-Cap-1.17-395.el8.noarch 33/55 Verifying : perl-Text-ParseWords-3.30-395.el8.noarch 34/55 Verifying : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch 35/55 Verifying : perl-Time-Local-1:1.280-1.el8.noarch 36/55 Verifying : perl-Unicode-Normalize-1.25-396.el8.x86_64 37/55 Verifying : perl-constant-1.33-396.el8.noarch 38/55 Verifying : perl-interpreter-4:5.26.3-419.el8.x86_64 39/55 Verifying : perl-libs-4:5.26.3-419.el8.x86_64 40/55 Verifying : perl-macros-4:5.26.3-419.el8.x86_64 41/55 Verifying : perl-parent-1:0.237-1.el8.noarch 42/55 Verifying : perl-podlators-4.11-1.el8.noarch 43/55 Verifying : perl-threads-1:2.21-2.el8.x86_64 44/55 Verifying : perl-threads-shared-1.58-2.el8.x86_64 45/55 Verifying : python3-setuptools-39.2.0-6.el8.noarch 46/55 Verifying : barman-2.12-1.rhel8.noarch 47/55 Verifying : python3-barman-2.12-1.rhel8.noarch 48/55 Verifying : python3-psycopg2-2.8.6-1.rhel8.x86_64 49/55 Verifying : pg_stat_kcache_13-2.2.0-1.rhel8.x86_64 50/55 Verifying : postgresql13-13.3-2PGDG.rhel8.x86_64 51/55 Verifying : postgresql13-contrib-13.3-2PGDG.rhel8.x86_64 52/55 Verifying : postgresql13-libs-13.3-2PGDG.rhel8.x86_64 53/55 Verifying : postgresql13-server-13.3-2PGDG.rhel8.x86_64 54/55 Verifying : repmgr_13-5.2.1-1.rhel8.x86_64 55/55 Installed: barman-2.12-1.rhel8.noarch perl-Carp-1.42-396.el8.noarch perl-Data-Dumper-2.167-399.el8.x86_64 perl-Digest-1.17-395.el8.noarch perl-Digest-MD5-2.55-396.el8.x86_64 perl-Encode-4:2.97-3.el8.x86_64 perl-Errno-1.28-419.el8.x86_64 perl-Exporter-5.72-396.el8.noarch perl-File-Path-2.15-2.el8.noarch perl-File-Temp-0.230.600-1.el8.noarch perl-Getopt-Long-1:2.50-4.el8.noarch perl-HTTP-Tiny-0.074-1.el8.noarch perl-IO-1.38-419.el8.x86_64 perl-IO-Socket-IP-0.39-5.el8.noarch perl-IO-Socket-SSL-2.066-4.module+el8.4.0+512+d4f0fc54.noarch perl-MIME-Base64-3.15-396.el8.x86_64 perl-Mozilla-CA-20160104-7.module+el8.4.0+529+e3b3e624.noarch perl-Net-SSLeay-1.88-1.module+el8.4.0+512+d4f0fc54.x86_64 perl-PathTools-3.74-1.el8.x86_64 perl-Pod-Escapes-1:1.07-395.el8.noarch perl-Pod-Perldoc-3.28-396.el8.noarch perl-Pod-Simple-1:3.35-395.el8.noarch perl-Pod-Usage-4:1.69-395.el8.noarch perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 perl-Socket-4:2.027-3.el8.x86_64 perl-Storable-1:3.11-3.el8.x86_64 perl-Term-ANSIColor-4.06-396.el8.noarch perl-Term-Cap-1.17-395.el8.noarch perl-Text-ParseWords-3.30-395.el8.noarch perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch perl-Time-Local-1:1.280-1.el8.noarch perl-URI-1.73-3.el8.noarch perl-Unicode-Normalize-1.25-396.el8.x86_64 perl-constant-1.33-396.el8.noarch perl-interpreter-4:5.26.3-419.el8.x86_64 perl-libnet-3.11-3.el8.noarch perl-libs-4:5.26.3-419.el8.x86_64 perl-macros-4:5.26.3-419.el8.x86_64 perl-parent-1:0.237-1.el8.noarch perl-podlators-4.11-1.el8.noarch perl-threads-1:2.21-2.el8.x86_64 perl-threads-shared-1.58-2.el8.x86_64 pg_stat_kcache_13-2.2.0-1.rhel8.x86_64 postgresql13-13.3-2PGDG.rhel8.x86_64 postgresql13-contrib-13.3-2PGDG.rhel8.x86_64 postgresql13-libs-13.3-2PGDG.rhel8.x86_64 postgresql13-server-13.3-2PGDG.rhel8.x86_64 python3-argcomplete-1.9.3-6.el8.noarch python3-argh-0.26.1-8.el8.noarch python3-barman-2.12-1.rhel8.noarch python3-pip-9.0.3-19.el8.noarch python3-psycopg2-2.8.6-1.rhel8.x86_64 python3-setuptools-39.2.0-6.el8.noarch python36-3.6.8-2.module+el8.3.0+120+426d8baf.x86_64 repmgr_13-5.2.1-1.rhel8.x86_64 Complete! [Service] Environment=PGDATA=/pgdata/13/data Initialyze PostgreSQL 13 Initializing database ... OK Enable PostgreSQL Service Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-13.service → /usr/lib/systemd/system/postgresql-13.service. success success $ [[root@rocky ~]$
Installation is done, service is enabled to start at boot.
Lets start PostgreSQL 13 now:
$ [[root@rocky ~]$ systemctl start postgresql-13.service
Lets check the status:
$ [[root@rocky ~]$ systemctl status postgresql-13.service $ [[root@rocky ~]$ ● postgresql-13.service - PostgreSQL 13 database server $ [[root@rocky ~]$ Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled) $ [[root@rocky ~]$ Drop-In: /etc/systemd/system/postgresql-13.service.d $ [[root@rocky ~]$ └─override.conf $ [[root@rocky ~]$ Active: active (running) since Tue 2021-06-15 11:53:46 CEST; 7s ago $ [[root@rocky ~]$ Docs: https://www.postgresql.org/docs/13/static/ $ [[root@rocky ~]$ Process: 4443 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS) $ [[root@rocky ~]$ Main PID: 4449 (postmaster) $ [[root@rocky ~]$ Tasks: 8 (limit: 50551) $ [[root@rocky ~]$ Memory: 16.8M $ [[root@rocky ~]$ CGroup: /system.slice/postgresql-13.service $ [[root@rocky ~]$ ├─4449 /usr/pgsql-13/bin/postmaster -D /pgdata/13/data $ [[root@rocky ~]$ ├─4450 postgres: logger $ [[root@rocky ~]$ ├─4452 postgres: checkpointer $ [[root@rocky ~]$ ├─4453 postgres: background writer $ [[root@rocky ~]$ ├─4454 postgres: walwriter $ [[root@rocky ~]$ ├─4455 postgres: autovacuum launcher $ [[root@rocky ~]$ ├─4456 postgres: stats collector $ [[root@rocky ~]$ └─4457 postgres: logical replication launcher $ [[root@rocky ~]$ $ [[root@rocky ~]$ Jun 15 11:53:46 rocky.fritz.box systemd[1]: Starting PostgreSQL 13 database server... $ [[root@rocky ~]$ Jun 15 11:53:46 rocky.fritz.box postmaster[4449]: 2021-06-15 11:53:46.664 CEST [4449] LOG: redirecting log output to logging collector process $ [[root@rocky ~]$ Jun 15 11:53:46 rocky.fritz.box postmaster[4449]: 2021-06-15 11:53:46.664 CEST [4449] HINT: Future log output will appear in directory "log". $ [[root@rocky ~]$ Jun 15 11:53:46 rocky.fritz.box systemd[1]: Started PostgreSQL 13 database server.
With this script it is possible to operate several PostgreSQL versions at the same time on the same machine.
The binary folder and $pgdata have the Major Releasenumber of PostgreSQL within the naming.
For PostgreSQL 13 $pgdata is /pgdata/13/data and the binaries are in /usr/pgsql-13/.
With this concept ist is possible to use pg_upgrade in copy mode and having the older version for a certain time in the background available for checks after upgrade.
In my upcoming blogs i will also provide scripst for scale up and down on memory and cpu parameters according to vCPU and Memory setting, pgpass and replication setup using repmgr.
Cet article Recurring PostgreSQL Installations using RHEL 8 and Clones est apparu en premier sur Blog dbi services.