{"id":10271,"date":"2021-09-07T14:04:15","date_gmt":"2021-09-07T11:04:15","guid":{"rendered":"https:\/\/kifarunix.com\/?p=10271"},"modified":"2024-03-18T14:10:40","modified_gmt":"2024-03-18T11:10:40","slug":"install-postgresql-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-postgresql-on-rocky-linux-8\/","title":{"rendered":"Install PostgreSQL on Rocky Linux 8"},"content":{"rendered":"\n<p>In this tutorial, you will learn how to install PostgreSQL on Rocky Linux 8. <\/p>\n\n\n\n<p>&nbsp;<a href=\"https:\/\/www.datacamp.com\/courses\/creating-postgresql-databases\" target=\"_blank\" rel=\"noopener\">PostgreSQL<\/a>&nbsp;is a fully featured object-relational database management system. It supports a large part of the SQL standard and is designed to be extensible by users in many aspects.<\/p>\n\n\n\n<p>Some of the features are: ACID transactions, foreign keys, views, sequences, subqueries, triggers, user-defined types and functions, outer joins, multiversion concurrency control. Graphical user interfaces and bindings for many programming languages are available as well.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing PostgreSQL on Rocky Linux 8<\/h2>\n\n\n\n<p>Rocky Linux ships with AppStream repository modules for various versions of PostgreSQL.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf module list postgresql<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Rocky Linux 8 - AppStream\nName                                Stream                          Profiles                                    Summary                                                     \npostgresql                          9.6                             client, server [d]                          PostgreSQL server and client module                         \npostgresql                          10 [d]                          client, server [d]                          PostgreSQL server and client module                         \npostgresql                          12                              client, server [d]                          PostgreSQL server and client module                         \npostgresql                          13                              client, server [d]                          PostgreSQL server and client module                         \n\nHint: [d]efault, [e]nabled, [x]disabled, [i]nstalled\n<\/code><\/pre>\n\n\n\n<p>From the output above, you can can we that there are streams of various versions of PostgreSQL including v9.6, 10, 12, 13.<\/p>\n\n\n\n<p>The AppStream modules for PostgreSQL is enabled by default.<\/p>\n\n\n\n<p>For various reasons, you might want to install various versions of PostgreSQL on your Rocky Linux 8 box.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"pgsql-13\"><a href=\"#pgsql-13\">Install PostgreSQL 13 on Rocky Linux 8<\/a><\/h3>\n\n\n\n<p>As of this writing, <a href=\"https:\/\/www.postgresql.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">PostgreSQL 13 is the current stable release<\/a>.<\/p>\n\n\n\n<p>By default, the AppStream modules for PostgreSQL 10 are enabled by default.<\/p>\n\n\n\n<p>To install PostgreSQL 13 on Rocky Linux 8;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enable PostgreSQL 13 AppStream module<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf -qy module enable postgresql:13<\/code><\/pre>\n\n\n\n<p>Confirm;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf info postgresql-server<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Available Packages\n<strong>Name         : postgresql-server\nVersion      : 13.3<\/strong>\nRelease      : 1.module+el8.4.0+546+3620623e\nArchitecture : x86_64\nSize         : 5.6 M\nSource       : postgresql-13.3-1.module+el8.4.0+546+3620623e.src.rpm\nRepository   : appstream\nSummary      : The programs needed to create and run a PostgreSQL server\nURL          : http:\/\/www.postgresql.org\/\nLicense      : PostgreSQL\n<\/code><\/pre>\n\n\n\n<p> Hence, you can now run  the command below to install PostgreSQL 13 on Rocky Linux 8.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install postgresql-server<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Dependencies resolved.\n============================================================================================================================================================================\n Package                                  Architecture                  Version                                                      Repository                        Size\n============================================================================================================================================================================\nInstalling:\n postgresql-server                        x86_64                        13.3-1.module+el8.4.0+546+3620623e                           appstream                        5.6 M\nInstalling dependencies:\n libicu                                   x86_64                        60.3-2.el8_1                                                 baseos                           8.8 M\n libpq                                    x86_64                        13.3-1.el8_4                                                 appstream                        196 k\n postgresql                               x86_64                        13.3-1.module+el8.4.0+546+3620623e                           appstream                        1.5 M\n\nTransaction Summary\n============================================================================================================================================================================\nInstall  4 Packages\n\nTotal download size: 16 M\nInstalled size: 59 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n<p>Check the version PostgreSQL installed;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres (PostgreSQL) 13.3<\/code><\/pre>\n\n\n\n<p>Initialize the database;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgresql-setup --initdb<\/code><\/pre>\n\n\n\n<p>Start and enable PostgreSQL to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable --now postgresql<\/code><\/pre>\n\n\n\n<p>Checking the status;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status postgresql<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\u25cf postgresql.service - PostgreSQL database server\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/postgresql.service; enabled; vendor preset: disabled)\n   Active: active (running) since Tue 2021-09-07 09:42:14 EAT; 47s ago\n  Process: 15684 ExecStartPre=\/usr\/libexec\/postgresql-check-db-dir postgresql (code=exited, status=0\/SUCCESS)\n Main PID: 15686 (postmaster)\n    Tasks: 8 (limit: 4938)\n   Memory: 16.8M\n   CGroup: \/system.slice\/postgresql.service\n           \u251c\u250015686 \/usr\/bin\/postmaster -D \/var\/lib\/pgsql\/data\n           \u251c\u250015688 postgres: logger   \n           \u251c\u250015690 postgres: checkpointer   \n           \u251c\u250015691 postgres: background writer   \n           \u251c\u250015692 postgres: walwriter   \n           \u251c\u250015693 postgres: autovacuum launcher   \n           \u251c\u250015694 postgres: stats collector   \n           \u2514\u250015695 postgres: logical replication launcher   \n\nSep 07 09:42:13 rocky8 systemd[1]: Starting PostgreSQL database server...\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.544 EAT [15686] LOG:  starting PostgreSQL 12.7 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.4.1 202009&gt;\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.545 EAT [15686] LOG:  listening on IPv6 address \"::1\", port 5432\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.545 EAT [15686] LOG:  listening on IPv4 address \"127.0.0.1\", port 5432\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.687 EAT [15686] LOG:  listening on Unix socket \"\/var\/run\/postgresql\/.s.PGSQL.5432\"\nSep 07 09:42:13 rocky8 postmaster[15686]: 2021-09-07 09:42:13.962 EAT [15686] LOG:  listening on Unix socket \"\/tmp\/.s.PGSQL.5432\"\nSep 07 09:42:14 rocky8 postmaster[15686]: 2021-09-07 09:42:14.130 EAT [15686] LOG:  redirecting log output to logging collector process\nSep 07 09:42:14 rocky8 postmaster[15686]: 2021-09-07 09:42:14.130 EAT [15686] HINT:  Future log output will appear in directory \"log\".\nSep 07 09:42:14 rocky8 systemd[1]: Started PostgreSQL database server.\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"pgsql-12\"><a href=\"#pgsql-12\">Install PostgreSQL 12 on Rocky Linux 8<\/a><\/h3>\n\n\n\n<p>To install PostgreSQL 12 on Rocky Linux, run the commands below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf -qy module enable postgresql:12<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install postgresql-server<\/code><\/pre>\n\n\n\n<p>Otherwise, if you had other versions modules enabled, then reset the modules and install PostgreSQL as follows;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf -qy module reset postgresql<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf -qy module enable postgresql:12<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install postgresql-server<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Dependencies resolved.\n============================================================================================================================================================================\n Package                                  Architecture                  Version                                                      Repository                        Size\n============================================================================================================================================================================\nInstalling:\n postgresql-server                        x86_64                        12.7-1.module+el8.4.0+587+d46efd10                           appstream                        5.6 M\nInstalling dependencies:\n libicu                                   x86_64                        60.3-2.el8_1                                                 baseos                           8.8 M\n libpq                                    x86_64                        13.3-1.el8_4                                                 appstream                        196 k\n postgresql                               x86_64                        12.7-1.module+el8.4.0+587+d46efd10                           appstream                        1.5 M\n\nTransaction Summary\n============================================================================================================================================================================\nInstall  4 Packages\n\nTotal download size: 16 M\nInstalled size: 59 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n<p>After install, you can verify the version;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres (PostgreSQL) 12.7<\/code><\/pre>\n\n\n\n<p>Initialize the database;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgresql-setup --initdb<\/code><\/pre>\n\n\n\n<p>Start and enable PostgreSQL to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable --now postgresql<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"pgsql-10\"><a href=\"#pgsql-10\">Install PostgreSQL 10 on Rocky Linux 8<\/a><\/h3>\n\n\n\n<p>By default, you would simply run the commands below to install PostgreSQL 10 on Rocky Linux 8.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install postgresql-server<\/code><\/pre>\n\n\n\n<p>However, if you have other versions AppStream modules enabled, then you have to reset the modules.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf -qy module reset postgresql<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install postgresql-server<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Dependencies resolved.\n============================================================================================================================================================================\n Package                                  Architecture                  Version                                                      Repository                        Size\n============================================================================================================================================================================\nInstalling:\n postgresql-server                        x86_64                        10.17-1.module+el8.4.0+548+9eccbe3f                          appstream                        5.1 M\nInstalling dependencies:\n libpq                                    x86_64                        13.3-1.el8_4                                                 appstream                        196 k\n postgresql                               x86_64                        10.17-1.module+el8.4.0+548+9eccbe3f                          appstream                        1.5 M\nEnabling module streams:\n postgresql                                                             10                                                                                                 \n\nTransaction Summary\n============================================================================================================================================================================\nInstall  3 Packages\n\nTotal download size: 6.8 M\nInstalled size: 26 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n<p>After install, you can verify the version;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres (PostgreSQL) 10.17<\/code><\/pre>\n\n\n\n<p>Initialize the database;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgresql-setup --initdb<\/code><\/pre>\n\n\n\n<p>Start and enable PostgreSQL to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable --now postgresql<\/code><\/pre>\n\n\n\n<p>Similarly, to install PostgreSQL 9.x, then enable the module and run the installation command.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install PostgreSQL 11 on Rocky Linux 8<\/h3>\n\n\n\n<p>Rocky Linux do not provide repositories for installing PostgreSQL 11.<\/p>\n\n\n\n<p>Thus, if you want to install PostgreSQL 11 on Rocky Linux 8, then you need to install the repository RPM:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install -y https:\/\/download.postgresql.org\/pub\/repos\/yum\/reporpms\/EL-8-x86_64\/pgdg-redhat-repo-latest.noarch.rpm<\/code><\/pre>\n\n\n\n<p id=\"block-4499b478-7fa7-4f29-989a-9bc93786b063\">Disable the built-in PostgreSQL module:<\/p>\n\n\n\n<pre id=\"script-box\" class=\"wp-block-code\"><code>dnf -qy module disable postgresql<\/code><\/pre>\n\n\n\n<p>Install PostgreSQL 11 on Rocky Linux 8<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install postgresql11-server<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Dependencies resolved.\n============================================================================================================================================================================\n Package                                         Architecture                       Version                                        Repository                          Size\n============================================================================================================================================================================\nInstalling:\n postgresql11-server                             x86_64                             11.13-1PGDG.rhel8                              pgdg11                             4.9 M\nInstalling dependencies:\n libicu                                          x86_64                             60.3-2.el8_1                                   baseos                             8.8 M\n postgresql11                                    x86_64                             11.13-1PGDG.rhel8                              pgdg11                             1.7 M\n postgresql11-libs                               x86_64                             11.13-1PGDG.rhel8                              pgdg11                             394 k\n\nTransaction Summary\n============================================================================================================================================================================\nInstall  4 Packages\n\nTotal download size: 16 M\nInstalled size: 60 M\nIs this ok [y\/N]: y\n<\/code><\/pre>\n\n\n\n<p id=\"script-box\">Initialize the database;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgresql-11-setup initdb<\/code><\/pre>\n\n\n\n<p>Start and enable PostgreSQL to run on system boot;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable --now postgresql-11<\/code><\/pre>\n\n\n\n<p>Checking the status;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status postgresql-11<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\u25cf postgresql-11.service - PostgreSQL 11 database server\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/postgresql-11.service; enabled; vendor preset: disabled)\n   Active: active (running) since Tue 2021-09-07 09:19:07 EAT; 44s ago\n     Docs: https:\/\/www.postgresql.org\/docs\/11\/static\/\n  Process: 11990 ExecStartPre=\/usr\/pgsql-11\/bin\/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=0\/SUCCESS)\n Main PID: 11995 (postmaster)\n    Tasks: 8 (limit: 4938)\n   Memory: 16.4M\n   CGroup: \/system.slice\/postgresql-11.service\n           \u251c\u250011995 \/usr\/pgsql-11\/bin\/postmaster -D \/var\/lib\/pgsql\/11\/data\/\n           \u251c\u250012001 postgres: logger   \n           \u251c\u250012003 postgres: checkpointer   \n           \u251c\u250012004 postgres: background writer   \n           \u251c\u250012005 postgres: walwriter   \n           \u251c\u250012006 postgres: autovacuum launcher   \n           \u251c\u250012007 postgres: stats collector   \n           \u2514\u250012008 postgres: logical replication launcher   \n\nSep 07 09:19:05 rocky8 systemd[1]: Starting PostgreSQL 11 database server...\nSep 07 09:19:06 rocky8 postmaster[11995]: 2021-09-07 09:19:06.387 EAT [11995] LOG:  listening on IPv6 address \"::1\", port 5432\nSep 07 09:19:06 rocky8 postmaster[11995]: 2021-09-07 09:19:06.387 EAT [11995] LOG:  listening on IPv4 address \"127.0.0.1\", port 5432\nSep 07 09:19:06 rocky8 postmaster[11995]: 2021-09-07 09:19:06.541 EAT [11995] LOG:  listening on Unix socket \"\/var\/run\/postgresql\/.s.PGSQL.5432\"\nSep 07 09:19:06 rocky8 postmaster[11995]: 2021-09-07 09:19:06.848 EAT [11995] LOG:  listening on Unix socket \"\/tmp\/.s.PGSQL.5432\"\nSep 07 09:19:07 rocky8 postmaster[11995]: 2021-09-07 09:19:07.005 EAT [11995] LOG:  redirecting log output to logging collector process\nSep 07 09:19:07 rocky8 postmaster[11995]: 2021-09-07 09:19:07.005 EAT [11995] HINT:  Future log output will appear in directory \"log\".\nSep 07 09:19:07 rocky8 systemd[1]: Started PostgreSQL 11 database server.\n<\/code><\/pre>\n\n\n\n<p>Read More on <a href=\"https:\/\/www.postgresqltutorial.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">PostgreSQL Tutorials<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-lamp-stack-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install LAMP Stack on Debian 11<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/enable-mssql-server-and-database-level-auditing\/\" target=\"_blank\" rel=\"noreferrer noopener\">Enable MSSQL Server and Database Level Auditing<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-postgresql-13-on-debian-11\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install PostgreSQL 13 on Debian 11<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to install PostgreSQL on Rocky Linux 8. &nbsp;PostgreSQL&nbsp;is a fully featured object-relational database management system. It supports a<\/p>\n","protected":false},"author":3,"featured_media":10267,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,299],"tags":[4066,4065,4067,4064,4063,990,4068,3587],"class_list":["post-10271","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-database","tag-install-postgresql-10-on-rocky-linux-8","tag-install-postgresql-11-on-rocky-linux-8","tag-install-postgresql-12-on-rocky-linux-8","tag-install-postgresql-13-on-rocky-linux-8","tag-install-postgresql-on-rocky-linux-8","tag-postgresql","tag-postgresql-13-install-rocky-linux-8","tag-rocky-linux-8","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10271"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=10271"}],"version-history":[{"count":7,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10271\/revisions"}],"predecessor-version":[{"id":21664,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/10271\/revisions\/21664"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/10267"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=10271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=10271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=10271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}