{"id":8212,"date":"2021-07-10T12:11:27","date_gmt":"2021-07-10T12:11:27","guid":{"rendered":"https:\/\/linuxways.net\/?p=8212"},"modified":"2021-07-10T12:11:27","modified_gmt":"2021-07-10T12:11:27","slug":"how-to-install-postgresql-13-on-rocky-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/red-hat\/how-to-install-postgresql-13-on-rocky-linux\/","title":{"rendered":"How to Install PostgreSQL 13 on Rocky Linux"},"content":{"rendered":"<p>Commonly referred to as Postgres, PostgreSQL is a free and open-source, advanced, and stable relational database management system that has been around for over 20 years since its release in 1996. Synonymous with its blue elephant logo, PostgreSQL is widely used among professionals and regular users who are trying to find their way in Relational Database Management Systems (RDMS). PostgreSQL is hugely popular, and according to a survey conducted by StackOverflow in 2019, it comes second to MySQL with a market share of 36.3%. Some of the Tech giants that use PostgreSQL include Apple, Reddit, Spotify, Skype, and Instagram to mention a few.<\/p>\n<p>One of the aspects that makes PostgreSQL so popular especially among developers is its supports for a vast number of programming languages including Python, Java, C\/C++, Go, Javascript, Perl, and Ruby. It also ships with powerful features which include:<\/p>\n<ul>\n<li>User-defined types<\/li>\n<li>Asynchronous replication<\/li>\n<li>Table inheritance<\/li>\n<li>Nested transactions<\/li>\n<li>Multi-version concurrency control (MVCC)<\/li>\n<li>Advanced locking mechanism<\/li>\n<li>Foreign key referential integrity<\/li>\n<\/ul>\n<p>The latest release is<a href=\"https:\/\/www.postgresql.org\/docs\/13\/release-13.html\"> PostgreSQL 13<\/a> which was released in September 2020. It provides a number of improvements which include:<\/p>\n<ul>\n<li>Incremental sorting.<\/li>\n<li>Improved query planning whilst leveraging enhanced statistics.<\/li>\n<li>Faster response times in queries that use partitions or aggregates.<\/li>\n<li>Performance gains for indexes.<\/li>\n<li>Parallelized vacuuming of indexes.<\/li>\n<\/ul>\n<p>In this tutorial, we focus on the installation of PostgreSQL 13 on Rocky Linux 8.4.<\/p>\n<h2>Step 1: Update Rocky Linux repositories<\/h2>\n<p>The default version of PostgreSQL in Rocky Linux repositories is version 10. However, the latest version is PostgreSQL 13 and this is what we intend to install. To maneuver around this obstacle, we will download the latest YUM repository from PostgreSQL and add it to our system as follows.<\/p>\n<pre><strong>$ sudo dnf install https:\/\/download.postgresql.org\/pub\/repos\/yum\/reporpms\/EL-8-x86_64\/pgdg-redhat-repo-latest.noarch.rpm<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"433\" class=\"wp-image-8213\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-330.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-330.png 886w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-330-300x147.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-330-768x375.png 768w\" sizes=\"auto, (max-width: 886px) 100vw, 886px\" \/><\/p>\n<h2><strong>Step 2: Disable default module<\/strong><\/h2>\n<p>As pointed out earlier, the default PostgreSQL module is version 10. Before proceeding any further, we need to disable it so that we can install the latest version.<\/p>\n<p>To disable the default module, issue the command:<\/p>\n<pre><strong>$ sudo dnf -qy module disable postgresql<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"891\" height=\"247\" class=\"wp-image-8214\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-331.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-331.png 891w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-331-300x83.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-331-768x213.png 768w\" sizes=\"auto, (max-width: 891px) 100vw, 891px\" \/><\/p>\n<p><strong>Step 3: Update the system<\/strong><\/p>\n<p>To synchronize with the newly added PostgreSQL repository, update your Rocky Linux 8 instance as shown.<\/p>\n<pre><strong>$ sudo dnf update -y<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"367\" class=\"wp-image-8215\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-332.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-332.png 890w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-332-300x124.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-332-768x317.png 768w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/strong><\/p>\n<p><strong>Step 4: Install PostgreSQL 13 server and client on Rocky<\/strong><\/p>\n<p>With the latest PostgreSQL repository in place, install the PostgreSQL client and server as follows.<\/p>\n<pre><strong>$ sudo dnf install postgresql13 postgresql13-server<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"458\" class=\"wp-image-8216\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-333.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-333.png 890w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-333-300x154.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-333-768x395.png 768w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/strong><\/p>\n<p>Once the installation is complete, you should see the following output.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"889\" height=\"384\" class=\"wp-image-8217\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-334.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-334.png 889w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-334-300x130.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-334-768x332.png 768w\" sizes=\"auto, (max-width: 889px) 100vw, 889px\" \/><\/p>\n<p>To verify the version installed, execute:<\/p>\n<pre><strong>$ psql -V<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"194\" class=\"wp-image-8218\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-335.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-335.png 890w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-335-300x65.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-335-768x167.png 768w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/p>\n<h2><strong>Step 5: Initialize the database<\/strong><\/h2>\n<p>Thus far, we have installed the PostgreSQL server and ensured that it is running. Next, we will initialize the <strong>initdb <\/strong>database which will create a new PostgreSQL cluster that comprises multiple databases &amp; tables. To initialize the database, run the command:<\/p>\n<pre><strong>$ sudo <\/strong><\/pre>\n<p><strong>\/usr\/pgsql-*\/bin\/postgresql-*-setup initdb<\/strong><\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"187\" class=\"wp-image-8219\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-336.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-336.png 890w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-336-300x63.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-336-768x161.png 768w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/strong><\/p>\n<h2><strong>Step 6: Enable and start PostgreSQL service<\/strong><\/h2>\n<p>Once the database has been initialized, proceed and enable PostgreSQL to start on boot.<\/p>\n<pre><strong>$ sudo systemctl enable postgresql-13<\/strong><\/pre>\n<p>Once enabled, start PostgreSQL.<\/p>\n<pre><strong>$ sudo systemctl start postgresql-13<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"885\" height=\"272\" class=\"wp-image-8220\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-337.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-337.png 885w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-337-300x92.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-337-768x236.png 768w\" sizes=\"auto, (max-width: 885px) 100vw, 885px\" \/><\/strong><\/p>\n<p>To verify that indeed PostgreSQL is active and running, invoke the command:<\/p>\n<pre><strong>$ sudo systemctl status postgresql-13<\/strong><\/pre>\n<p>The output below confirms that the PostgreSQL service is running.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"265\" class=\"wp-image-8221\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-338.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-338.png 890w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-338-300x89.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-338-768x229.png 768w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/strong><\/p>\n<h2><strong>Step 7. Connecting to PostgreSQL<\/strong><\/h2>\n<p>During installation. PostgreSQL creates a new user called postgres. We will leverage this user to gain access to Postgres prompt.<\/p>\n<p>So, run the command:<\/p>\n<pre><strong>$ sudo su - postgres<\/strong><\/pre>\n<p>To access PostgresSQL prompt, execute:<\/p>\n<pre><strong>$ psql<\/strong><\/pre>\n<p>From here, you can proceed and create your database and tables and perform all the database management operations you deem fit.<\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"895\" height=\"317\" class=\"wp-image-8222\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-339.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-339.png 895w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-339-300x106.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-339-768x272.png 768w\" sizes=\"auto, (max-width: 895px) 100vw, 895px\" \/><\/strong><\/p>\n<p>To exit from the prompt, simply run:<\/p>\n<pre><strong>$ \\q<\/strong><\/pre>\n<p>TO revert to your user account, type \u2018exit\u2019.<\/p>\n<pre><strong>$ exit<\/strong><\/pre>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"647\" height=\"165\" class=\"wp-image-8223\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-340.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-340.png 647w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/07\/word-image-340-300x77.png 300w\" sizes=\"auto, (max-width: 647px) 100vw, 647px\" \/><\/strong><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>That was a walkthrough of PostgreSQL 13 installation on Rocky Linux 8.4. We do hope you now have the wherewithal to install the RDMS on your system without any trouble.<\/p>","protected":false},"excerpt":{"rendered":"<p>Commonly referred to as Postgres, PostgreSQL is a free and open-source, advanced, and stable relational database management system that has been around for over 20 years since its&hellip;<\/p>","protected":false},"author":1,"featured_media":8246,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165],"tags":[415,411],"class_list":["post-8212","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-red-hat","tag-postgresql-13","tag-rocky-linux"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=8212"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/8212\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/8246"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=8212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=8212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=8212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}